diff --git a/sdk/core/azure-core-management/CHANGELOG.md b/sdk/core/azure-core-management/CHANGELOG.md index 8521c8ed9ec77..d3cafb5f3cfc6 100644 --- a/sdk/core/azure-core-management/CHANGELOG.md +++ b/sdk/core/azure-core-management/CHANGELOG.md @@ -4,6 +4,10 @@ ### Features Added +- Added `ExternalEvaluationPolicy` to support the Azure Policy external evaluation ("Invoke") flow. When every + blocking policy violation requires a policy token, the policy acquires one through the client pipeline and retries + the operation. + ### Breaking Changes ### Bugs Fixed diff --git a/sdk/core/azure-core-management/pom.xml b/sdk/core/azure-core-management/pom.xml index ab62b15d9c357..24c68531b236f 100644 --- a/sdk/core/azure-core-management/pom.xml +++ b/sdk/core/azure-core-management/pom.xml @@ -47,7 +47,12 @@ 0.21 0.24 + --add-reads com.azure.core.management=com.azure.http.netty + --add-reads com.azure.core.management=io.netty.handler + --add-reads com.azure.core.management=reactor.netty.http --add-opens com.azure.core.management/com.azure.core.management.implementation.polling=ALL-UNNAMED + --add-opens com.azure.core.management/com.azure.resourcemanager.storage.models=com.azure.core,com.azure.json + --add-opens com.azure.core.management/com.azure.resourcemanager.storage.fluent.models=com.azure.core,com.azure.json diff --git a/sdk/core/azure-core-management/src/main/java/com/azure/core/management/http/policy/ExternalEvaluationPolicy.java b/sdk/core/azure-core-management/src/main/java/com/azure/core/management/http/policy/ExternalEvaluationPolicy.java new file mode 100644 index 0000000000000..536f89a0ee653 --- /dev/null +++ b/sdk/core/azure-core-management/src/main/java/com/azure/core/management/http/policy/ExternalEvaluationPolicy.java @@ -0,0 +1,396 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.core.management.http.policy; + +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpMethod; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineCallContext; +import com.azure.core.http.HttpPipelineNextPolicy; +import com.azure.core.http.HttpPipelineNextSyncPolicy; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.HttpRequest; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.management.exception.ManagementError; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.implementation.evaluation.MissingPolicyTokenDetails; +import com.azure.core.util.BinaryData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonProviders; +import com.azure.json.JsonReader; +import com.azure.json.JsonWriter; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.Map; +import java.util.Objects; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * The pipeline policy that drives the Azure Policy external evaluation ("Invoke") flow. + *

+ * When a resource operation is disallowed by policy because an external evaluation policy token is missing, Azure + * Resource Manager responds with {@code 403 RequestDisallowedByPolicy}. This policy acquires a token through a + * dedicated pipeline, applies it to the {@code x-ms-policy-external-evaluations} header, and retries the original + * operation once through the management pipeline. + *

+ * The flow applies to all resource operations except {@code GET}. Requests that already carry the token header are + * left untouched to prevent the replay from re-entering the flow. + */ +public class ExternalEvaluationPolicy implements HttpPipelinePolicy { + private static final ClientLogger LOGGER = new ClientLogger(ExternalEvaluationPolicy.class); + + private static final HttpHeaderName POLICY_EXTERNAL_EVALUATIONS + = HttpHeaderName.fromString("x-ms-policy-external-evaluations"); + private static final HttpHeaderName CONTENT_TYPE = HttpHeaderName.fromString("Content-Type"); + private static final HttpHeaderName ACCEPT = HttpHeaderName.fromString("Accept"); + + private static final String APPLICATION_JSON = "application/json"; + private static final String POLICY_API_VERSION = "2026-07-01"; + private static final String ACQUIRE_POLICY_TOKEN + = "/providers/Microsoft.Authorization/acquirePolicyToken?api-version=" + POLICY_API_VERSION; + + private static final int FORBIDDEN = 403; + private static final byte[] EMPTY_BODY = new byte[0]; + private static final byte[] ACQUIRE_BODY_SUFFIX = "}}".getBytes(StandardCharsets.UTF_8); + + private static final Pattern MANAGEMENT_GROUP_SCOPE = Pattern + .compile("^/providers/Microsoft\\.Management/managementGroups/([^/]+)(?:/|$)", Pattern.CASE_INSENSITIVE); + private static final Pattern RESOURCE_GROUP_SCOPE + = Pattern.compile("^/subscriptions/([^/]+)/resourceGroups/([^/]+)(?:/|$)", Pattern.CASE_INSENSITIVE); + private static final Pattern SUBSCRIPTION_SCOPE + = Pattern.compile("^/subscriptions/([^/]+)(?:/|$)", Pattern.CASE_INSENSITIVE); + + private final HttpPipeline acquisitionPipeline; + + /** + * Creates an {@link ExternalEvaluationPolicy}. + * + * @param acquisitionPipeline the pipeline used to acquire policy tokens + */ + public ExternalEvaluationPolicy(HttpPipeline acquisitionPipeline) { + this.acquisitionPipeline = Objects.requireNonNull(acquisitionPipeline, "'acquisitionPipeline' cannot be null."); + } + + @Override + public HttpPipelinePosition getPipelinePosition() { + return HttpPipelinePosition.PER_CALL; + } + + @Override + public Mono process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) { + HttpRequest request = context.getHttpRequest(); + if (shouldSkip(request)) { + return next.process(); + } + + return makeBodyReplayable(request).then(Mono.defer(() -> { + HttpRequest originalRequest = context.getHttpRequest().copy(); + PolicyScope scope = PolicyScope.from(originalRequest.getUrl()); + HttpPipelineNextPolicy original = next.clone(); + HttpPipelineNextPolicy replay = next.clone(); + + context.setHttpRequest(originalRequest.copy()); + return original.process().flatMap(response -> { + if (response.getStatusCode() != FORBIDDEN) { + return Mono.just(response); + } + + HttpResponse bufferedResponse = response.buffer(); + return bufferedResponse.getBodyAsByteArray().defaultIfEmpty(EMPTY_BODY).flatMap(body -> { + MissingPolicyTokenDetails details = MissingPolicyTokenDetails.parse(body); + if (details == null || scope == null) { + return Mono.just(bufferedResponse); + } + + RuntimeException guardError = validate(details); + if (guardError != null) { + bufferedResponse.close(); + return Mono.error(guardError); + } + + return acquirePolicyToken(context, originalRequest, scope) + .onErrorMap(error -> policyDeniedException(bufferedResponse, body, error)) + .flatMap(token -> { + HttpRequest replayRequest = originalRequest.copy(); + replayRequest.setHeader(POLICY_EXTERNAL_EVALUATIONS, token); + context.setHttpRequest(replayRequest); + bufferedResponse.close(); + return replay.process(); + }); + }); + }); + })); + } + + @Override + public HttpResponse processSync(HttpPipelineCallContext context, HttpPipelineNextSyncPolicy next) { + HttpRequest request = context.getHttpRequest(); + if (shouldSkip(request)) { + return next.processSync(); + } + + makeBodyReplayableSync(request); + HttpRequest originalRequest = context.getHttpRequest().copy(); + PolicyScope scope = PolicyScope.from(originalRequest.getUrl()); + HttpPipelineNextSyncPolicy original = next.clone(); + HttpPipelineNextSyncPolicy replay = next.clone(); + + context.setHttpRequest(originalRequest.copy()); + HttpResponse response = original.processSync(); + if (response.getStatusCode() != FORBIDDEN) { + return response; + } + + HttpResponse bufferedResponse = response.buffer(); + byte[] body = bufferedResponse.getBodyAsByteArray().block(); + MissingPolicyTokenDetails details = MissingPolicyTokenDetails.parse(body); + if (details == null || scope == null) { + return bufferedResponse; + } + + RuntimeException guardError = validate(details); + if (guardError != null) { + bufferedResponse.close(); + throw LOGGER.logExceptionAsError(guardError); + } + + String token; + try { + token = acquirePolicyTokenSync(context, originalRequest, scope); + } catch (RuntimeException acquisitionError) { + throw LOGGER.logExceptionAsError(policyDeniedException(bufferedResponse, body, acquisitionError)); + } + + HttpRequest replayRequest = originalRequest.copy(); + replayRequest.setHeader(POLICY_EXTERNAL_EVALUATIONS, token); + context.setHttpRequest(replayRequest); + bufferedResponse.close(); + return replay.processSync(); + } + + private Mono acquirePolicyToken(HttpPipelineCallContext context, HttpRequest originalRequest, + PolicyScope scope) { + return createAcquireRequest(originalRequest, scope) + .flatMap(request -> acquisitionPipeline.send(request, + context.getContext().addData(HttpLoggingPolicy.BODY_LOGGING_DISABLED_CONTEXT, true))) + .flatMap(ExternalEvaluationPolicy::readPolicyToken); + } + + private String acquirePolicyTokenSync(HttpPipelineCallContext context, HttpRequest originalRequest, + PolicyScope scope) { + HttpRequest request = createAcquireRequestSync(originalRequest, scope); + return readPolicyTokenSync(acquisitionPipeline.sendSync(request, + context.getContext().addData(HttpLoggingPolicy.BODY_LOGGING_DISABLED_CONTEXT, true))); + } + + private static Mono createAcquireRequest(HttpRequest originalRequest, PolicyScope scope) { + byte[] prefix = createAcquireBodyPrefix(originalRequest); + BinaryData originalBody = originalRequest.getBodyAsBinaryData(); + Flux serializedBody = originalBody == null + ? Flux.just(ByteBuffer.wrap(prefix), ByteBuffer.wrap(ACQUIRE_BODY_SUFFIX)) + : Flux.concat(Flux.just(ByteBuffer.wrap(prefix)), originalBody.toFluxByteBuffer(), + Flux.just(ByteBuffer.wrap(ACQUIRE_BODY_SUFFIX))); + + return BinaryData.fromFlux(serializedBody) + .map(body -> createAcquireRequest(originalRequest.getUrl(), scope, body)); + } + + private static HttpRequest createAcquireRequestSync(HttpRequest originalRequest, PolicyScope scope) { + byte[] prefix = createAcquireBodyPrefix(originalRequest); + BinaryData originalBody = originalRequest.getBodyAsBinaryData(); + byte[] body = originalBody == null ? EMPTY_BODY : originalBody.toBytes(); + int bodyLength = body.length; + byte[] serializedBody = new byte[prefix.length + bodyLength + ACQUIRE_BODY_SUFFIX.length]; + System.arraycopy(prefix, 0, serializedBody, 0, prefix.length); + if (originalBody != null) { + System.arraycopy(body, 0, serializedBody, prefix.length, body.length); + } + System.arraycopy(ACQUIRE_BODY_SUFFIX, 0, serializedBody, prefix.length + bodyLength, + ACQUIRE_BODY_SUFFIX.length); + return createAcquireRequest(originalRequest.getUrl(), scope, BinaryData.fromBytes(serializedBody)); + } + + private static HttpRequest createAcquireRequest(URL originalUrl, PolicyScope scope, BinaryData body) { + HttpRequest request = new HttpRequest(HttpMethod.POST, scope.acquireUrl(originalUrl)); + request.setHeader(CONTENT_TYPE, APPLICATION_JSON); + request.setHeader(ACCEPT, APPLICATION_JSON); + request.setBody(body); + return request; + } + + private static byte[] createAcquireBodyPrefix(HttpRequest request) { + String prefix = "{\"operation\":{\"uri\":" + toJsonString(request.getUrl().toString()) + ",\"httpMethod\":" + + toJsonString(request.getHttpMethod().toString()); + if (request.getBodyAsBinaryData() != null) { + prefix += ",\"content\":"; + } + return prefix.getBytes(StandardCharsets.UTF_8); + } + + private static String toJsonString(String value) { + ByteArrayOutputStream output = new ByteArrayOutputStream(); + try (JsonWriter writer = JsonProviders.createWriter(output)) { + writer.writeString(value); + } catch (IOException e) { + throw LOGGER.logExceptionAsError(new IllegalStateException("Failed to serialize the acquire request.", e)); + } + return new String(output.toByteArray(), StandardCharsets.UTF_8); + } + + private static Mono readPolicyToken(HttpResponse response) { + HttpResponse bufferedResponse = response.buffer(); + return bufferedResponse.getBodyAsByteArray().defaultIfEmpty(EMPTY_BODY).flatMap(body -> { + try { + String token = extractPolicyToken(bufferedResponse, body); + bufferedResponse.close(); + return Mono.just(token); + } catch (ManagementException e) { + return Mono.error(e); + } catch (RuntimeException e) { + bufferedResponse.close(); + return Mono.error(e); + } + }); + } + + private static String readPolicyTokenSync(HttpResponse response) { + HttpResponse bufferedResponse = response.buffer(); + byte[] body = bufferedResponse.getBodyAsByteArray().block(); + try { + String token = extractPolicyToken(bufferedResponse, body); + bufferedResponse.close(); + return token; + } catch (ManagementException e) { + throw e; + } catch (RuntimeException e) { + bufferedResponse.close(); + throw e; + } + } + + @SuppressWarnings("unchecked") + private static String extractPolicyToken(HttpResponse response, byte[] body) { + if (response.getStatusCode() < 200 || response.getStatusCode() >= 300) { + ManagementError error = parseManagementError(body); + String message = error != null && error.getMessage() != null + ? error.getMessage() + : "The policy token acquisition request failed with status code " + response.getStatusCode() + "."; + throw new ManagementException(message, response, error); + } + + try (JsonReader reader = JsonProviders.createReader(body)) { + Object root = reader.readUntyped(); + Object tokenValue = root instanceof Map ? ((Map) root).get("token") : null; + String token = tokenValue instanceof String ? (String) tokenValue : null; + if (token != null && !token.trim().isEmpty()) { + return token; + } + throw new IllegalStateException("The policy token acquisition response did not contain a valid token."); + } catch (IOException e) { + throw new IllegalStateException("The policy token acquisition response could not be parsed.", e); + } + } + + private static Mono makeBodyReplayable(HttpRequest request) { + BinaryData body = request.getBodyAsBinaryData(); + if (body == null || body.isReplayable()) { + return Mono.empty(); + } + return body.toReplayableBinaryDataAsync().doOnNext(request::setBody).then(); + } + + private static void makeBodyReplayableSync(HttpRequest request) { + BinaryData body = request.getBodyAsBinaryData(); + if (body != null && !body.isReplayable()) { + request.setBody(body.toReplayableBinaryData()); + } + } + + private static RuntimeException validate(MissingPolicyTokenDetails details) { + if (details.isChangeReferenceRequired()) { + return new IllegalStateException("The policy external evaluation flow requires a change reference, which " + + "is not supported by this version of the SDK. Please upgrade to a newer version of the Azure SDK."); + } + return null; + } + + private static ManagementException policyDeniedException(HttpResponse deniedResponse, byte[] deniedBody, + Throwable cause) { + ManagementError error = parseManagementError(deniedBody); + String message = error != null && error.getMessage() != null + ? error.getMessage() + : "The resource operation was disallowed by policy and a policy token could not be acquired."; + ManagementException exception = new ManagementException(message, deniedResponse, error); + exception.initCause(cause); + return exception; + } + + private static ManagementError parseManagementError(byte[] body) { + if (body == null || body.length == 0) { + return null; + } + try (JsonReader reader = JsonProviders.createReader(body)) { + return ManagementError.fromJson(reader); + } catch (IOException | RuntimeException e) { + return null; + } + } + + private static boolean shouldSkip(HttpRequest request) { + return request.getHttpMethod() == HttpMethod.GET + || request.getHeaders().getValue(POLICY_EXTERNAL_EVALUATIONS) != null; + } + + private static final class PolicyScope { + private final String acquirePath; + + private PolicyScope(String acquirePath) { + this.acquirePath = acquirePath; + } + + private static PolicyScope from(URL url) { + String path = url.getPath(); + Matcher managementGroup = MANAGEMENT_GROUP_SCOPE.matcher(path); + if (managementGroup.find()) { + return new PolicyScope("/providers/Microsoft.Management/managementGroups/" + managementGroup.group(1) + + ACQUIRE_POLICY_TOKEN); + } + + Matcher resourceGroup = RESOURCE_GROUP_SCOPE.matcher(path); + if (resourceGroup.find()) { + return new PolicyScope("/subscriptions/" + resourceGroup.group(1) + "/resourceGroups/" + + resourceGroup.group(2) + ACQUIRE_POLICY_TOKEN); + } + + Matcher subscription = SUBSCRIPTION_SCOPE.matcher(path); + if (subscription.find()) { + return new PolicyScope("/subscriptions/" + subscription.group(1) + ACQUIRE_POLICY_TOKEN); + } + + LOGGER.verbose("Unable to determine the ARM scope from the request URL; " + + "skipping the policy external evaluation flow."); + return null; + } + + private URL acquireUrl(URL originalUrl) { + try { + return originalUrl.toURI().resolve(acquirePath).toURL(); + } catch (MalformedURLException | URISyntaxException e) { + throw LOGGER.logExceptionAsError( + new IllegalStateException("Failed to construct the policy token acquisition URL.", e)); + } + } + } +} diff --git a/sdk/core/azure-core-management/src/main/java/com/azure/core/management/implementation/evaluation/MissingPolicyTokenDetails.java b/sdk/core/azure-core-management/src/main/java/com/azure/core/management/implementation/evaluation/MissingPolicyTokenDetails.java new file mode 100644 index 0000000000000..3157101a4ec25 --- /dev/null +++ b/sdk/core/azure-core-management/src/main/java/com/azure/core/management/implementation/evaluation/MissingPolicyTokenDetails.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.core.management.implementation.evaluation; + +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonProviders; +import com.azure.json.JsonReader; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * Internal representation of the external evaluation details returned in a policy-denied response. + */ +public final class MissingPolicyTokenDetails { + private static final ClientLogger LOGGER = new ClientLogger(MissingPolicyTokenDetails.class); + + private static final String ERROR = "error"; + private static final String CODE = "code"; + private static final String REQUEST_DISALLOWED_BY_POLICY = "RequestDisallowedByPolicy"; + private static final String ADDITIONAL_INFO = "additionalInfo"; + private static final String TYPE = "type"; + private static final String POLICY_VIOLATION = "PolicyViolation"; + private static final String INFO = "info"; + private static final String EVALUATION_DETAILS = "evaluationDetails"; + private static final String MISSING_POLICY_TOKEN_DETAILS = "missingPolicyTokenDetails"; + private static final String SHOULD_DENY = "shouldDeny"; + private static final String IS_CHANGE_REFERENCE_REQUIRED = "isChangeReferenceRequired"; + + private final boolean changeReferenceRequired; + + private MissingPolicyTokenDetails(boolean changeReferenceRequired) { + this.changeReferenceRequired = changeReferenceRequired; + } + + /** + * Whether the service requires a change-safety reference to acquire the policy token. + * + * @return whether a change reference is required. + */ + public boolean isChangeReferenceRequired() { + return changeReferenceRequired; + } + + /** + * Parses an actionable external evaluation response. + *

+ * A response is actionable only when it is a {@code RequestDisallowedByPolicy} error containing at least one + * {@code PolicyViolation}, and every policy violation contains + * {@code evaluationDetails.missingPolicyTokenDetails.shouldDeny=true}. + * + * @param body the raw response body. + * @return the aggregated details, or {@code null} when token acquisition should not be attempted. + */ + @SuppressWarnings("unchecked") + public static MissingPolicyTokenDetails parse(byte[] body) { + if (body == null || body.length == 0) { + return null; + } + + try (JsonReader jsonReader = JsonProviders.createReader(body)) { + Object rootValue = jsonReader.readUntyped(); + if (!(rootValue instanceof Map)) { + return null; + } + + Object errorValue = ((Map) rootValue).get(ERROR); + if (!(errorValue instanceof Map)) { + return null; + } + Map error = (Map) errorValue; + if (!REQUEST_DISALLOWED_BY_POLICY.equalsIgnoreCase(asString(error.get(CODE)))) { + return null; + } + + Object additionalInfoValue = error.get(ADDITIONAL_INFO); + if (!(additionalInfoValue instanceof List)) { + return null; + } + + boolean foundPolicyViolation = false; + boolean changeReferenceRequired = false; + for (Object additionalInfoEntry : (List) additionalInfoValue) { + if (!(additionalInfoEntry instanceof Map)) { + continue; + } + + Map additionalInfo = (Map) additionalInfoEntry; + if (!POLICY_VIOLATION.equalsIgnoreCase(asString(additionalInfo.get(TYPE)))) { + continue; + } + + foundPolicyViolation = true; + Map missingTokenDetails = getMissingTokenDetails(additionalInfo.get(INFO)); + if (missingTokenDetails == null || !Boolean.TRUE.equals(missingTokenDetails.get(SHOULD_DENY))) { + return null; + } + changeReferenceRequired |= Boolean.TRUE.equals(missingTokenDetails.get(IS_CHANGE_REFERENCE_REQUIRED)); + } + + return foundPolicyViolation ? new MissingPolicyTokenDetails(changeReferenceRequired) : null; + } catch (IOException | RuntimeException ex) { + LOGGER.verbose("Failed to parse the policy violation details from the response body.", ex); + return null; + } + } + + @SuppressWarnings("unchecked") + private static Map getMissingTokenDetails(Object infoValue) { + if (!(infoValue instanceof Map)) { + return null; + } + Object evaluationDetailsValue = ((Map) infoValue).get(EVALUATION_DETAILS); + if (!(evaluationDetailsValue instanceof Map)) { + return null; + } + Object missingTokenDetailsValue + = ((Map) evaluationDetailsValue).get(MISSING_POLICY_TOKEN_DETAILS); + return missingTokenDetailsValue instanceof Map ? (Map) missingTokenDetailsValue : null; + } + + private static String asString(Object value) { + return value instanceof String ? (String) value : null; + } +} diff --git a/sdk/core/azure-core-management/src/main/java/com/azure/core/management/implementation/evaluation/package-info.java b/sdk/core/azure-core-management/src/main/java/com/azure/core/management/implementation/evaluation/package-info.java new file mode 100644 index 0000000000000..566b1331de1a5 --- /dev/null +++ b/sdk/core/azure-core-management/src/main/java/com/azure/core/management/implementation/evaluation/package-info.java @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +/** + * Package containing internal implementation types for the Azure Policy external evaluation ("Invoke") flow. + */ +package com.azure.core.management.implementation.evaluation; diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/core/management/http/policy/ExternalEvaluationPolicyE2ETests.java b/sdk/core/azure-core-management/src/test/java/com/azure/core/management/http/policy/ExternalEvaluationPolicyE2ETests.java new file mode 100644 index 0000000000000..2023322c9e2d5 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/core/management/http/policy/ExternalEvaluationPolicyE2ETests.java @@ -0,0 +1,183 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.core.management.http.policy; + +import com.azure.core.credential.AccessToken; +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpMethod; +import com.azure.core.http.HttpRequest; +import com.azure.core.http.HttpResponse; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.storage.StorageManager; +import com.azure.resourcemanager.storage.fluent.models.StorageAccountInner; +import com.azure.resourcemanager.storage.models.Kind; +import com.azure.resourcemanager.storage.models.Sku; +import com.azure.resourcemanager.storage.models.SkuName; +import com.azure.resourcemanager.storage.models.StorageAccountCreateParameters; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +/** + * End-to-end test for {@link ExternalEvaluationPolicy} that exercises the full external evaluation ("Invoke") flow + * against a real generated Storage management client, with Azure Resource Manager faked by WireMock. + */ +public class ExternalEvaluationPolicyE2ETests { + private static final String SUBSCRIPTION_ID = "00000000-0000-0000-0000-000000000000"; + private static final String RESOURCE_GROUP = "rg"; + private static final String ACCOUNT_NAME = "acct"; + private static final String POLICY_TOKEN_VALUE = "PoP eyJhbGciOiJSUzI1NiJ9.policy-token-value"; + private static final String EE_HEADER = "x-ms-policy-external-evaluations"; + + private static final String STORAGE_PATH = "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + + "/providers/Microsoft.Storage/storageAccounts/" + ACCOUNT_NAME; + private static final String ACQUIRE_PATH = "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + + "/providers/Microsoft.Authorization/acquirePolicyToken"; + + private static final String DENY_BODY = "{\"error\":{\"code\":\"RequestDisallowedByPolicy\"," + + "\"message\":\"Resource was disallowed by policy.\",\"additionalInfo\":[{\"type\":\"PolicyViolation\"," + + "\"info\":{\"evaluationDetails\":{\"missingPolicyTokenDetails\":{\"shouldDeny\":true," + + "\"endpointKind\":\"AzureResourceGraph\",\"isChangeReferenceRequired\":false}}}}]}}"; + + private static final String STORAGE_BODY = "{\"id\":\"" + STORAGE_PATH + "\",\"name\":\"" + ACCOUNT_NAME + "\"," + + "\"type\":\"Microsoft.Storage/storageAccounts\",\"location\":\"eastus\"," + + "\"properties\":{\"provisioningState\":\"Succeeded\"}}"; + + private static final String ACQUIRE_BODY = "{\"result\":\"Succeeded\",\"token\":\"" + POLICY_TOKEN_VALUE + "\"," + + "\"tokenId\":\"11111111-1111-1111-1111-111111111111\"}"; + + // The exact JSON body the Storage create operation serializes for the parameters built below. The External + // Evaluation flow requires the retried request body to be byte-for-byte identical to the original, so the mock + // service asserts on this exact string for both the denied and the retried PUT. + private static final String EXPECTED_REQUEST_BODY + = "{\"sku\":{\"name\":\"Standard_LRS\"},\"kind\":\"StorageV2\",\"location\":\"eastus\"}"; + + private static final String API_VERSION = "2026-04-01"; + + @Test + public void endToEndAcquireAndRetry() { + String endpoint = "https://management.azure.com"; + String operationUrl = endpoint + STORAGE_PATH + "?api-version=" + API_VERSION; + String acquireUrl = endpoint + ACQUIRE_PATH + "?api-version=2026-07-01"; + String expectedAcquireBody = "{\"operation\":{\"uri\":\"" + operationUrl + + "\",\"httpMethod\":\"PUT\",\"content\":" + EXPECTED_REQUEST_BODY + "}}"; + RecordingHttpClient httpClient = new RecordingHttpClient(); + StorageManager storageManager = StorageManager.configure() + .withHttpClient(httpClient) + .withExternalEvaluation() + .authenticate(credential(), profile(endpoint)); + + StorageAccountInner result = storageManager.serviceClient() + .getResourceProviders() + .create(RESOURCE_GROUP, ACCOUNT_NAME, + new StorageAccountCreateParameters().withSku(new Sku().withName(SkuName.STANDARD_LRS)) + .withKind(Kind.STORAGE_V2) + .withLocation("eastus")); + + assertNotNull(result); + assertEquals(ACCOUNT_NAME, result.name()); + assertEquals(3, httpClient.requests.size()); + assertRequest(httpClient.requests.get(0), HttpMethod.PUT, operationUrl, null, EXPECTED_REQUEST_BODY); + assertRequest(httpClient.requests.get(1), HttpMethod.POST, acquireUrl, null, expectedAcquireBody); + assertRequest(httpClient.requests.get(2), HttpMethod.PUT, operationUrl, POLICY_TOKEN_VALUE, + EXPECTED_REQUEST_BODY); + } + + @Test + public void externalEvaluationIsDisabledByDefault() { + String endpoint = "https://management.azure.com"; + RecordingHttpClient httpClient = new RecordingHttpClient(); + StorageManager storageManager + = StorageManager.configure().withHttpClient(httpClient).authenticate(credential(), profile(endpoint)); + + assertThrows(ManagementException.class, + () -> storageManager.serviceClient() + .getResourceProviders() + .create(RESOURCE_GROUP, ACCOUNT_NAME, + new StorageAccountCreateParameters().withSku(new Sku().withName(SkuName.STANDARD_LRS)) + .withKind(Kind.STORAGE_V2) + .withLocation("eastus"))); + + assertEquals(1, httpClient.requests.size()); + assertRequest(httpClient.requests.get(0), HttpMethod.PUT, + endpoint + STORAGE_PATH + "?api-version=" + API_VERSION, null, EXPECTED_REQUEST_BODY); + } + + private static TokenCredential credential() { + return request -> Mono.just(new AccessToken("dummy-token", OffsetDateTime.now().plusHours(1))); + } + + private static AzureProfile profile(String endpoint) { + Map endpoints = new HashMap<>(); + endpoints.put(AzureEnvironment.Endpoint.MANAGEMENT.identifier(), endpoint); + endpoints.put(AzureEnvironment.Endpoint.RESOURCE_MANAGER.identifier(), endpoint); + endpoints.put(AzureEnvironment.Endpoint.ACTIVE_DIRECTORY.identifier(), endpoint); + return new AzureProfile("tenant", SUBSCRIPTION_ID, new AzureEnvironment(endpoints)); + } + + private static void assertRequest(CapturedRequest request, HttpMethod method, String url, String token, + String body) { + assertEquals(method, request.method); + assertEquals(url, request.url); + assertEquals(token, request.token); + assertEquals(body, request.body); + } + + private static final class RecordingHttpClient implements HttpClient { + private final List requests = new ArrayList<>(); + + @Override + public Mono send(HttpRequest request) { + String token = request.getHeaders().getValue(HttpHeaderName.fromString(EE_HEADER)); + String body = request.getBodyAsBinaryData() == null ? null : request.getBodyAsBinaryData().toString(); + requests.add(new CapturedRequest(request.getHttpMethod(), request.getUrl().toString(), token, body)); + + if (request.getHttpMethod() == HttpMethod.POST && request.getUrl().getPath().equals(ACQUIRE_PATH)) { + return response(request, 200, ACQUIRE_BODY); + } + if (request.getHttpMethod() == HttpMethod.PUT && token == null) { + return response(request, 403, DENY_BODY); + } + if (request.getHttpMethod() == HttpMethod.PUT && POLICY_TOKEN_VALUE.equals(token)) { + return response(request, 200, STORAGE_BODY); + } + return response(request, 500, "{}"); + } + + private static Mono response(HttpRequest request, int statusCode, String body) { + HttpHeaders headers = new HttpHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/json"); + return Mono.just(new MockHttpResponse(request, statusCode, headers, body.getBytes(StandardCharsets.UTF_8))); + } + } + + private static final class CapturedRequest { + private final HttpMethod method; + private final String url; + private final String token; + private final String body; + + private CapturedRequest(HttpMethod method, String url, String token, String body) { + this.method = method; + this.url = url; + this.token = token; + this.body = body; + } + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/core/management/http/policy/ExternalEvaluationPolicyTests.java b/sdk/core/azure-core-management/src/test/java/com/azure/core/management/http/policy/ExternalEvaluationPolicyTests.java new file mode 100644 index 0000000000000..85bb4df8940f8 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/core/management/http/policy/ExternalEvaluationPolicyTests.java @@ -0,0 +1,446 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.core.management.http.policy; + +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpMethod; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelineCallContext; +import com.azure.core.http.HttpPipelineNextPolicy; +import com.azure.core.http.HttpRequest; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.BinaryData; +import com.azure.core.util.Context; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import reactor.test.StepVerifier; + +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + +public class ExternalEvaluationPolicyTests { + private static final HttpHeaderName POLICY_EXTERNAL_EVALUATIONS + = HttpHeaderName.fromString("x-ms-policy-external-evaluations"); + + private static final String SUBSCRIPTION_ID = "00000000-0000-0000-0000-000000000000"; + private static final String OPERATION_PATH + = "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/rg/providers/Microsoft.Storage/storageAccounts/acc"; + private static final String OPERATION_URL + = "https://management.azure.com" + OPERATION_PATH + "?api-version=2023-01-01"; + private static final String RESOURCE_GROUP_ACQUIRE_URL + = "https://management.azure.com/subscriptions/" + SUBSCRIPTION_ID + + "/resourceGroups/rg/providers/Microsoft.Authorization/acquirePolicyToken?api-version=2026-07-01"; + + private static final String REQUEST_BODY = "{\"location\":\"eastus\"}"; + private static final String TOKEN_VALUE = "PoP test-policy-token"; + private static final String TOKEN_BODY = "{\"token\":\"" + TOKEN_VALUE + "\"}"; + + private static final String MISSING_DETAILS = "\"evaluationDetails\":{\"missingPolicyTokenDetails\":" + + "{\"shouldDeny\":true,\"endpointKind\":\"AzureResourceGraph\",\"isChangeReferenceRequired\":false}}"; + private static final String MISSING_DETAILS_BODY = denyBody(policyViolation(MISSING_DETAILS)); + private static final String CHANGE_REFERENCE_REQUIRED_BODY + = denyBody(policyViolation("\"evaluationDetails\":{\"missingPolicyTokenDetails\":{\"shouldDeny\":true," + + "\"isChangeReferenceRequired\":true}}")); + private static final String PLAIN_DENY_BODY + = "{\"error\":{\"code\":\"RequestDisallowedByPolicy\",\"message\":\"Resource was disallowed by policy.\"}}"; + + @Test + public void acquiresTokenAndRetriesAsync() { + MockHttpClient client + = new MockHttpClient(new int[] { 403, 200, 200 }, new String[] { MISSING_DETAILS_BODY, TOKEN_BODY, "{}" }); + + StepVerifier.create(pipeline(client).send(newRequest())) + .assertNext(response -> Assertions.assertEquals(200, response.getStatusCode())) + .verifyComplete(); + + assertHappyPath(client); + } + + @Test + public void acquiresTokenAndRetriesSync() { + MockHttpClient client + = new MockHttpClient(new int[] { 403, 200, 200 }, new String[] { MISSING_DETAILS_BODY, TOKEN_BODY, "{}" }); + + HttpResponse response = pipeline(client).sendSync(newRequest(), Context.NONE); + + Assertions.assertEquals(200, response.getStatusCode()); + assertHappyPath(client); + } + + @Test + public void acquisitionUsesDedicatedPipeline() { + MockHttpClient managementClient + = new MockHttpClient(new int[] { 403, 200 }, new String[] { MISSING_DETAILS_BODY, "{}" }); + MockHttpClient acquisitionClient = new MockHttpClient(new int[] { 200 }, new String[] { TOKEN_BODY }); + + StepVerifier.create(pipeline(managementClient, acquisitionClient).send(newRequest())) + .assertNext(response -> Assertions.assertEquals(200, response.getStatusCode())) + .verifyComplete(); + + Assertions.assertEquals(2, managementClient.requests.size()); + Assertions.assertEquals(HttpMethod.PUT, managementClient.requests.get(0).method); + Assertions.assertEquals(HttpMethod.PUT, managementClient.requests.get(1).method); + Assertions.assertEquals(1, acquisitionClient.requests.size()); + Assertions.assertEquals(HttpMethod.POST, acquisitionClient.requests.get(0).method); + Assertions.assertEquals(RESOURCE_GROUP_ACQUIRE_URL, acquisitionClient.requests.get(0).url); + } + + @ParameterizedTest + @CsvSource({ + "'/subscriptions/" + SUBSCRIPTION_ID + "/providers/Microsoft.Compute/virtualMachines/vm','/subscriptions/" + + SUBSCRIPTION_ID + "/providers/Microsoft.Authorization/acquirePolicyToken'", + "'/subscriptions/" + SUBSCRIPTION_ID + + "/resourceGroups/my-rg/providers/Microsoft.Compute/virtualMachines/vm','/subscriptions/" + SUBSCRIPTION_ID + + "/resourceGroups/my-rg/providers/Microsoft.Authorization/acquirePolicyToken'", + "'/providers/Microsoft.Management/managementGroups/my-mg/providers/Microsoft.Authorization/policyAssignments/a'," + + "'/providers/Microsoft.Management/managementGroups/my-mg/providers/Microsoft.Authorization/" + + "acquirePolicyToken'" }) + public void selectsAcquireEndpointFromOperationScope(String operationPath, String expectedAcquirePath) { + MockHttpClient client + = new MockHttpClient(new int[] { 403, 200, 200 }, new String[] { MISSING_DETAILS_BODY, TOKEN_BODY, "{}" }); + HttpRequest request = new HttpRequest(HttpMethod.PUT, + "https://management.azure.com" + operationPath + "?api-version=2023-01-01") + .setBody(BinaryData.fromString(REQUEST_BODY)); + + StepVerifier.create(pipeline(client).send(request)).expectNextCount(1).verifyComplete(); + + Assertions.assertEquals("https://management.azure.com" + expectedAcquirePath + "?api-version=2026-07-01", + client.requests.get(1).url); + } + + @Test + public void onlyAcquiresWhenEveryPolicyViolationRequiresToken() { + String mixedDeny = denyBody(policyViolation(MISSING_DETAILS), + policyViolation("\"evaluationDetails\":{\"reason\":\"ordinary deny\"}")); + MockHttpClient client = new MockHttpClient(new int[] { 403 }, new String[] { mixedDeny }); + + StepVerifier.create(pipeline(client).send(newRequest())) + .assertNext(response -> Assertions.assertEquals(403, response.getStatusCode())) + .verifyComplete(); + + Assertions.assertEquals(1, client.requests.size()); + } + + @Test + public void shouldDenyMustBeTrue() { + String shouldNotDeny + = denyBody(policyViolation("\"evaluationDetails\":{\"missingPolicyTokenDetails\":{\"shouldDeny\":false}}")); + MockHttpClient client = new MockHttpClient(new int[] { 403 }, new String[] { shouldNotDeny }); + + StepVerifier.create(pipeline(client).send(newRequest())) + .assertNext(response -> Assertions.assertEquals(403, response.getStatusCode())) + .verifyComplete(); + + Assertions.assertEquals(1, client.requests.size()); + } + + @Test + public void ignoresUnrelatedAdditionalInfoEntries() { + String deny = denyBody("{\"type\":\"Other\",\"info\":{}}", policyViolation(MISSING_DETAILS)); + MockHttpClient client + = new MockHttpClient(new int[] { 403, 200, 200 }, new String[] { deny, TOKEN_BODY, "{}" }); + + StepVerifier.create(pipeline(client).send(newRequest())).expectNextCount(1).verifyComplete(); + + Assertions.assertEquals(3, client.requests.size()); + } + + @Test + public void tokenIsSuccessRegardlessOfOtherResponseFields() { + MockHttpClient client = new MockHttpClient(new int[] { 403, 200, 200 }, + new String[] { MISSING_DETAILS_BODY, "{\"result\":\"Failed\",\"token\":\"" + TOKEN_VALUE + "\"}", "{}" }); + + StepVerifier.create(pipeline(client).send(newRequest())) + .assertNext(response -> Assertions.assertEquals(200, response.getStatusCode())) + .verifyComplete(); + + Assertions.assertEquals(TOKEN_VALUE, client.requests.get(2).header); + } + + @Test + public void disablesBodyLoggingOnlyForAcquisition() { + MockHttpClient client + = new MockHttpClient(new int[] { 403, 200, 200 }, new String[] { MISSING_DETAILS_BODY, TOKEN_BODY, "{}" }); + BodyLoggingContextPolicy contextPolicy = new BodyLoggingContextPolicy(); + + StepVerifier.create(pipeline(client, contextPolicy).send(newRequest())).expectNextCount(1).verifyComplete(); + + Assertions.assertEquals(java.util.Arrays.asList(false, true, false), contextPolicy.values); + } + + @Test + public void preservesCallerBodyLoggingSuppression() { + MockHttpClient client + = new MockHttpClient(new int[] { 403, 200, 200 }, new String[] { MISSING_DETAILS_BODY, TOKEN_BODY, "{}" }); + BodyLoggingContextPolicy contextPolicy = new BodyLoggingContextPolicy(); + Context context = Context.NONE.addData(HttpLoggingPolicy.BODY_LOGGING_DISABLED_CONTEXT, true); + + StepVerifier.create(pipeline(client, contextPolicy).send(newRequest(), context)) + .expectNextCount(1) + .verifyComplete(); + + Assertions.assertEquals(java.util.Arrays.asList(true, true, true), contextPolicy.values); + } + + @Test + public void missingTokenReSurfacesOriginalDeny() { + MockHttpClient client = new MockHttpClient(new int[] { 403, 200 }, + new String[] { MISSING_DETAILS_BODY, "{\"result\":\"Succeeded\"}" }); + + StepVerifier.create(pipeline(client).send(newRequest())).verifyErrorMatches(error -> { + if (!(error instanceof ManagementException)) { + return false; + } + ManagementException denied = (ManagementException) error; + return denied.getResponse().getStatusCode() == 403 + && denied.getCause() instanceof IllegalStateException + && denied.getCause().getMessage().contains("did not contain a valid token"); + }); + } + + @Test + public void acquisitionHttpErrorReSurfacesOriginalDeny() { + String acquireError = "{\"error\":{\"code\":\"AcquisitionFailed\",\"message\":\"Policy rejected issuance.\"}}"; + MockHttpClient client + = new MockHttpClient(new int[] { 403, 500 }, new String[] { MISSING_DETAILS_BODY, acquireError }); + + StepVerifier.create(pipeline(client).send(newRequest())).verifyErrorMatches(error -> { + if (!(error instanceof ManagementException) || !(error.getCause() instanceof ManagementException)) { + return false; + } + ManagementException denied = (ManagementException) error; + ManagementException acquisition = (ManagementException) error.getCause(); + return denied.getResponse().getStatusCode() == 403 + && acquisition.getResponse().getStatusCode() == 500 + && "AcquisitionFailed".equals(acquisition.getValue().getCode()); + }); + } + + @Test + public void preservesNonReplayableOperationBody() { + MockHttpClient client + = new MockHttpClient(new int[] { 403, 200, 200 }, new String[] { MISSING_DETAILS_BODY, TOKEN_BODY, "{}" }); + BinaryData nonReplayable = BinaryData + .fromFlux(Flux.just(ByteBuffer.wrap(REQUEST_BODY.getBytes(StandardCharsets.UTF_8))), null, false) + .block(); + HttpRequest request = new HttpRequest(HttpMethod.PUT, OPERATION_URL).setBody(nonReplayable); + + StepVerifier.create(pipeline(client).send(request)).expectNextCount(1).verifyComplete(); + + assertHappyPath(client); + } + + @Test + public void acquiresTokenForDeleteWithoutBody() { + MockHttpClient client + = new MockHttpClient(new int[] { 403, 200, 200 }, new String[] { MISSING_DETAILS_BODY, TOKEN_BODY, "{}" }); + HttpRequest request = new HttpRequest(HttpMethod.DELETE, OPERATION_URL); + + StepVerifier.create(pipeline(client).send(request)).expectNextCount(1).verifyComplete(); + + Assertions.assertEquals("{\"operation\":{\"uri\":\"" + OPERATION_URL + "\",\"httpMethod\":\"DELETE\"}}", + client.requests.get(1).body); + Assertions.assertNull(client.requests.get(0).body); + Assertions.assertNull(client.requests.get(2).body); + } + + @Test + public void plainDenyIsPassedThrough() { + MockHttpClient client = new MockHttpClient(new int[] { 403 }, new String[] { PLAIN_DENY_BODY }); + + StepVerifier.create(pipeline(client).send(newRequest())) + .assertNext(response -> Assertions.assertEquals(403, response.getStatusCode())) + .verifyComplete(); + + Assertions.assertEquals(1, client.requests.size()); + } + + @Test + public void changeReferenceRequiredIsGuarded() { + MockHttpClient client = new MockHttpClient(new int[] { 403 }, new String[] { CHANGE_REFERENCE_REQUIRED_BODY }); + + StepVerifier.create(pipeline(client).send(newRequest())).verifyError(IllegalStateException.class); + + Assertions.assertEquals(1, client.requests.size()); + } + + @Test + public void getAndPreAuthorizedRequestsAreNotIntercepted() { + MockHttpClient getClient = new MockHttpClient(new int[] { 403 }, new String[] { MISSING_DETAILS_BODY }); + StepVerifier.create(pipeline(getClient).send(new HttpRequest(HttpMethod.GET, OPERATION_URL))) + .assertNext(response -> Assertions.assertEquals(403, response.getStatusCode())) + .verifyComplete(); + + MockHttpClient authorizedClient = new MockHttpClient(new int[] { 403 }, new String[] { MISSING_DETAILS_BODY }); + HttpRequest authorizedRequest + = newRequest().setHeader(POLICY_EXTERNAL_EVALUATIONS, "PoP already-present-token"); + StepVerifier.create(pipeline(authorizedClient).send(authorizedRequest)) + .assertNext(response -> Assertions.assertEquals(403, response.getStatusCode())) + .verifyComplete(); + + Assertions.assertEquals(1, getClient.requests.size()); + Assertions.assertEquals(1, authorizedClient.requests.size()); + } + + private static void assertHappyPath(MockHttpClient client) { + Assertions.assertEquals(3, client.requests.size()); + + CapturedRequest original = client.requests.get(0); + Assertions.assertEquals(HttpMethod.PUT, original.method); + Assertions.assertEquals(OPERATION_URL, original.url); + Assertions.assertNull(original.header); + Assertions.assertEquals(REQUEST_BODY, original.body); + + CapturedRequest acquire = client.requests.get(1); + Assertions.assertEquals(HttpMethod.POST, acquire.method); + Assertions.assertEquals(RESOURCE_GROUP_ACQUIRE_URL, acquire.url); + Assertions.assertNull(acquire.header); + Assertions.assertEquals("{\"operation\":{\"uri\":\"" + OPERATION_URL + "\",\"httpMethod\":\"PUT\",\"content\":" + + REQUEST_BODY + "}}", acquire.body); + + CapturedRequest replay = client.requests.get(2); + Assertions.assertEquals(HttpMethod.PUT, replay.method); + Assertions.assertEquals(OPERATION_URL, replay.url); + Assertions.assertEquals(TOKEN_VALUE, replay.header); + Assertions.assertEquals(REQUEST_BODY, replay.body); + } + + private static String denyBody(String... additionalInfo) { + return "{\"error\":{\"code\":\"RequestDisallowedByPolicy\",\"message\":\"A policy token is required.\"," + + "\"additionalInfo\":[" + String.join(",", additionalInfo) + "]}}"; + } + + private static String policyViolation(String infoContent) { + return "{\"type\":\"PolicyViolation\",\"info\":{" + infoContent + "}}"; + } + + private static HttpPipeline pipeline(HttpClient client, HttpPipelinePolicy... additionalPolicies) { + return pipeline(client, client, additionalPolicies); + } + + private static HttpPipeline pipeline(HttpClient managementClient, HttpClient acquisitionClient, + HttpPipelinePolicy... additionalPolicies) { + HttpPipeline acquisitionPipeline + = new HttpPipelineBuilder().policies(additionalPolicies).httpClient(acquisitionClient).build(); + HttpPipelinePolicy[] policies = new HttpPipelinePolicy[additionalPolicies.length + 1]; + policies[0] = new ExternalEvaluationPolicy(acquisitionPipeline); + System.arraycopy(additionalPolicies, 0, policies, 1, additionalPolicies.length); + return new HttpPipelineBuilder().policies(policies).httpClient(managementClient).build(); + } + + private static HttpRequest newRequest() { + return new HttpRequest(HttpMethod.PUT, OPERATION_URL).setBody(BinaryData.fromString(REQUEST_BODY)); + } + + private static final class CapturedRequest { + private final HttpMethod method; + private final String url; + private final String header; + private final String body; + + private CapturedRequest(HttpMethod method, String url, String header, String body) { + this.method = method; + this.url = url; + this.header = header; + this.body = body; + } + } + + private static final class MockHttpClient implements HttpClient { + private final int[] statusCodes; + private final String[] bodies; + private final AtomicInteger index = new AtomicInteger(); + private final List requests = new ArrayList<>(); + + private MockHttpClient(int[] statusCodes, String[] bodies) { + this.statusCodes = statusCodes; + this.bodies = bodies; + } + + @Override + public Mono send(HttpRequest request) { + String header = request.getHeaders().getValue(POLICY_EXTERNAL_EVALUATIONS); + String body = request.getBodyAsBinaryData() == null ? null : request.getBodyAsBinaryData().toString(); + synchronized (requests) { + requests.add(new CapturedRequest(request.getHttpMethod(), request.getUrl().toString(), header, body)); + } + int i = index.getAndIncrement(); + return Mono.just(new MockHttpResponse(request, statusCodes[i], bodies[i])); + } + } + + private static final class BodyLoggingContextPolicy implements HttpPipelinePolicy { + private final List values = new ArrayList<>(); + + @Override + public Mono process(HttpPipelineCallContext context, HttpPipelineNextPolicy next) { + values.add( + Boolean.TRUE.equals(context.getData(HttpLoggingPolicy.BODY_LOGGING_DISABLED_CONTEXT).orElse(false))); + return next.process(); + } + } + + private static final class MockHttpResponse extends HttpResponse { + private final int statusCode; + private final HttpHeaders headers; + private final byte[] body; + + private MockHttpResponse(HttpRequest request, int statusCode, String body) { + super(request); + this.statusCode = statusCode; + this.body = body.getBytes(StandardCharsets.UTF_8); + this.headers = new HttpHeaders().set(HttpHeaderName.CONTENT_LENGTH, String.valueOf(this.body.length)); + } + + @Override + public int getStatusCode() { + return statusCode; + } + + @Override + @SuppressWarnings("deprecation") + public String getHeaderValue(String name) { + return headers.getValue(name); + } + + @Override + public HttpHeaders getHeaders() { + return headers; + } + + @Override + public Flux getBody() { + return Flux.just(ByteBuffer.wrap(body)); + } + + @Override + public Mono getBodyAsByteArray() { + return Mono.just(body); + } + + @Override + public Mono getBodyAsString() { + return Mono.just(new String(body, StandardCharsets.UTF_8)); + } + + @Override + public Mono getBodyAsString(Charset charset) { + return Mono.just(new String(body, charset)); + } + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/StorageManager.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/StorageManager.java new file mode 100644 index 0000000000000..fcbaaebd6a543 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/StorageManager.java @@ -0,0 +1,322 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.AddHeadersFromContextPolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.http.policy.ExternalEvaluationPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.storage.fluent.StorageManagementClient; +import com.azure.resourcemanager.storage.implementation.ResourceProvidersImpl; +import com.azure.resourcemanager.storage.implementation.StorageManagementClientBuilder; +import com.azure.resourcemanager.storage.models.ResourceProviders; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Entry point to StorageManager. + * The Azure Storage Management API. + */ +public final class StorageManager { + private ResourceProviders resourceProviders; + + private final StorageManagementClient clientObject; + + private StorageManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new StorageManagementClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of Storage service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Storage service API instance. + */ + public static StorageManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Creates an instance of Storage service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the Storage service API instance. + */ + public static StorageManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new StorageManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create StorageManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new StorageManager.Configurable(); + } + + /** + * The Configurable allowing configurations to be set. + */ + public static final class Configurable { + private static final ClientLogger LOGGER = new ClientLogger(Configurable.class); + private static final String SDK_VERSION = "version"; + private static final Map PROPERTIES + = CoreUtils.getProperties("azure-resourcemanager-storage.properties"); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); + private RetryPolicy retryPolicy; + private RetryOptions retryOptions; + private Duration defaultPollInterval; + private boolean externalEvaluationEnabled; + + private Configurable() { + } + + /** + * Sets the http client. + * + * @param httpClient the HTTP client. + * @return the configurable object itself. + */ + public Configurable withHttpClient(HttpClient httpClient) { + this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null."); + return this; + } + + /** + * Sets the logging options to the HTTP pipeline. + * + * @param httpLogOptions the HTTP log options. + * @return the configurable object itself. + */ + public Configurable withLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'httpLogOptions' cannot be null."); + return this; + } + + /** + * Adds the pipeline policy to the HTTP pipeline. + * + * @param policy the HTTP pipeline policy. + * @return the configurable object itself. + */ + public Configurable withPolicy(HttpPipelinePolicy policy) { + this.policies.add(Objects.requireNonNull(policy, "'policy' cannot be null.")); + return this; + } + + /** + * Enables external policy evaluation. + * + * @return the configurable object itself. + */ + public Configurable withExternalEvaluation() { + this.externalEvaluationEnabled = true; + return this; + } + + /** + * Adds the scope to permission sets. + * + * @param scope the scope. + * @return the configurable object itself. + */ + public Configurable withScope(String scope) { + this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null.")); + return this; + } + + /** + * Sets the retry policy to the HTTP pipeline. + * + * @param retryPolicy the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); + return this; + } + + /** + * Sets the retry options for the HTTP pipeline retry policy. + *

+ * This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}. + * + * @param retryOptions the retry options for the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryOptions(RetryOptions retryOptions) { + this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' cannot be null."); + return this; + } + + /** + * Sets the default poll interval, used when service does not provide "Retry-After" header. + * + * @param defaultPollInterval the default poll interval. + * @return the configurable object itself. + */ + public Configurable withDefaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval + = Objects.requireNonNull(defaultPollInterval, "'defaultPollInterval' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw LOGGER + .logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of Storage service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Storage service API instance. + */ + public StorageManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder.append("azsdk-java") + .append("-") + .append("com.azure.resourcemanager.storage") + .append("/") + .append(clientVersion); + if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { + userAgentBuilder.append(" (") + .append(Configuration.getGlobalConfiguration().get("java.version")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.name")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.version")) + .append("; auto-generated)"); + } else { + userAgentBuilder.append(" (auto-generated)"); + } + + if (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } + if (retryPolicy == null) { + if (retryOptions != null) { + retryPolicy = new RetryPolicy(retryOptions); + } else { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + } + HttpPipeline acquisitionPipeline = null; + HttpClient pipelineHttpClient = this.httpClient; + if (externalEvaluationEnabled) { + List acquisitionPolicies = new ArrayList<>(); + acquisitionPolicies.add(new UserAgentPolicy(userAgentBuilder.toString())); + acquisitionPolicies.add(new AddHeadersFromContextPolicy()); + acquisitionPolicies.add(new RequestIdPolicy()); + acquisitionPolicies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(acquisitionPolicies); + acquisitionPolicies.add(retryPolicy); + acquisitionPolicies.add(new AddDatePolicy()); + acquisitionPolicies.add(new BearerTokenAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + acquisitionPolicies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(acquisitionPolicies); + acquisitionPolicies.add(new HttpLoggingPolicy(httpLogOptions)); + acquisitionPipeline = new HttpPipelineBuilder().httpClient(this.httpClient) + .policies(acquisitionPolicies.toArray(new HttpPipelinePolicy[0])) + .build(); + pipelineHttpClient = acquisitionPipeline.getHttpClient(); + } + + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new AddHeadersFromContextPolicy()); + policies.add(new RequestIdPolicy()); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + if (acquisitionPipeline != null) { + policies.add(new ExternalEvaluationPolicy(acquisitionPipeline)); + } + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies.add(new BearerTokenAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + policies.addAll(this.policies.stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(pipelineHttpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new StorageManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** + * Gets the resource collection API of ResourceProviders. It manages StorageAccount. + * + * @return Resource collection API of ResourceProviders. + */ + public ResourceProviders resourceProviders() { + if (this.resourceProviders == null) { + this.resourceProviders = new ResourceProvidersImpl(clientObject.getResourceProviders(), this); + } + return resourceProviders; + } + + /** + * Gets wrapped service client StorageManagementClient providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + * + * @return Wrapped service client StorageManagementClient. + */ + public StorageManagementClient serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/ResourceProvidersClient.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/ResourceProvidersClient.java new file mode 100644 index 0000000000000..f321a97ab297c --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/ResourceProvidersClient.java @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.storage.fluent.models.StorageAccountInner; +import com.azure.resourcemanager.storage.models.StorageAccountCreateParameters; + +/** + * An instance of this class provides access to all the operations defined in ResourceProvidersClient. + */ +public interface ResourceProvidersClient { + /** + * Asynchronously creates a new storage account with the specified parameters. If an account is already created and + * a subsequent create request is issued with different properties, the account properties will be updated. If an + * account is already created and a subsequent create or update request is issued with the exact same set of + * properties, the request will succeed. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the storage account within the specified resource group. Storage account names + * must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param parameters The parameters to provide for the created account. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of the storage account. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, StorageAccountInner> beginCreate(String resourceGroupName, + String accountName, StorageAccountCreateParameters parameters); + + /** + * Asynchronously creates a new storage account with the specified parameters. If an account is already created and + * a subsequent create request is issued with different properties, the account properties will be updated. If an + * account is already created and a subsequent create or update request is issued with the exact same set of + * properties, the request will succeed. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the storage account within the specified resource group. Storage account names + * must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param parameters The parameters to provide for the created account. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of the storage account. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, StorageAccountInner> beginCreate(String resourceGroupName, + String accountName, StorageAccountCreateParameters parameters, Context context); + + /** + * Asynchronously creates a new storage account with the specified parameters. If an account is already created and + * a subsequent create request is issued with different properties, the account properties will be updated. If an + * account is already created and a subsequent create or update request is issued with the exact same set of + * properties, the request will succeed. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the storage account within the specified resource group. Storage account names + * must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param parameters The parameters to provide for the created account. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the storage account. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + StorageAccountInner create(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters); + + /** + * Asynchronously creates a new storage account with the specified parameters. If an account is already created and + * a subsequent create request is issued with different properties, the account properties will be updated. If an + * account is already created and a subsequent create or update request is issued with the exact same set of + * properties, the request will succeed. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the storage account within the specified resource group. Storage account names + * must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param parameters The parameters to provide for the created account. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the storage account. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + StorageAccountInner create(String resourceGroupName, String accountName, StorageAccountCreateParameters parameters, + Context context); +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/StorageManagementClient.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/StorageManagementClient.java new file mode 100644 index 0000000000000..1eb4634e1bcd7 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/StorageManagementClient.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for StorageManagementClient class. + */ +public interface StorageManagementClient { + /** + * Gets Service host. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + HttpPipeline getHttpPipeline(); + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + Duration getDefaultPollInterval(); + + /** + * Gets the ResourceProvidersClient object to access its operations. + * + * @return the ResourceProvidersClient object. + */ + ResourceProvidersClient getResourceProviders(); +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/models/PrivateEndpointConnectionProperties.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/models/PrivateEndpointConnectionProperties.java new file mode 100644 index 0000000000000..44d8f4f384207 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/models/PrivateEndpointConnectionProperties.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.fluent.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.storage.models.PrivateEndpoint; +import com.azure.resourcemanager.storage.models.PrivateEndpointConnectionProvisioningState; +import com.azure.resourcemanager.storage.models.PrivateLinkServiceConnectionState; +import java.io.IOException; + +/** + * Properties of the PrivateEndpointConnectProperties. + */ +@Immutable +public final class PrivateEndpointConnectionProperties + implements JsonSerializable { + /* + * The resource of private end point. + */ + private PrivateEndpoint privateEndpoint; + + /* + * A collection of information about the state of the connection between service consumer and provider. + */ + private PrivateLinkServiceConnectionState privateLinkServiceConnectionState; + + /* + * The provisioning state of the private endpoint connection resource. + */ + private PrivateEndpointConnectionProvisioningState provisioningState; + + /** + * Creates an instance of PrivateEndpointConnectionProperties class. + */ + private PrivateEndpointConnectionProperties() { + } + + /** + * Get the privateEndpoint property: The resource of private end point. + * + * @return the privateEndpoint value. + */ + public PrivateEndpoint privateEndpoint() { + return this.privateEndpoint; + } + + /** + * Get the privateLinkServiceConnectionState property: A collection of information about the state of the connection + * between service consumer and provider. + * + * @return the privateLinkServiceConnectionState value. + */ + public PrivateLinkServiceConnectionState privateLinkServiceConnectionState() { + return this.privateLinkServiceConnectionState; + } + + /** + * Get the provisioningState property: The provisioning state of the private endpoint connection resource. + * + * @return the provisioningState value. + */ + public PrivateEndpointConnectionProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (privateEndpoint() != null) { + privateEndpoint().validate(); + } + if (privateLinkServiceConnectionState() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property privateLinkServiceConnectionState in model PrivateEndpointConnectionProperties")); + } else { + privateLinkServiceConnectionState().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(PrivateEndpointConnectionProperties.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("privateLinkServiceConnectionState", this.privateLinkServiceConnectionState); + jsonWriter.writeJsonField("privateEndpoint", this.privateEndpoint); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PrivateEndpointConnectionProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PrivateEndpointConnectionProperties if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the PrivateEndpointConnectionProperties. + */ + public static PrivateEndpointConnectionProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PrivateEndpointConnectionProperties deserializedPrivateEndpointConnectionProperties + = new PrivateEndpointConnectionProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("privateLinkServiceConnectionState".equals(fieldName)) { + deserializedPrivateEndpointConnectionProperties.privateLinkServiceConnectionState + = PrivateLinkServiceConnectionState.fromJson(reader); + } else if ("privateEndpoint".equals(fieldName)) { + deserializedPrivateEndpointConnectionProperties.privateEndpoint = PrivateEndpoint.fromJson(reader); + } else if ("provisioningState".equals(fieldName)) { + deserializedPrivateEndpointConnectionProperties.provisioningState + = PrivateEndpointConnectionProvisioningState.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedPrivateEndpointConnectionProperties; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/models/StorageAccountInner.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/models/StorageAccountInner.java new file mode 100644 index 0000000000000..0c89cb67ec271 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/models/StorageAccountInner.java @@ -0,0 +1,1158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.storage.models.AccessTier; +import com.azure.resourcemanager.storage.models.AccountStatus; +import com.azure.resourcemanager.storage.models.AllowedCopyScope; +import com.azure.resourcemanager.storage.models.AzureFilesIdentityBasedAuthentication; +import com.azure.resourcemanager.storage.models.BlobRestoreStatus; +import com.azure.resourcemanager.storage.models.CustomDomain; +import com.azure.resourcemanager.storage.models.DnsEndpointType; +import com.azure.resourcemanager.storage.models.DualStackEndpointPreference; +import com.azure.resourcemanager.storage.models.Encryption; +import com.azure.resourcemanager.storage.models.Endpoints; +import com.azure.resourcemanager.storage.models.ExtendedLocation; +import com.azure.resourcemanager.storage.models.GeoPriorityReplicationStatus; +import com.azure.resourcemanager.storage.models.GeoReplicationStats; +import com.azure.resourcemanager.storage.models.Identity; +import com.azure.resourcemanager.storage.models.ImmutableStorageAccount; +import com.azure.resourcemanager.storage.models.KeyCreationTime; +import com.azure.resourcemanager.storage.models.KeyPolicy; +import com.azure.resourcemanager.storage.models.Kind; +import com.azure.resourcemanager.storage.models.LargeFileSharesState; +import com.azure.resourcemanager.storage.models.MinimumTlsVersion; +import com.azure.resourcemanager.storage.models.NetworkRuleSet; +import com.azure.resourcemanager.storage.models.Placement; +import com.azure.resourcemanager.storage.models.PrivateEndpointConnection; +import com.azure.resourcemanager.storage.models.ProvisioningState; +import com.azure.resourcemanager.storage.models.PublicNetworkAccess; +import com.azure.resourcemanager.storage.models.RoutingPreference; +import com.azure.resourcemanager.storage.models.SasPolicy; +import com.azure.resourcemanager.storage.models.Sku; +import com.azure.resourcemanager.storage.models.StorageAccountSharedKeyAccessProperties; +import com.azure.resourcemanager.storage.models.StorageAccountSkuConversionStatus; +import com.azure.resourcemanager.storage.models.StorageDataCollaborationPolicyProperties; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.List; +import java.util.Map; + +/** + * The storage account. + */ +@Fluent +public final class StorageAccountInner extends Resource { + /* + * Properties of the storage account. + */ + private StorageAccountProperties innerProperties; + + /* + * Gets the SKU. + */ + private Sku sku; + + /* + * Gets the Kind. + */ + private Kind kind; + + /* + * The identity of the resource. + */ + private Identity identity; + + /* + * The extendedLocation of the resource. + */ + private ExtendedLocation extendedLocation; + + /* + * The availability zones. + */ + private List zones; + + /* + * Optional. Gets or sets the zonal placement details for the storage account. + */ + private Placement placement; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of StorageAccountInner class. + */ + public StorageAccountInner() { + } + + /** + * Get the innerProperties property: Properties of the storage account. + * + * @return the innerProperties value. + */ + private StorageAccountProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the sku property: Gets the SKU. + * + * @return the sku value. + */ + public Sku sku() { + return this.sku; + } + + /** + * Get the kind property: Gets the Kind. + * + * @return the kind value. + */ + public Kind kind() { + return this.kind; + } + + /** + * Get the identity property: The identity of the resource. + * + * @return the identity value. + */ + public Identity identity() { + return this.identity; + } + + /** + * Set the identity property: The identity of the resource. + * + * @param identity the identity value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withIdentity(Identity identity) { + this.identity = identity; + return this; + } + + /** + * Get the extendedLocation property: The extendedLocation of the resource. + * + * @return the extendedLocation value. + */ + public ExtendedLocation extendedLocation() { + return this.extendedLocation; + } + + /** + * Set the extendedLocation property: The extendedLocation of the resource. + * + * @param extendedLocation the extendedLocation value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withExtendedLocation(ExtendedLocation extendedLocation) { + this.extendedLocation = extendedLocation; + return this; + } + + /** + * Get the zones property: The availability zones. + * + * @return the zones value. + */ + public List zones() { + return this.zones; + } + + /** + * Set the zones property: The availability zones. + * + * @param zones the zones value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withZones(List zones) { + this.zones = zones; + return this; + } + + /** + * Get the placement property: Optional. Gets or sets the zonal placement details for the storage account. + * + * @return the placement value. + */ + public Placement placement() { + return this.placement; + } + + /** + * Set the placement property: Optional. Gets or sets the zonal placement details for the storage account. + * + * @param placement the placement value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withPlacement(Placement placement) { + this.placement = placement; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Override + public StorageAccountInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public StorageAccountInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Get the provisioningState property: Gets the status of the storage account at the time the operation was called. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.innerProperties() == null ? null : this.innerProperties().provisioningState(); + } + + /** + * Get the primaryEndpoints property: Gets the URLs that are used to perform a retrieval of a public blob, queue, or + * table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob endpoint. + * + * @return the primaryEndpoints value. + */ + public Endpoints primaryEndpoints() { + return this.innerProperties() == null ? null : this.innerProperties().primaryEndpoints(); + } + + /** + * Get the primaryLocation property: Gets the location of the primary data center for the storage account. + * + * @return the primaryLocation value. + */ + public String primaryLocation() { + return this.innerProperties() == null ? null : this.innerProperties().primaryLocation(); + } + + /** + * Get the statusOfPrimary property: Gets the status indicating whether the primary location of the storage account + * is available or unavailable. + * + * @return the statusOfPrimary value. + */ + public AccountStatus statusOfPrimary() { + return this.innerProperties() == null ? null : this.innerProperties().statusOfPrimary(); + } + + /** + * Get the lastGeoFailoverTime property: Gets the timestamp of the most recent instance of a failover to the + * secondary location. Only the most recent timestamp is retained. This element is not returned if there has never + * been a failover instance. Only available if the accountType is Standard_GRS or Standard_RAGRS. + * + * @return the lastGeoFailoverTime value. + */ + public OffsetDateTime lastGeoFailoverTime() { + return this.innerProperties() == null ? null : this.innerProperties().lastGeoFailoverTime(); + } + + /** + * Get the secondaryLocation property: Gets the location of the geo-replicated secondary for the storage account. + * Only available if the accountType is Standard_GRS or Standard_RAGRS. + * + * @return the secondaryLocation value. + */ + public String secondaryLocation() { + return this.innerProperties() == null ? null : this.innerProperties().secondaryLocation(); + } + + /** + * Get the statusOfSecondary property: Gets the status indicating whether the secondary location of the storage + * account is available or unavailable. Only available if the SKU name is Standard_GRS or Standard_RAGRS. + * + * @return the statusOfSecondary value. + */ + public AccountStatus statusOfSecondary() { + return this.innerProperties() == null ? null : this.innerProperties().statusOfSecondary(); + } + + /** + * Get the creationTime property: Gets the creation date and time of the storage account in UTC. + * + * @return the creationTime value. + */ + public OffsetDateTime creationTime() { + return this.innerProperties() == null ? null : this.innerProperties().creationTime(); + } + + /** + * Get the customDomain property: Gets the custom domain the user assigned to this storage account. + * + * @return the customDomain value. + */ + public CustomDomain customDomain() { + return this.innerProperties() == null ? null : this.innerProperties().customDomain(); + } + + /** + * Get the sasPolicy property: SasPolicy assigned to the storage account. + * + * @return the sasPolicy value. + */ + public SasPolicy sasPolicy() { + return this.innerProperties() == null ? null : this.innerProperties().sasPolicy(); + } + + /** + * Get the keyPolicy property: KeyPolicy assigned to the storage account. + * + * @return the keyPolicy value. + */ + public KeyPolicy keyPolicy() { + return this.innerProperties() == null ? null : this.innerProperties().keyPolicy(); + } + + /** + * Get the keyCreationTime property: Storage account keys creation time. + * + * @return the keyCreationTime value. + */ + public KeyCreationTime keyCreationTime() { + return this.innerProperties() == null ? null : this.innerProperties().keyCreationTime(); + } + + /** + * Get the secondaryEndpoints property: Gets the URLs that are used to perform a retrieval of a public blob, queue, + * or table object from the secondary location of the storage account. Only available if the SKU name is + * Standard_RAGRS. + * + * @return the secondaryEndpoints value. + */ + public Endpoints secondaryEndpoints() { + return this.innerProperties() == null ? null : this.innerProperties().secondaryEndpoints(); + } + + /** + * Get the encryption property: Encryption settings to be used for server-side encryption for the storage account. + * + * @return the encryption value. + */ + public Encryption encryption() { + return this.innerProperties() == null ? null : this.innerProperties().encryption(); + } + + /** + * Get the accessTier property: Required for storage accounts where kind = BlobStorage. The access tier is used for + * billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it + * cannot be changed for the premium block blobs storage account type. + * + * @return the accessTier value. + */ + public AccessTier accessTier() { + return this.innerProperties() == null ? null : this.innerProperties().accessTier(); + } + + /** + * Get the azureFilesIdentityBasedAuthentication property: Provides the identity based authentication settings for + * Azure Files. + * + * @return the azureFilesIdentityBasedAuthentication value. + */ + public AzureFilesIdentityBasedAuthentication azureFilesIdentityBasedAuthentication() { + return this.innerProperties() == null ? null : this.innerProperties().azureFilesIdentityBasedAuthentication(); + } + + /** + * Set the azureFilesIdentityBasedAuthentication property: Provides the identity based authentication settings for + * Azure Files. + * + * @param azureFilesIdentityBasedAuthentication the azureFilesIdentityBasedAuthentication value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withAzureFilesIdentityBasedAuthentication( + AzureFilesIdentityBasedAuthentication azureFilesIdentityBasedAuthentication) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withAzureFilesIdentityBasedAuthentication(azureFilesIdentityBasedAuthentication); + return this; + } + + /** + * Get the enableHttpsTrafficOnly property: Allows https traffic only to storage service if sets to true. + * + * @return the enableHttpsTrafficOnly value. + */ + public Boolean enableHttpsTrafficOnly() { + return this.innerProperties() == null ? null : this.innerProperties().enableHttpsTrafficOnly(); + } + + /** + * Set the enableHttpsTrafficOnly property: Allows https traffic only to storage service if sets to true. + * + * @param enableHttpsTrafficOnly the enableHttpsTrafficOnly value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withEnableHttpsTrafficOnly(Boolean enableHttpsTrafficOnly) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withEnableHttpsTrafficOnly(enableHttpsTrafficOnly); + return this; + } + + /** + * Get the networkRuleSet property: Network rule set. + * + * @return the networkRuleSet value. + */ + public NetworkRuleSet networkRuleSet() { + return this.innerProperties() == null ? null : this.innerProperties().networkRuleSet(); + } + + /** + * Get the isSftpEnabled property: Enables Secure File Transfer Protocol, if set to true. + * + * @return the isSftpEnabled value. + */ + public Boolean isSftpEnabled() { + return this.innerProperties() == null ? null : this.innerProperties().isSftpEnabled(); + } + + /** + * Set the isSftpEnabled property: Enables Secure File Transfer Protocol, if set to true. + * + * @param isSftpEnabled the isSftpEnabled value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withIsSftpEnabled(Boolean isSftpEnabled) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withIsSftpEnabled(isSftpEnabled); + return this; + } + + /** + * Get the isLocalUserEnabled property: Enables local users feature, if set to true. + * + * @return the isLocalUserEnabled value. + */ + public Boolean isLocalUserEnabled() { + return this.innerProperties() == null ? null : this.innerProperties().isLocalUserEnabled(); + } + + /** + * Set the isLocalUserEnabled property: Enables local users feature, if set to true. + * + * @param isLocalUserEnabled the isLocalUserEnabled value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withIsLocalUserEnabled(Boolean isLocalUserEnabled) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withIsLocalUserEnabled(isLocalUserEnabled); + return this; + } + + /** + * Get the enableExtendedGroups property: Enables extended group support with local users feature, if set to true. + * + * @return the enableExtendedGroups value. + */ + public Boolean enableExtendedGroups() { + return this.innerProperties() == null ? null : this.innerProperties().enableExtendedGroups(); + } + + /** + * Set the enableExtendedGroups property: Enables extended group support with local users feature, if set to true. + * + * @param enableExtendedGroups the enableExtendedGroups value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withEnableExtendedGroups(Boolean enableExtendedGroups) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withEnableExtendedGroups(enableExtendedGroups); + return this; + } + + /** + * Get the isHnsEnabled property: Account HierarchicalNamespace enabled if sets to true. + * + * @return the isHnsEnabled value. + */ + public Boolean isHnsEnabled() { + return this.innerProperties() == null ? null : this.innerProperties().isHnsEnabled(); + } + + /** + * Set the isHnsEnabled property: Account HierarchicalNamespace enabled if sets to true. + * + * @param isHnsEnabled the isHnsEnabled value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withIsHnsEnabled(Boolean isHnsEnabled) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withIsHnsEnabled(isHnsEnabled); + return this; + } + + /** + * Get the geoReplicationStats property: Geo Replication Stats. + * + * @return the geoReplicationStats value. + */ + public GeoReplicationStats geoReplicationStats() { + return this.innerProperties() == null ? null : this.innerProperties().geoReplicationStats(); + } + + /** + * Get the failoverInProgress property: If the failover is in progress, the value will be true, otherwise, it will + * be null. + * + * @return the failoverInProgress value. + */ + public Boolean failoverInProgress() { + return this.innerProperties() == null ? null : this.innerProperties().failoverInProgress(); + } + + /** + * Get the largeFileSharesState property: Allow large file shares if sets to Enabled. It cannot be disabled once it + * is enabled. + * + * @return the largeFileSharesState value. + */ + public LargeFileSharesState largeFileSharesState() { + return this.innerProperties() == null ? null : this.innerProperties().largeFileSharesState(); + } + + /** + * Set the largeFileSharesState property: Allow large file shares if sets to Enabled. It cannot be disabled once it + * is enabled. + * + * @param largeFileSharesState the largeFileSharesState value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withLargeFileSharesState(LargeFileSharesState largeFileSharesState) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withLargeFileSharesState(largeFileSharesState); + return this; + } + + /** + * Get the privateEndpointConnections property: List of private endpoint connection associated with the specified + * storage account. + * + * @return the privateEndpointConnections value. + */ + public List privateEndpointConnections() { + return this.innerProperties() == null ? null : this.innerProperties().privateEndpointConnections(); + } + + /** + * Get the routingPreference property: Maintains information about the network routing choice opted by the user for + * data transfer. + * + * @return the routingPreference value. + */ + public RoutingPreference routingPreference() { + return this.innerProperties() == null ? null : this.innerProperties().routingPreference(); + } + + /** + * Set the routingPreference property: Maintains information about the network routing choice opted by the user for + * data transfer. + * + * @param routingPreference the routingPreference value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withRoutingPreference(RoutingPreference routingPreference) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withRoutingPreference(routingPreference); + return this; + } + + /** + * Get the dualStackEndpointPreference property: Maintains information about the Internet protocol opted by the + * user. + * + * @return the dualStackEndpointPreference value. + */ + public DualStackEndpointPreference dualStackEndpointPreference() { + return this.innerProperties() == null ? null : this.innerProperties().dualStackEndpointPreference(); + } + + /** + * Set the dualStackEndpointPreference property: Maintains information about the Internet protocol opted by the + * user. + * + * @param dualStackEndpointPreference the dualStackEndpointPreference value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner + withDualStackEndpointPreference(DualStackEndpointPreference dualStackEndpointPreference) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withDualStackEndpointPreference(dualStackEndpointPreference); + return this; + } + + /** + * Get the blobRestoreStatus property: Blob restore status. + * + * @return the blobRestoreStatus value. + */ + public BlobRestoreStatus blobRestoreStatus() { + return this.innerProperties() == null ? null : this.innerProperties().blobRestoreStatus(); + } + + /** + * Get the allowBlobPublicAccess property: Allow or disallow public access to all blobs or containers in the storage + * account. The default interpretation is false for this property. + * + * @return the allowBlobPublicAccess value. + */ + public Boolean allowBlobPublicAccess() { + return this.innerProperties() == null ? null : this.innerProperties().allowBlobPublicAccess(); + } + + /** + * Set the allowBlobPublicAccess property: Allow or disallow public access to all blobs or containers in the storage + * account. The default interpretation is false for this property. + * + * @param allowBlobPublicAccess the allowBlobPublicAccess value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withAllowBlobPublicAccess(Boolean allowBlobPublicAccess) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withAllowBlobPublicAccess(allowBlobPublicAccess); + return this; + } + + /** + * Get the minimumTlsVersion property: Set the minimum TLS version to be permitted on requests to storage. The + * default interpretation is TLS 1.0 for this property. Minimum TLS version 1.3 version is not supported. + * + * @return the minimumTlsVersion value. + */ + public MinimumTlsVersion minimumTlsVersion() { + return this.innerProperties() == null ? null : this.innerProperties().minimumTlsVersion(); + } + + /** + * Set the minimumTlsVersion property: Set the minimum TLS version to be permitted on requests to storage. The + * default interpretation is TLS 1.0 for this property. Minimum TLS version 1.3 version is not supported. + * + * @param minimumTlsVersion the minimumTlsVersion value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withMinimumTlsVersion(MinimumTlsVersion minimumTlsVersion) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withMinimumTlsVersion(minimumTlsVersion); + return this; + } + + /** + * Get the allowSharedKeyAccess property: Indicates whether the storage account permits requests to be authorized + * with the account access key via Shared Key. If false, then all requests, including shared access signatures, must + * be authorized with Azure Active Directory (Azure AD). The default value is null, which is equivalent to true. + * + * @return the allowSharedKeyAccess value. + */ + public Boolean allowSharedKeyAccess() { + return this.innerProperties() == null ? null : this.innerProperties().allowSharedKeyAccess(); + } + + /** + * Set the allowSharedKeyAccess property: Indicates whether the storage account permits requests to be authorized + * with the account access key via Shared Key. If false, then all requests, including shared access signatures, must + * be authorized with Azure Active Directory (Azure AD). The default value is null, which is equivalent to true. + * + * @param allowSharedKeyAccess the allowSharedKeyAccess value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withAllowSharedKeyAccess(Boolean allowSharedKeyAccess) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withAllowSharedKeyAccess(allowSharedKeyAccess); + return this; + } + + /** + * Get the enableNfsV3 property: NFS 3.0 protocol support enabled if set to true. + * + * @return the enableNfsV3 value. + */ + public Boolean enableNfsV3() { + return this.innerProperties() == null ? null : this.innerProperties().enableNfsV3(); + } + + /** + * Set the enableNfsV3 property: NFS 3.0 protocol support enabled if set to true. + * + * @param enableNfsV3 the enableNfsV3 value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withEnableNfsV3(Boolean enableNfsV3) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withEnableNfsV3(enableNfsV3); + return this; + } + + /** + * Get the allowCrossTenantReplication property: Allow or disallow cross AAD tenant object replication. Set this + * property to true for new or existing accounts only if object replication policies will involve storage accounts + * in different AAD tenants. The default interpretation is false for new accounts to follow best security practices + * by default. + * + * @return the allowCrossTenantReplication value. + */ + public Boolean allowCrossTenantReplication() { + return this.innerProperties() == null ? null : this.innerProperties().allowCrossTenantReplication(); + } + + /** + * Set the allowCrossTenantReplication property: Allow or disallow cross AAD tenant object replication. Set this + * property to true for new or existing accounts only if object replication policies will involve storage accounts + * in different AAD tenants. The default interpretation is false for new accounts to follow best security practices + * by default. + * + * @param allowCrossTenantReplication the allowCrossTenantReplication value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withAllowCrossTenantReplication(Boolean allowCrossTenantReplication) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withAllowCrossTenantReplication(allowCrossTenantReplication); + return this; + } + + /** + * Get the defaultToOAuthAuthentication property: A boolean flag which indicates whether the default authentication + * is OAuth or not. The default interpretation is false for this property. + * + * @return the defaultToOAuthAuthentication value. + */ + public Boolean defaultToOAuthAuthentication() { + return this.innerProperties() == null ? null : this.innerProperties().defaultToOAuthAuthentication(); + } + + /** + * Set the defaultToOAuthAuthentication property: A boolean flag which indicates whether the default authentication + * is OAuth or not. The default interpretation is false for this property. + * + * @param defaultToOAuthAuthentication the defaultToOAuthAuthentication value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withDefaultToOAuthAuthentication(Boolean defaultToOAuthAuthentication) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withDefaultToOAuthAuthentication(defaultToOAuthAuthentication); + return this; + } + + /** + * Get the publicNetworkAccess property: Allow, disallow, or let Network Security Perimeter configuration to + * evaluate public network access to Storage Account. + * + * @return the publicNetworkAccess value. + */ + public PublicNetworkAccess publicNetworkAccess() { + return this.innerProperties() == null ? null : this.innerProperties().publicNetworkAccess(); + } + + /** + * Set the publicNetworkAccess property: Allow, disallow, or let Network Security Perimeter configuration to + * evaluate public network access to Storage Account. + * + * @param publicNetworkAccess the publicNetworkAccess value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withPublicNetworkAccess(PublicNetworkAccess publicNetworkAccess) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withPublicNetworkAccess(publicNetworkAccess); + return this; + } + + /** + * Get the immutableStorageWithVersioning property: The property is immutable and can only be set to true at the + * account creation time. When set to true, it enables object level immutability for all the containers in the + * account by default. + * + * @return the immutableStorageWithVersioning value. + */ + public ImmutableStorageAccount immutableStorageWithVersioning() { + return this.innerProperties() == null ? null : this.innerProperties().immutableStorageWithVersioning(); + } + + /** + * Set the immutableStorageWithVersioning property: The property is immutable and can only be set to true at the + * account creation time. When set to true, it enables object level immutability for all the containers in the + * account by default. + * + * @param immutableStorageWithVersioning the immutableStorageWithVersioning value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner + withImmutableStorageWithVersioning(ImmutableStorageAccount immutableStorageWithVersioning) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withImmutableStorageWithVersioning(immutableStorageWithVersioning); + return this; + } + + /** + * Get the allowedCopyScope property: Restrict copy to and from Storage Accounts within an AAD tenant or with + * Private Links to the same VNet. + * + * @return the allowedCopyScope value. + */ + public AllowedCopyScope allowedCopyScope() { + return this.innerProperties() == null ? null : this.innerProperties().allowedCopyScope(); + } + + /** + * Set the allowedCopyScope property: Restrict copy to and from Storage Accounts within an AAD tenant or with + * Private Links to the same VNet. + * + * @param allowedCopyScope the allowedCopyScope value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withAllowedCopyScope(AllowedCopyScope allowedCopyScope) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withAllowedCopyScope(allowedCopyScope); + return this; + } + + /** + * Get the storageAccountSkuConversionStatus property: This property is readOnly and is set by server during + * asynchronous storage account sku conversion operations. + * + * @return the storageAccountSkuConversionStatus value. + */ + public StorageAccountSkuConversionStatus storageAccountSkuConversionStatus() { + return this.innerProperties() == null ? null : this.innerProperties().storageAccountSkuConversionStatus(); + } + + /** + * Set the storageAccountSkuConversionStatus property: This property is readOnly and is set by server during + * asynchronous storage account sku conversion operations. + * + * @param storageAccountSkuConversionStatus the storageAccountSkuConversionStatus value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner + withStorageAccountSkuConversionStatus(StorageAccountSkuConversionStatus storageAccountSkuConversionStatus) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withStorageAccountSkuConversionStatus(storageAccountSkuConversionStatus); + return this; + } + + /** + * Get the dnsEndpointType property: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create + * a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint + * URL will have an alphanumeric DNS Zone identifier. + * + * @return the dnsEndpointType value. + */ + public DnsEndpointType dnsEndpointType() { + return this.innerProperties() == null ? null : this.innerProperties().dnsEndpointType(); + } + + /** + * Set the dnsEndpointType property: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create + * a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint + * URL will have an alphanumeric DNS Zone identifier. + * + * @param dnsEndpointType the dnsEndpointType value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withDnsEndpointType(DnsEndpointType dnsEndpointType) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withDnsEndpointType(dnsEndpointType); + return this; + } + + /** + * Get the isSkuConversionBlocked property: This property will be set to true or false on an event of ongoing + * migration. Default value is null. + * + * @return the isSkuConversionBlocked value. + */ + public Boolean isSkuConversionBlocked() { + return this.innerProperties() == null ? null : this.innerProperties().isSkuConversionBlocked(); + } + + /** + * Get the accountMigrationInProgress property: If customer initiated account migration is in progress, the value + * will be true else it will be null. + * + * @return the accountMigrationInProgress value. + */ + public Boolean accountMigrationInProgress() { + return this.innerProperties() == null ? null : this.innerProperties().accountMigrationInProgress(); + } + + /** + * Get the geoPriorityReplicationStatus property: Status indicating whether Geo Priority Replication is enabled for + * the account. + * + * @return the geoPriorityReplicationStatus value. + */ + public GeoPriorityReplicationStatus geoPriorityReplicationStatus() { + return this.innerProperties() == null ? null : this.innerProperties().geoPriorityReplicationStatus(); + } + + /** + * Set the geoPriorityReplicationStatus property: Status indicating whether Geo Priority Replication is enabled for + * the account. + * + * @param geoPriorityReplicationStatus the geoPriorityReplicationStatus value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner + withGeoPriorityReplicationStatus(GeoPriorityReplicationStatus geoPriorityReplicationStatus) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withGeoPriorityReplicationStatus(geoPriorityReplicationStatus); + return this; + } + + /** + * Get the allowSharedKeyAccessForServices property: Indicate shared key access properties at service level. + * + * @return the allowSharedKeyAccessForServices value. + */ + public StorageAccountSharedKeyAccessProperties allowSharedKeyAccessForServices() { + return this.innerProperties() == null ? null : this.innerProperties().allowSharedKeyAccessForServices(); + } + + /** + * Set the allowSharedKeyAccessForServices property: Indicate shared key access properties at service level. + * + * @param allowSharedKeyAccessForServices the allowSharedKeyAccessForServices value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner + withAllowSharedKeyAccessForServices(StorageAccountSharedKeyAccessProperties allowSharedKeyAccessForServices) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withAllowSharedKeyAccessForServices(allowSharedKeyAccessForServices); + return this; + } + + /** + * Get the dataCollaborationPolicyProperties property: Data Collaboration policy for the storage account. + * + * @return the dataCollaborationPolicyProperties value. + */ + public StorageDataCollaborationPolicyProperties dataCollaborationPolicyProperties() { + return this.innerProperties() == null ? null : this.innerProperties().dataCollaborationPolicyProperties(); + } + + /** + * Set the dataCollaborationPolicyProperties property: Data Collaboration policy for the storage account. + * + * @param dataCollaborationPolicyProperties the dataCollaborationPolicyProperties value to set. + * @return the StorageAccountInner object itself. + */ + public StorageAccountInner withDataCollaborationPolicyProperties( + StorageDataCollaborationPolicyProperties dataCollaborationPolicyProperties) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountProperties(); + } + this.innerProperties().withDataCollaborationPolicyProperties(dataCollaborationPolicyProperties); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (innerProperties() != null) { + innerProperties().validate(); + } + if (sku() != null) { + sku().validate(); + } + if (identity() != null) { + identity().validate(); + } + if (extendedLocation() != null) { + extendedLocation().validate(); + } + if (placement() != null) { + placement().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("location", location()); + jsonWriter.writeMapField("tags", tags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("properties", this.innerProperties); + jsonWriter.writeJsonField("identity", this.identity); + jsonWriter.writeJsonField("extendedLocation", this.extendedLocation); + jsonWriter.writeArrayField("zones", this.zones, (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("placement", this.placement); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StorageAccountInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StorageAccountInner if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the StorageAccountInner. + */ + public static StorageAccountInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StorageAccountInner deserializedStorageAccountInner = new StorageAccountInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedStorageAccountInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedStorageAccountInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedStorageAccountInner.type = reader.getString(); + } else if ("location".equals(fieldName)) { + deserializedStorageAccountInner.withLocation(reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedStorageAccountInner.withTags(tags); + } else if ("properties".equals(fieldName)) { + deserializedStorageAccountInner.innerProperties = StorageAccountProperties.fromJson(reader); + } else if ("sku".equals(fieldName)) { + deserializedStorageAccountInner.sku = Sku.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedStorageAccountInner.kind = Kind.fromString(reader.getString()); + } else if ("identity".equals(fieldName)) { + deserializedStorageAccountInner.identity = Identity.fromJson(reader); + } else if ("extendedLocation".equals(fieldName)) { + deserializedStorageAccountInner.extendedLocation = ExtendedLocation.fromJson(reader); + } else if ("zones".equals(fieldName)) { + List zones = reader.readArray(reader1 -> reader1.getString()); + deserializedStorageAccountInner.zones = zones; + } else if ("placement".equals(fieldName)) { + deserializedStorageAccountInner.placement = Placement.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedStorageAccountInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedStorageAccountInner; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/models/StorageAccountProperties.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/models/StorageAccountProperties.java new file mode 100644 index 0000000000000..c2845d5f7c0cd --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/models/StorageAccountProperties.java @@ -0,0 +1,1260 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.storage.models.AccessTier; +import com.azure.resourcemanager.storage.models.AccountStatus; +import com.azure.resourcemanager.storage.models.AllowedCopyScope; +import com.azure.resourcemanager.storage.models.AzureFilesIdentityBasedAuthentication; +import com.azure.resourcemanager.storage.models.BlobRestoreStatus; +import com.azure.resourcemanager.storage.models.CustomDomain; +import com.azure.resourcemanager.storage.models.DnsEndpointType; +import com.azure.resourcemanager.storage.models.DualStackEndpointPreference; +import com.azure.resourcemanager.storage.models.Encryption; +import com.azure.resourcemanager.storage.models.Endpoints; +import com.azure.resourcemanager.storage.models.GeoPriorityReplicationStatus; +import com.azure.resourcemanager.storage.models.GeoReplicationStats; +import com.azure.resourcemanager.storage.models.ImmutableStorageAccount; +import com.azure.resourcemanager.storage.models.KeyCreationTime; +import com.azure.resourcemanager.storage.models.KeyPolicy; +import com.azure.resourcemanager.storage.models.LargeFileSharesState; +import com.azure.resourcemanager.storage.models.MinimumTlsVersion; +import com.azure.resourcemanager.storage.models.NetworkRuleSet; +import com.azure.resourcemanager.storage.models.PrivateEndpointConnection; +import com.azure.resourcemanager.storage.models.ProvisioningState; +import com.azure.resourcemanager.storage.models.PublicNetworkAccess; +import com.azure.resourcemanager.storage.models.RoutingPreference; +import com.azure.resourcemanager.storage.models.SasPolicy; +import com.azure.resourcemanager.storage.models.StorageAccountSharedKeyAccessProperties; +import com.azure.resourcemanager.storage.models.StorageAccountSkuConversionStatus; +import com.azure.resourcemanager.storage.models.StorageDataCollaborationPolicyProperties; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.List; + +/** + * Properties of the storage account. + */ +@Fluent +public final class StorageAccountProperties implements JsonSerializable { + /* + * Gets the status of the storage account at the time the operation was called. + */ + private ProvisioningState provisioningState; + + /* + * Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that + * Standard_ZRS and Premium_LRS accounts only return the blob endpoint. + */ + private Endpoints primaryEndpoints; + + /* + * Gets the location of the primary data center for the storage account. + */ + private String primaryLocation; + + /* + * Gets the status indicating whether the primary location of the storage account is available or unavailable. + */ + private AccountStatus statusOfPrimary; + + /* + * Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent + * timestamp is retained. This element is not returned if there has never been a failover instance. Only available + * if the accountType is Standard_GRS or Standard_RAGRS. + */ + private OffsetDateTime lastGeoFailoverTime; + + /* + * Gets the location of the geo-replicated secondary for the storage account. Only available if the accountType is + * Standard_GRS or Standard_RAGRS. + */ + private String secondaryLocation; + + /* + * Gets the status indicating whether the secondary location of the storage account is available or unavailable. + * Only available if the SKU name is Standard_GRS or Standard_RAGRS. + */ + private AccountStatus statusOfSecondary; + + /* + * Gets the creation date and time of the storage account in UTC. + */ + private OffsetDateTime creationTime; + + /* + * Gets the custom domain the user assigned to this storage account. + */ + private CustomDomain customDomain; + + /* + * SasPolicy assigned to the storage account. + */ + private SasPolicy sasPolicy; + + /* + * KeyPolicy assigned to the storage account. + */ + private KeyPolicy keyPolicy; + + /* + * Storage account keys creation time. + */ + private KeyCreationTime keyCreationTime; + + /* + * Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object from the secondary + * location of the storage account. Only available if the SKU name is Standard_RAGRS. + */ + private Endpoints secondaryEndpoints; + + /* + * Encryption settings to be used for server-side encryption for the storage account. + */ + private Encryption encryption; + + /* + * Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access + * tier is the default value for premium block blobs storage account type and it cannot be changed for the premium + * block blobs storage account type. + */ + private AccessTier accessTier; + + /* + * Provides the identity based authentication settings for Azure Files. + */ + private AzureFilesIdentityBasedAuthentication azureFilesIdentityBasedAuthentication; + + /* + * Allows https traffic only to storage service if sets to true. + */ + private Boolean enableHttpsTrafficOnly; + + /* + * Network rule set + */ + private NetworkRuleSet networkRuleSet; + + /* + * Enables Secure File Transfer Protocol, if set to true + */ + private Boolean isSftpEnabled; + + /* + * Enables local users feature, if set to true + */ + private Boolean isLocalUserEnabled; + + /* + * Enables extended group support with local users feature, if set to true + */ + private Boolean enableExtendedGroups; + + /* + * Account HierarchicalNamespace enabled if sets to true. + */ + private Boolean isHnsEnabled; + + /* + * Geo Replication Stats + */ + private GeoReplicationStats geoReplicationStats; + + /* + * If the failover is in progress, the value will be true, otherwise, it will be null. + */ + private Boolean failoverInProgress; + + /* + * Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. + */ + private LargeFileSharesState largeFileSharesState; + + /* + * List of private endpoint connection associated with the specified storage account + */ + private List privateEndpointConnections; + + /* + * Maintains information about the network routing choice opted by the user for data transfer + */ + private RoutingPreference routingPreference; + + /* + * Maintains information about the Internet protocol opted by the user. + */ + private DualStackEndpointPreference dualStackEndpointPreference; + + /* + * Blob restore status + */ + private BlobRestoreStatus blobRestoreStatus; + + /* + * Allow or disallow public access to all blobs or containers in the storage account. The default interpretation is + * false for this property. + */ + private Boolean allowBlobPublicAccess; + + /* + * Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for + * this property. Minimum TLS version 1.3 version is not supported. + */ + private MinimumTlsVersion minimumTlsVersion; + + /* + * Indicates whether the storage account permits requests to be authorized with the account access key via Shared + * Key. If false, then all requests, including shared access signatures, must be authorized with Azure Active + * Directory (Azure AD). The default value is null, which is equivalent to true. + */ + private Boolean allowSharedKeyAccess; + + /* + * NFS 3.0 protocol support enabled if set to true. + */ + private Boolean enableNfsV3; + + /* + * Allow or disallow cross AAD tenant object replication. Set this property to true for new or existing accounts + * only if object replication policies will involve storage accounts in different AAD tenants. The default + * interpretation is false for new accounts to follow best security practices by default. + */ + private Boolean allowCrossTenantReplication; + + /* + * A boolean flag which indicates whether the default authentication is OAuth or not. The default interpretation is + * false for this property. + */ + private Boolean defaultToOAuthAuthentication; + + /* + * Allow, disallow, or let Network Security Perimeter configuration to evaluate public network access to Storage + * Account. + */ + private PublicNetworkAccess publicNetworkAccess; + + /* + * The property is immutable and can only be set to true at the account creation time. When set to true, it enables + * object level immutability for all the containers in the account by default. + */ + private ImmutableStorageAccount immutableStorageWithVersioning; + + /* + * Restrict copy to and from Storage Accounts within an AAD tenant or with Private Links to the same VNet. + */ + private AllowedCopyScope allowedCopyScope; + + /* + * This property is readOnly and is set by server during asynchronous storage account sku conversion operations. + */ + private StorageAccountSkuConversionStatus storageAccountSkuConversionStatus; + + /* + * Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a + * single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric + * DNS Zone identifier. + */ + private DnsEndpointType dnsEndpointType; + + /* + * This property will be set to true or false on an event of ongoing migration. Default value is null. + */ + private Boolean isSkuConversionBlocked; + + /* + * If customer initiated account migration is in progress, the value will be true else it will be null. + */ + private Boolean accountMigrationInProgress; + + /* + * Status indicating whether Geo Priority Replication is enabled for the account. + */ + private GeoPriorityReplicationStatus geoPriorityReplicationStatus; + + /* + * Indicate shared key access properties at service level + */ + private StorageAccountSharedKeyAccessProperties allowSharedKeyAccessForServices; + + /* + * Data Collaboration policy for the storage account. + */ + private StorageDataCollaborationPolicyProperties dataCollaborationPolicyProperties; + + /** + * Creates an instance of StorageAccountProperties class. + */ + public StorageAccountProperties() { + } + + /** + * Get the provisioningState property: Gets the status of the storage account at the time the operation was called. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the primaryEndpoints property: Gets the URLs that are used to perform a retrieval of a public blob, queue, or + * table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob endpoint. + * + * @return the primaryEndpoints value. + */ + public Endpoints primaryEndpoints() { + return this.primaryEndpoints; + } + + /** + * Get the primaryLocation property: Gets the location of the primary data center for the storage account. + * + * @return the primaryLocation value. + */ + public String primaryLocation() { + return this.primaryLocation; + } + + /** + * Get the statusOfPrimary property: Gets the status indicating whether the primary location of the storage account + * is available or unavailable. + * + * @return the statusOfPrimary value. + */ + public AccountStatus statusOfPrimary() { + return this.statusOfPrimary; + } + + /** + * Get the lastGeoFailoverTime property: Gets the timestamp of the most recent instance of a failover to the + * secondary location. Only the most recent timestamp is retained. This element is not returned if there has never + * been a failover instance. Only available if the accountType is Standard_GRS or Standard_RAGRS. + * + * @return the lastGeoFailoverTime value. + */ + public OffsetDateTime lastGeoFailoverTime() { + return this.lastGeoFailoverTime; + } + + /** + * Get the secondaryLocation property: Gets the location of the geo-replicated secondary for the storage account. + * Only available if the accountType is Standard_GRS or Standard_RAGRS. + * + * @return the secondaryLocation value. + */ + public String secondaryLocation() { + return this.secondaryLocation; + } + + /** + * Get the statusOfSecondary property: Gets the status indicating whether the secondary location of the storage + * account is available or unavailable. Only available if the SKU name is Standard_GRS or Standard_RAGRS. + * + * @return the statusOfSecondary value. + */ + public AccountStatus statusOfSecondary() { + return this.statusOfSecondary; + } + + /** + * Get the creationTime property: Gets the creation date and time of the storage account in UTC. + * + * @return the creationTime value. + */ + public OffsetDateTime creationTime() { + return this.creationTime; + } + + /** + * Get the customDomain property: Gets the custom domain the user assigned to this storage account. + * + * @return the customDomain value. + */ + public CustomDomain customDomain() { + return this.customDomain; + } + + /** + * Get the sasPolicy property: SasPolicy assigned to the storage account. + * + * @return the sasPolicy value. + */ + public SasPolicy sasPolicy() { + return this.sasPolicy; + } + + /** + * Get the keyPolicy property: KeyPolicy assigned to the storage account. + * + * @return the keyPolicy value. + */ + public KeyPolicy keyPolicy() { + return this.keyPolicy; + } + + /** + * Get the keyCreationTime property: Storage account keys creation time. + * + * @return the keyCreationTime value. + */ + public KeyCreationTime keyCreationTime() { + return this.keyCreationTime; + } + + /** + * Get the secondaryEndpoints property: Gets the URLs that are used to perform a retrieval of a public blob, queue, + * or table object from the secondary location of the storage account. Only available if the SKU name is + * Standard_RAGRS. + * + * @return the secondaryEndpoints value. + */ + public Endpoints secondaryEndpoints() { + return this.secondaryEndpoints; + } + + /** + * Get the encryption property: Encryption settings to be used for server-side encryption for the storage account. + * + * @return the encryption value. + */ + public Encryption encryption() { + return this.encryption; + } + + /** + * Get the accessTier property: Required for storage accounts where kind = BlobStorage. The access tier is used for + * billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it + * cannot be changed for the premium block blobs storage account type. + * + * @return the accessTier value. + */ + public AccessTier accessTier() { + return this.accessTier; + } + + /** + * Get the azureFilesIdentityBasedAuthentication property: Provides the identity based authentication settings for + * Azure Files. + * + * @return the azureFilesIdentityBasedAuthentication value. + */ + public AzureFilesIdentityBasedAuthentication azureFilesIdentityBasedAuthentication() { + return this.azureFilesIdentityBasedAuthentication; + } + + /** + * Set the azureFilesIdentityBasedAuthentication property: Provides the identity based authentication settings for + * Azure Files. + * + * @param azureFilesIdentityBasedAuthentication the azureFilesIdentityBasedAuthentication value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties withAzureFilesIdentityBasedAuthentication( + AzureFilesIdentityBasedAuthentication azureFilesIdentityBasedAuthentication) { + this.azureFilesIdentityBasedAuthentication = azureFilesIdentityBasedAuthentication; + return this; + } + + /** + * Get the enableHttpsTrafficOnly property: Allows https traffic only to storage service if sets to true. + * + * @return the enableHttpsTrafficOnly value. + */ + public Boolean enableHttpsTrafficOnly() { + return this.enableHttpsTrafficOnly; + } + + /** + * Set the enableHttpsTrafficOnly property: Allows https traffic only to storage service if sets to true. + * + * @param enableHttpsTrafficOnly the enableHttpsTrafficOnly value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties withEnableHttpsTrafficOnly(Boolean enableHttpsTrafficOnly) { + this.enableHttpsTrafficOnly = enableHttpsTrafficOnly; + return this; + } + + /** + * Get the networkRuleSet property: Network rule set. + * + * @return the networkRuleSet value. + */ + public NetworkRuleSet networkRuleSet() { + return this.networkRuleSet; + } + + /** + * Get the isSftpEnabled property: Enables Secure File Transfer Protocol, if set to true. + * + * @return the isSftpEnabled value. + */ + public Boolean isSftpEnabled() { + return this.isSftpEnabled; + } + + /** + * Set the isSftpEnabled property: Enables Secure File Transfer Protocol, if set to true. + * + * @param isSftpEnabled the isSftpEnabled value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties withIsSftpEnabled(Boolean isSftpEnabled) { + this.isSftpEnabled = isSftpEnabled; + return this; + } + + /** + * Get the isLocalUserEnabled property: Enables local users feature, if set to true. + * + * @return the isLocalUserEnabled value. + */ + public Boolean isLocalUserEnabled() { + return this.isLocalUserEnabled; + } + + /** + * Set the isLocalUserEnabled property: Enables local users feature, if set to true. + * + * @param isLocalUserEnabled the isLocalUserEnabled value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties withIsLocalUserEnabled(Boolean isLocalUserEnabled) { + this.isLocalUserEnabled = isLocalUserEnabled; + return this; + } + + /** + * Get the enableExtendedGroups property: Enables extended group support with local users feature, if set to true. + * + * @return the enableExtendedGroups value. + */ + public Boolean enableExtendedGroups() { + return this.enableExtendedGroups; + } + + /** + * Set the enableExtendedGroups property: Enables extended group support with local users feature, if set to true. + * + * @param enableExtendedGroups the enableExtendedGroups value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties withEnableExtendedGroups(Boolean enableExtendedGroups) { + this.enableExtendedGroups = enableExtendedGroups; + return this; + } + + /** + * Get the isHnsEnabled property: Account HierarchicalNamespace enabled if sets to true. + * + * @return the isHnsEnabled value. + */ + public Boolean isHnsEnabled() { + return this.isHnsEnabled; + } + + /** + * Set the isHnsEnabled property: Account HierarchicalNamespace enabled if sets to true. + * + * @param isHnsEnabled the isHnsEnabled value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties withIsHnsEnabled(Boolean isHnsEnabled) { + this.isHnsEnabled = isHnsEnabled; + return this; + } + + /** + * Get the geoReplicationStats property: Geo Replication Stats. + * + * @return the geoReplicationStats value. + */ + public GeoReplicationStats geoReplicationStats() { + return this.geoReplicationStats; + } + + /** + * Get the failoverInProgress property: If the failover is in progress, the value will be true, otherwise, it will + * be null. + * + * @return the failoverInProgress value. + */ + public Boolean failoverInProgress() { + return this.failoverInProgress; + } + + /** + * Get the largeFileSharesState property: Allow large file shares if sets to Enabled. It cannot be disabled once it + * is enabled. + * + * @return the largeFileSharesState value. + */ + public LargeFileSharesState largeFileSharesState() { + return this.largeFileSharesState; + } + + /** + * Set the largeFileSharesState property: Allow large file shares if sets to Enabled. It cannot be disabled once it + * is enabled. + * + * @param largeFileSharesState the largeFileSharesState value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties withLargeFileSharesState(LargeFileSharesState largeFileSharesState) { + this.largeFileSharesState = largeFileSharesState; + return this; + } + + /** + * Get the privateEndpointConnections property: List of private endpoint connection associated with the specified + * storage account. + * + * @return the privateEndpointConnections value. + */ + public List privateEndpointConnections() { + return this.privateEndpointConnections; + } + + /** + * Get the routingPreference property: Maintains information about the network routing choice opted by the user for + * data transfer. + * + * @return the routingPreference value. + */ + public RoutingPreference routingPreference() { + return this.routingPreference; + } + + /** + * Set the routingPreference property: Maintains information about the network routing choice opted by the user for + * data transfer. + * + * @param routingPreference the routingPreference value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties withRoutingPreference(RoutingPreference routingPreference) { + this.routingPreference = routingPreference; + return this; + } + + /** + * Get the dualStackEndpointPreference property: Maintains information about the Internet protocol opted by the + * user. + * + * @return the dualStackEndpointPreference value. + */ + public DualStackEndpointPreference dualStackEndpointPreference() { + return this.dualStackEndpointPreference; + } + + /** + * Set the dualStackEndpointPreference property: Maintains information about the Internet protocol opted by the + * user. + * + * @param dualStackEndpointPreference the dualStackEndpointPreference value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties + withDualStackEndpointPreference(DualStackEndpointPreference dualStackEndpointPreference) { + this.dualStackEndpointPreference = dualStackEndpointPreference; + return this; + } + + /** + * Get the blobRestoreStatus property: Blob restore status. + * + * @return the blobRestoreStatus value. + */ + public BlobRestoreStatus blobRestoreStatus() { + return this.blobRestoreStatus; + } + + /** + * Get the allowBlobPublicAccess property: Allow or disallow public access to all blobs or containers in the storage + * account. The default interpretation is false for this property. + * + * @return the allowBlobPublicAccess value. + */ + public Boolean allowBlobPublicAccess() { + return this.allowBlobPublicAccess; + } + + /** + * Set the allowBlobPublicAccess property: Allow or disallow public access to all blobs or containers in the storage + * account. The default interpretation is false for this property. + * + * @param allowBlobPublicAccess the allowBlobPublicAccess value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties withAllowBlobPublicAccess(Boolean allowBlobPublicAccess) { + this.allowBlobPublicAccess = allowBlobPublicAccess; + return this; + } + + /** + * Get the minimumTlsVersion property: Set the minimum TLS version to be permitted on requests to storage. The + * default interpretation is TLS 1.0 for this property. Minimum TLS version 1.3 version is not supported. + * + * @return the minimumTlsVersion value. + */ + public MinimumTlsVersion minimumTlsVersion() { + return this.minimumTlsVersion; + } + + /** + * Set the minimumTlsVersion property: Set the minimum TLS version to be permitted on requests to storage. The + * default interpretation is TLS 1.0 for this property. Minimum TLS version 1.3 version is not supported. + * + * @param minimumTlsVersion the minimumTlsVersion value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties withMinimumTlsVersion(MinimumTlsVersion minimumTlsVersion) { + this.minimumTlsVersion = minimumTlsVersion; + return this; + } + + /** + * Get the allowSharedKeyAccess property: Indicates whether the storage account permits requests to be authorized + * with the account access key via Shared Key. If false, then all requests, including shared access signatures, must + * be authorized with Azure Active Directory (Azure AD). The default value is null, which is equivalent to true. + * + * @return the allowSharedKeyAccess value. + */ + public Boolean allowSharedKeyAccess() { + return this.allowSharedKeyAccess; + } + + /** + * Set the allowSharedKeyAccess property: Indicates whether the storage account permits requests to be authorized + * with the account access key via Shared Key. If false, then all requests, including shared access signatures, must + * be authorized with Azure Active Directory (Azure AD). The default value is null, which is equivalent to true. + * + * @param allowSharedKeyAccess the allowSharedKeyAccess value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties withAllowSharedKeyAccess(Boolean allowSharedKeyAccess) { + this.allowSharedKeyAccess = allowSharedKeyAccess; + return this; + } + + /** + * Get the enableNfsV3 property: NFS 3.0 protocol support enabled if set to true. + * + * @return the enableNfsV3 value. + */ + public Boolean enableNfsV3() { + return this.enableNfsV3; + } + + /** + * Set the enableNfsV3 property: NFS 3.0 protocol support enabled if set to true. + * + * @param enableNfsV3 the enableNfsV3 value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties withEnableNfsV3(Boolean enableNfsV3) { + this.enableNfsV3 = enableNfsV3; + return this; + } + + /** + * Get the allowCrossTenantReplication property: Allow or disallow cross AAD tenant object replication. Set this + * property to true for new or existing accounts only if object replication policies will involve storage accounts + * in different AAD tenants. The default interpretation is false for new accounts to follow best security practices + * by default. + * + * @return the allowCrossTenantReplication value. + */ + public Boolean allowCrossTenantReplication() { + return this.allowCrossTenantReplication; + } + + /** + * Set the allowCrossTenantReplication property: Allow or disallow cross AAD tenant object replication. Set this + * property to true for new or existing accounts only if object replication policies will involve storage accounts + * in different AAD tenants. The default interpretation is false for new accounts to follow best security practices + * by default. + * + * @param allowCrossTenantReplication the allowCrossTenantReplication value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties withAllowCrossTenantReplication(Boolean allowCrossTenantReplication) { + this.allowCrossTenantReplication = allowCrossTenantReplication; + return this; + } + + /** + * Get the defaultToOAuthAuthentication property: A boolean flag which indicates whether the default authentication + * is OAuth or not. The default interpretation is false for this property. + * + * @return the defaultToOAuthAuthentication value. + */ + public Boolean defaultToOAuthAuthentication() { + return this.defaultToOAuthAuthentication; + } + + /** + * Set the defaultToOAuthAuthentication property: A boolean flag which indicates whether the default authentication + * is OAuth or not. The default interpretation is false for this property. + * + * @param defaultToOAuthAuthentication the defaultToOAuthAuthentication value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties withDefaultToOAuthAuthentication(Boolean defaultToOAuthAuthentication) { + this.defaultToOAuthAuthentication = defaultToOAuthAuthentication; + return this; + } + + /** + * Get the publicNetworkAccess property: Allow, disallow, or let Network Security Perimeter configuration to + * evaluate public network access to Storage Account. + * + * @return the publicNetworkAccess value. + */ + public PublicNetworkAccess publicNetworkAccess() { + return this.publicNetworkAccess; + } + + /** + * Set the publicNetworkAccess property: Allow, disallow, or let Network Security Perimeter configuration to + * evaluate public network access to Storage Account. + * + * @param publicNetworkAccess the publicNetworkAccess value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties withPublicNetworkAccess(PublicNetworkAccess publicNetworkAccess) { + this.publicNetworkAccess = publicNetworkAccess; + return this; + } + + /** + * Get the immutableStorageWithVersioning property: The property is immutable and can only be set to true at the + * account creation time. When set to true, it enables object level immutability for all the containers in the + * account by default. + * + * @return the immutableStorageWithVersioning value. + */ + public ImmutableStorageAccount immutableStorageWithVersioning() { + return this.immutableStorageWithVersioning; + } + + /** + * Set the immutableStorageWithVersioning property: The property is immutable and can only be set to true at the + * account creation time. When set to true, it enables object level immutability for all the containers in the + * account by default. + * + * @param immutableStorageWithVersioning the immutableStorageWithVersioning value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties + withImmutableStorageWithVersioning(ImmutableStorageAccount immutableStorageWithVersioning) { + this.immutableStorageWithVersioning = immutableStorageWithVersioning; + return this; + } + + /** + * Get the allowedCopyScope property: Restrict copy to and from Storage Accounts within an AAD tenant or with + * Private Links to the same VNet. + * + * @return the allowedCopyScope value. + */ + public AllowedCopyScope allowedCopyScope() { + return this.allowedCopyScope; + } + + /** + * Set the allowedCopyScope property: Restrict copy to and from Storage Accounts within an AAD tenant or with + * Private Links to the same VNet. + * + * @param allowedCopyScope the allowedCopyScope value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties withAllowedCopyScope(AllowedCopyScope allowedCopyScope) { + this.allowedCopyScope = allowedCopyScope; + return this; + } + + /** + * Get the storageAccountSkuConversionStatus property: This property is readOnly and is set by server during + * asynchronous storage account sku conversion operations. + * + * @return the storageAccountSkuConversionStatus value. + */ + public StorageAccountSkuConversionStatus storageAccountSkuConversionStatus() { + return this.storageAccountSkuConversionStatus; + } + + /** + * Set the storageAccountSkuConversionStatus property: This property is readOnly and is set by server during + * asynchronous storage account sku conversion operations. + * + * @param storageAccountSkuConversionStatus the storageAccountSkuConversionStatus value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties + withStorageAccountSkuConversionStatus(StorageAccountSkuConversionStatus storageAccountSkuConversionStatus) { + this.storageAccountSkuConversionStatus = storageAccountSkuConversionStatus; + return this; + } + + /** + * Get the dnsEndpointType property: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create + * a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint + * URL will have an alphanumeric DNS Zone identifier. + * + * @return the dnsEndpointType value. + */ + public DnsEndpointType dnsEndpointType() { + return this.dnsEndpointType; + } + + /** + * Set the dnsEndpointType property: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create + * a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint + * URL will have an alphanumeric DNS Zone identifier. + * + * @param dnsEndpointType the dnsEndpointType value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties withDnsEndpointType(DnsEndpointType dnsEndpointType) { + this.dnsEndpointType = dnsEndpointType; + return this; + } + + /** + * Get the isSkuConversionBlocked property: This property will be set to true or false on an event of ongoing + * migration. Default value is null. + * + * @return the isSkuConversionBlocked value. + */ + public Boolean isSkuConversionBlocked() { + return this.isSkuConversionBlocked; + } + + /** + * Get the accountMigrationInProgress property: If customer initiated account migration is in progress, the value + * will be true else it will be null. + * + * @return the accountMigrationInProgress value. + */ + public Boolean accountMigrationInProgress() { + return this.accountMigrationInProgress; + } + + /** + * Get the geoPriorityReplicationStatus property: Status indicating whether Geo Priority Replication is enabled for + * the account. + * + * @return the geoPriorityReplicationStatus value. + */ + public GeoPriorityReplicationStatus geoPriorityReplicationStatus() { + return this.geoPriorityReplicationStatus; + } + + /** + * Set the geoPriorityReplicationStatus property: Status indicating whether Geo Priority Replication is enabled for + * the account. + * + * @param geoPriorityReplicationStatus the geoPriorityReplicationStatus value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties + withGeoPriorityReplicationStatus(GeoPriorityReplicationStatus geoPriorityReplicationStatus) { + this.geoPriorityReplicationStatus = geoPriorityReplicationStatus; + return this; + } + + /** + * Get the allowSharedKeyAccessForServices property: Indicate shared key access properties at service level. + * + * @return the allowSharedKeyAccessForServices value. + */ + public StorageAccountSharedKeyAccessProperties allowSharedKeyAccessForServices() { + return this.allowSharedKeyAccessForServices; + } + + /** + * Set the allowSharedKeyAccessForServices property: Indicate shared key access properties at service level. + * + * @param allowSharedKeyAccessForServices the allowSharedKeyAccessForServices value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties + withAllowSharedKeyAccessForServices(StorageAccountSharedKeyAccessProperties allowSharedKeyAccessForServices) { + this.allowSharedKeyAccessForServices = allowSharedKeyAccessForServices; + return this; + } + + /** + * Get the dataCollaborationPolicyProperties property: Data Collaboration policy for the storage account. + * + * @return the dataCollaborationPolicyProperties value. + */ + public StorageDataCollaborationPolicyProperties dataCollaborationPolicyProperties() { + return this.dataCollaborationPolicyProperties; + } + + /** + * Set the dataCollaborationPolicyProperties property: Data Collaboration policy for the storage account. + * + * @param dataCollaborationPolicyProperties the dataCollaborationPolicyProperties value to set. + * @return the StorageAccountProperties object itself. + */ + public StorageAccountProperties withDataCollaborationPolicyProperties( + StorageDataCollaborationPolicyProperties dataCollaborationPolicyProperties) { + this.dataCollaborationPolicyProperties = dataCollaborationPolicyProperties; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (primaryEndpoints() != null) { + primaryEndpoints().validate(); + } + if (customDomain() != null) { + customDomain().validate(); + } + if (sasPolicy() != null) { + sasPolicy().validate(); + } + if (keyPolicy() != null) { + keyPolicy().validate(); + } + if (keyCreationTime() != null) { + keyCreationTime().validate(); + } + if (secondaryEndpoints() != null) { + secondaryEndpoints().validate(); + } + if (encryption() != null) { + encryption().validate(); + } + if (azureFilesIdentityBasedAuthentication() != null) { + azureFilesIdentityBasedAuthentication().validate(); + } + if (networkRuleSet() != null) { + networkRuleSet().validate(); + } + if (geoReplicationStats() != null) { + geoReplicationStats().validate(); + } + if (privateEndpointConnections() != null) { + privateEndpointConnections().forEach(e -> e.validate()); + } + if (routingPreference() != null) { + routingPreference().validate(); + } + if (dualStackEndpointPreference() != null) { + dualStackEndpointPreference().validate(); + } + if (blobRestoreStatus() != null) { + blobRestoreStatus().validate(); + } + if (immutableStorageWithVersioning() != null) { + immutableStorageWithVersioning().validate(); + } + if (storageAccountSkuConversionStatus() != null) { + storageAccountSkuConversionStatus().validate(); + } + if (geoPriorityReplicationStatus() != null) { + geoPriorityReplicationStatus().validate(); + } + if (allowSharedKeyAccessForServices() != null) { + allowSharedKeyAccessForServices().validate(); + } + if (dataCollaborationPolicyProperties() != null) { + dataCollaborationPolicyProperties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("azureFilesIdentityBasedAuthentication", this.azureFilesIdentityBasedAuthentication); + jsonWriter.writeBooleanField("supportsHttpsTrafficOnly", this.enableHttpsTrafficOnly); + jsonWriter.writeBooleanField("isSftpEnabled", this.isSftpEnabled); + jsonWriter.writeBooleanField("isLocalUserEnabled", this.isLocalUserEnabled); + jsonWriter.writeBooleanField("enableExtendedGroups", this.enableExtendedGroups); + jsonWriter.writeBooleanField("isHnsEnabled", this.isHnsEnabled); + jsonWriter.writeStringField("largeFileSharesState", + this.largeFileSharesState == null ? null : this.largeFileSharesState.toString()); + jsonWriter.writeJsonField("routingPreference", this.routingPreference); + jsonWriter.writeJsonField("dualStackEndpointPreference", this.dualStackEndpointPreference); + jsonWriter.writeBooleanField("allowBlobPublicAccess", this.allowBlobPublicAccess); + jsonWriter.writeStringField("minimumTlsVersion", + this.minimumTlsVersion == null ? null : this.minimumTlsVersion.toString()); + jsonWriter.writeBooleanField("allowSharedKeyAccess", this.allowSharedKeyAccess); + jsonWriter.writeBooleanField("isNfsV3Enabled", this.enableNfsV3); + jsonWriter.writeBooleanField("allowCrossTenantReplication", this.allowCrossTenantReplication); + jsonWriter.writeBooleanField("defaultToOAuthAuthentication", this.defaultToOAuthAuthentication); + jsonWriter.writeStringField("publicNetworkAccess", + this.publicNetworkAccess == null ? null : this.publicNetworkAccess.toString()); + jsonWriter.writeJsonField("immutableStorageWithVersioning", this.immutableStorageWithVersioning); + jsonWriter.writeStringField("allowedCopyScope", + this.allowedCopyScope == null ? null : this.allowedCopyScope.toString()); + jsonWriter.writeJsonField("storageAccountSkuConversionStatus", this.storageAccountSkuConversionStatus); + jsonWriter.writeStringField("dnsEndpointType", + this.dnsEndpointType == null ? null : this.dnsEndpointType.toString()); + jsonWriter.writeJsonField("geoPriorityReplicationStatus", this.geoPriorityReplicationStatus); + jsonWriter.writeJsonField("allowSharedKeyAccessForServices", this.allowSharedKeyAccessForServices); + jsonWriter.writeJsonField("dataCollaborationPolicyProperties", this.dataCollaborationPolicyProperties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StorageAccountProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StorageAccountProperties if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the StorageAccountProperties. + */ + public static StorageAccountProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StorageAccountProperties deserializedStorageAccountProperties = new StorageAccountProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provisioningState".equals(fieldName)) { + deserializedStorageAccountProperties.provisioningState + = ProvisioningState.fromString(reader.getString()); + } else if ("primaryEndpoints".equals(fieldName)) { + deserializedStorageAccountProperties.primaryEndpoints = Endpoints.fromJson(reader); + } else if ("primaryLocation".equals(fieldName)) { + deserializedStorageAccountProperties.primaryLocation = reader.getString(); + } else if ("statusOfPrimary".equals(fieldName)) { + deserializedStorageAccountProperties.statusOfPrimary = AccountStatus.fromString(reader.getString()); + } else if ("lastGeoFailoverTime".equals(fieldName)) { + deserializedStorageAccountProperties.lastGeoFailoverTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("secondaryLocation".equals(fieldName)) { + deserializedStorageAccountProperties.secondaryLocation = reader.getString(); + } else if ("statusOfSecondary".equals(fieldName)) { + deserializedStorageAccountProperties.statusOfSecondary + = AccountStatus.fromString(reader.getString()); + } else if ("creationTime".equals(fieldName)) { + deserializedStorageAccountProperties.creationTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("customDomain".equals(fieldName)) { + deserializedStorageAccountProperties.customDomain = CustomDomain.fromJson(reader); + } else if ("sasPolicy".equals(fieldName)) { + deserializedStorageAccountProperties.sasPolicy = SasPolicy.fromJson(reader); + } else if ("keyPolicy".equals(fieldName)) { + deserializedStorageAccountProperties.keyPolicy = KeyPolicy.fromJson(reader); + } else if ("keyCreationTime".equals(fieldName)) { + deserializedStorageAccountProperties.keyCreationTime = KeyCreationTime.fromJson(reader); + } else if ("secondaryEndpoints".equals(fieldName)) { + deserializedStorageAccountProperties.secondaryEndpoints = Endpoints.fromJson(reader); + } else if ("encryption".equals(fieldName)) { + deserializedStorageAccountProperties.encryption = Encryption.fromJson(reader); + } else if ("accessTier".equals(fieldName)) { + deserializedStorageAccountProperties.accessTier = AccessTier.fromString(reader.getString()); + } else if ("azureFilesIdentityBasedAuthentication".equals(fieldName)) { + deserializedStorageAccountProperties.azureFilesIdentityBasedAuthentication + = AzureFilesIdentityBasedAuthentication.fromJson(reader); + } else if ("supportsHttpsTrafficOnly".equals(fieldName)) { + deserializedStorageAccountProperties.enableHttpsTrafficOnly + = reader.getNullable(JsonReader::getBoolean); + } else if ("networkAcls".equals(fieldName)) { + deserializedStorageAccountProperties.networkRuleSet = NetworkRuleSet.fromJson(reader); + } else if ("isSftpEnabled".equals(fieldName)) { + deserializedStorageAccountProperties.isSftpEnabled = reader.getNullable(JsonReader::getBoolean); + } else if ("isLocalUserEnabled".equals(fieldName)) { + deserializedStorageAccountProperties.isLocalUserEnabled + = reader.getNullable(JsonReader::getBoolean); + } else if ("enableExtendedGroups".equals(fieldName)) { + deserializedStorageAccountProperties.enableExtendedGroups + = reader.getNullable(JsonReader::getBoolean); + } else if ("isHnsEnabled".equals(fieldName)) { + deserializedStorageAccountProperties.isHnsEnabled = reader.getNullable(JsonReader::getBoolean); + } else if ("geoReplicationStats".equals(fieldName)) { + deserializedStorageAccountProperties.geoReplicationStats = GeoReplicationStats.fromJson(reader); + } else if ("failoverInProgress".equals(fieldName)) { + deserializedStorageAccountProperties.failoverInProgress + = reader.getNullable(JsonReader::getBoolean); + } else if ("largeFileSharesState".equals(fieldName)) { + deserializedStorageAccountProperties.largeFileSharesState + = LargeFileSharesState.fromString(reader.getString()); + } else if ("privateEndpointConnections".equals(fieldName)) { + List privateEndpointConnections + = reader.readArray(reader1 -> PrivateEndpointConnection.fromJson(reader1)); + deserializedStorageAccountProperties.privateEndpointConnections = privateEndpointConnections; + } else if ("routingPreference".equals(fieldName)) { + deserializedStorageAccountProperties.routingPreference = RoutingPreference.fromJson(reader); + } else if ("dualStackEndpointPreference".equals(fieldName)) { + deserializedStorageAccountProperties.dualStackEndpointPreference + = DualStackEndpointPreference.fromJson(reader); + } else if ("blobRestoreStatus".equals(fieldName)) { + deserializedStorageAccountProperties.blobRestoreStatus = BlobRestoreStatus.fromJson(reader); + } else if ("allowBlobPublicAccess".equals(fieldName)) { + deserializedStorageAccountProperties.allowBlobPublicAccess + = reader.getNullable(JsonReader::getBoolean); + } else if ("minimumTlsVersion".equals(fieldName)) { + deserializedStorageAccountProperties.minimumTlsVersion + = MinimumTlsVersion.fromString(reader.getString()); + } else if ("allowSharedKeyAccess".equals(fieldName)) { + deserializedStorageAccountProperties.allowSharedKeyAccess + = reader.getNullable(JsonReader::getBoolean); + } else if ("isNfsV3Enabled".equals(fieldName)) { + deserializedStorageAccountProperties.enableNfsV3 = reader.getNullable(JsonReader::getBoolean); + } else if ("allowCrossTenantReplication".equals(fieldName)) { + deserializedStorageAccountProperties.allowCrossTenantReplication + = reader.getNullable(JsonReader::getBoolean); + } else if ("defaultToOAuthAuthentication".equals(fieldName)) { + deserializedStorageAccountProperties.defaultToOAuthAuthentication + = reader.getNullable(JsonReader::getBoolean); + } else if ("publicNetworkAccess".equals(fieldName)) { + deserializedStorageAccountProperties.publicNetworkAccess + = PublicNetworkAccess.fromString(reader.getString()); + } else if ("immutableStorageWithVersioning".equals(fieldName)) { + deserializedStorageAccountProperties.immutableStorageWithVersioning + = ImmutableStorageAccount.fromJson(reader); + } else if ("allowedCopyScope".equals(fieldName)) { + deserializedStorageAccountProperties.allowedCopyScope + = AllowedCopyScope.fromString(reader.getString()); + } else if ("storageAccountSkuConversionStatus".equals(fieldName)) { + deserializedStorageAccountProperties.storageAccountSkuConversionStatus + = StorageAccountSkuConversionStatus.fromJson(reader); + } else if ("dnsEndpointType".equals(fieldName)) { + deserializedStorageAccountProperties.dnsEndpointType + = DnsEndpointType.fromString(reader.getString()); + } else if ("isSkuConversionBlocked".equals(fieldName)) { + deserializedStorageAccountProperties.isSkuConversionBlocked + = reader.getNullable(JsonReader::getBoolean); + } else if ("accountMigrationInProgress".equals(fieldName)) { + deserializedStorageAccountProperties.accountMigrationInProgress + = reader.getNullable(JsonReader::getBoolean); + } else if ("geoPriorityReplicationStatus".equals(fieldName)) { + deserializedStorageAccountProperties.geoPriorityReplicationStatus + = GeoPriorityReplicationStatus.fromJson(reader); + } else if ("allowSharedKeyAccessForServices".equals(fieldName)) { + deserializedStorageAccountProperties.allowSharedKeyAccessForServices + = StorageAccountSharedKeyAccessProperties.fromJson(reader); + } else if ("dataCollaborationPolicyProperties".equals(fieldName)) { + deserializedStorageAccountProperties.dataCollaborationPolicyProperties + = StorageDataCollaborationPolicyProperties.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedStorageAccountProperties; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/models/StorageAccountPropertiesCreateParameters.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/models/StorageAccountPropertiesCreateParameters.java new file mode 100644 index 0000000000000..645eb1f45d725 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/models/StorageAccountPropertiesCreateParameters.java @@ -0,0 +1,1009 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.storage.models.AccessTier; +import com.azure.resourcemanager.storage.models.AllowedCopyScope; +import com.azure.resourcemanager.storage.models.AzureFilesIdentityBasedAuthentication; +import com.azure.resourcemanager.storage.models.CustomDomain; +import com.azure.resourcemanager.storage.models.DnsEndpointType; +import com.azure.resourcemanager.storage.models.DualStackEndpointPreference; +import com.azure.resourcemanager.storage.models.Encryption; +import com.azure.resourcemanager.storage.models.GeoPriorityReplicationStatus; +import com.azure.resourcemanager.storage.models.ImmutableStorageAccount; +import com.azure.resourcemanager.storage.models.KeyPolicy; +import com.azure.resourcemanager.storage.models.LargeFileSharesState; +import com.azure.resourcemanager.storage.models.MinimumTlsVersion; +import com.azure.resourcemanager.storage.models.NetworkRuleSet; +import com.azure.resourcemanager.storage.models.PublicNetworkAccess; +import com.azure.resourcemanager.storage.models.RoutingPreference; +import com.azure.resourcemanager.storage.models.SasPolicy; +import com.azure.resourcemanager.storage.models.StorageAccountSharedKeyAccessProperties; +import com.azure.resourcemanager.storage.models.StorageDataCollaborationPolicyProperties; +import java.io.IOException; + +/** + * The parameters used to create the storage account. + */ +@Fluent +public final class StorageAccountPropertiesCreateParameters + implements JsonSerializable { + /* + * Restrict copy to and from Storage Accounts within an AAD tenant or with Private Links to the same VNet. + */ + private AllowedCopyScope allowedCopyScope; + + /* + * Allow, disallow, or let Network Security Perimeter configuration to evaluate public network access to Storage + * Account. Value is optional but if passed in, must be 'Enabled', 'Disabled' or 'SecuredByPerimeter'. + */ + private PublicNetworkAccess publicNetworkAccess; + + /* + * SasPolicy assigned to the storage account. + */ + private SasPolicy sasPolicy; + + /* + * KeyPolicy assigned to the storage account. + */ + private KeyPolicy keyPolicy; + + /* + * User domain assigned to the storage account. Name is the CNAME source. Only one custom domain is supported per + * storage account at this time. To clear the existing custom domain, use an empty string for the custom domain name + * property. + */ + private CustomDomain customDomain; + + /* + * Encryption settings to be used for server-side encryption for the storage account. + */ + private Encryption encryption; + + /* + * Network rule set + */ + private NetworkRuleSet networkRuleSet; + + /* + * Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access + * tier is the default value for premium block blobs storage account type and it cannot be changed for the premium + * block blobs storage account type. + */ + private AccessTier accessTier; + + /* + * Provides the identity based authentication settings for Azure Files. + */ + private AzureFilesIdentityBasedAuthentication azureFilesIdentityBasedAuthentication; + + /* + * Allows https traffic only to storage service if sets to true. The default value is true since API version + * 2019-04-01. + */ + private Boolean enableHttpsTrafficOnly; + + /* + * Enables Secure File Transfer Protocol, if set to true + */ + private Boolean isSftpEnabled; + + /* + * Enables local users feature, if set to true + */ + private Boolean isLocalUserEnabled; + + /* + * Enables extended group support with local users feature, if set to true + */ + private Boolean enableExtendedGroups; + + /* + * Account HierarchicalNamespace enabled if sets to true. + */ + private Boolean isHnsEnabled; + + /* + * Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. + */ + private LargeFileSharesState largeFileSharesState; + + /* + * Maintains information about the network routing choice opted by the user for data transfer + */ + private RoutingPreference routingPreference; + + /* + * Maintains information about the Internet protocol opted by the user. + */ + private DualStackEndpointPreference dualStackEndpointPreference; + + /* + * Allow or disallow public access to all blobs or containers in the storage account. The default interpretation is + * false for this property. + */ + private Boolean allowBlobPublicAccess; + + /* + * Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for + * this property. Minimum TLS version 1.3 version is not supported. + */ + private MinimumTlsVersion minimumTlsVersion; + + /* + * Indicates whether the storage account permits requests to be authorized with the account access key via Shared + * Key. If false, then all requests, including shared access signatures, must be authorized with Azure Active + * Directory (Azure AD). The default value is null, which is equivalent to true. + */ + private Boolean allowSharedKeyAccess; + + /* + * NFS 3.0 protocol support enabled if set to true. + */ + private Boolean enableNfsV3; + + /* + * Allow or disallow cross AAD tenant object replication. Set this property to true for new or existing accounts + * only if object replication policies will involve storage accounts in different AAD tenants. The default + * interpretation is false for new accounts to follow best security practices by default. + */ + private Boolean allowCrossTenantReplication; + + /* + * A boolean flag which indicates whether the default authentication is OAuth or not. The default interpretation is + * false for this property. + */ + private Boolean defaultToOAuthAuthentication; + + /* + * The property is immutable and can only be set to true at the account creation time. When set to true, it enables + * object level immutability for all the new containers in the account by default. + */ + private ImmutableStorageAccount immutableStorageWithVersioning; + + /* + * Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a + * single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric + * DNS Zone identifier. + */ + private DnsEndpointType dnsEndpointType; + + /* + * Status indicating whether Geo Priority Replication is enabled for the account. + */ + private GeoPriorityReplicationStatus geoPriorityReplicationStatus; + + /* + * Indicate shared key access properties at service level + */ + private StorageAccountSharedKeyAccessProperties allowSharedKeyAccessForServices; + + /* + * Data Collaboration policy for the storage account. + */ + private StorageDataCollaborationPolicyProperties dataCollaborationPolicyProperties; + + /** + * Creates an instance of StorageAccountPropertiesCreateParameters class. + */ + public StorageAccountPropertiesCreateParameters() { + } + + /** + * Get the allowedCopyScope property: Restrict copy to and from Storage Accounts within an AAD tenant or with + * Private Links to the same VNet. + * + * @return the allowedCopyScope value. + */ + public AllowedCopyScope allowedCopyScope() { + return this.allowedCopyScope; + } + + /** + * Set the allowedCopyScope property: Restrict copy to and from Storage Accounts within an AAD tenant or with + * Private Links to the same VNet. + * + * @param allowedCopyScope the allowedCopyScope value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withAllowedCopyScope(AllowedCopyScope allowedCopyScope) { + this.allowedCopyScope = allowedCopyScope; + return this; + } + + /** + * Get the publicNetworkAccess property: Allow, disallow, or let Network Security Perimeter configuration to + * evaluate public network access to Storage Account. Value is optional but if passed in, must be 'Enabled', + * 'Disabled' or 'SecuredByPerimeter'. + * + * @return the publicNetworkAccess value. + */ + public PublicNetworkAccess publicNetworkAccess() { + return this.publicNetworkAccess; + } + + /** + * Set the publicNetworkAccess property: Allow, disallow, or let Network Security Perimeter configuration to + * evaluate public network access to Storage Account. Value is optional but if passed in, must be 'Enabled', + * 'Disabled' or 'SecuredByPerimeter'. + * + * @param publicNetworkAccess the publicNetworkAccess value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withPublicNetworkAccess(PublicNetworkAccess publicNetworkAccess) { + this.publicNetworkAccess = publicNetworkAccess; + return this; + } + + /** + * Get the sasPolicy property: SasPolicy assigned to the storage account. + * + * @return the sasPolicy value. + */ + public SasPolicy sasPolicy() { + return this.sasPolicy; + } + + /** + * Set the sasPolicy property: SasPolicy assigned to the storage account. + * + * @param sasPolicy the sasPolicy value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withSasPolicy(SasPolicy sasPolicy) { + this.sasPolicy = sasPolicy; + return this; + } + + /** + * Get the keyPolicy property: KeyPolicy assigned to the storage account. + * + * @return the keyPolicy value. + */ + public KeyPolicy keyPolicy() { + return this.keyPolicy; + } + + /** + * Set the keyPolicy property: KeyPolicy assigned to the storage account. + * + * @param keyPolicy the keyPolicy value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withKeyPolicy(KeyPolicy keyPolicy) { + this.keyPolicy = keyPolicy; + return this; + } + + /** + * Get the customDomain property: User domain assigned to the storage account. Name is the CNAME source. Only one + * custom domain is supported per storage account at this time. To clear the existing custom domain, use an empty + * string for the custom domain name property. + * + * @return the customDomain value. + */ + public CustomDomain customDomain() { + return this.customDomain; + } + + /** + * Set the customDomain property: User domain assigned to the storage account. Name is the CNAME source. Only one + * custom domain is supported per storage account at this time. To clear the existing custom domain, use an empty + * string for the custom domain name property. + * + * @param customDomain the customDomain value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withCustomDomain(CustomDomain customDomain) { + this.customDomain = customDomain; + return this; + } + + /** + * Get the encryption property: Encryption settings to be used for server-side encryption for the storage account. + * + * @return the encryption value. + */ + public Encryption encryption() { + return this.encryption; + } + + /** + * Set the encryption property: Encryption settings to be used for server-side encryption for the storage account. + * + * @param encryption the encryption value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withEncryption(Encryption encryption) { + this.encryption = encryption; + return this; + } + + /** + * Get the networkRuleSet property: Network rule set. + * + * @return the networkRuleSet value. + */ + public NetworkRuleSet networkRuleSet() { + return this.networkRuleSet; + } + + /** + * Set the networkRuleSet property: Network rule set. + * + * @param networkRuleSet the networkRuleSet value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withNetworkRuleSet(NetworkRuleSet networkRuleSet) { + this.networkRuleSet = networkRuleSet; + return this; + } + + /** + * Get the accessTier property: Required for storage accounts where kind = BlobStorage. The access tier is used for + * billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it + * cannot be changed for the premium block blobs storage account type. + * + * @return the accessTier value. + */ + public AccessTier accessTier() { + return this.accessTier; + } + + /** + * Set the accessTier property: Required for storage accounts where kind = BlobStorage. The access tier is used for + * billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it + * cannot be changed for the premium block blobs storage account type. + * + * @param accessTier the accessTier value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withAccessTier(AccessTier accessTier) { + this.accessTier = accessTier; + return this; + } + + /** + * Get the azureFilesIdentityBasedAuthentication property: Provides the identity based authentication settings for + * Azure Files. + * + * @return the azureFilesIdentityBasedAuthentication value. + */ + public AzureFilesIdentityBasedAuthentication azureFilesIdentityBasedAuthentication() { + return this.azureFilesIdentityBasedAuthentication; + } + + /** + * Set the azureFilesIdentityBasedAuthentication property: Provides the identity based authentication settings for + * Azure Files. + * + * @param azureFilesIdentityBasedAuthentication the azureFilesIdentityBasedAuthentication value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withAzureFilesIdentityBasedAuthentication( + AzureFilesIdentityBasedAuthentication azureFilesIdentityBasedAuthentication) { + this.azureFilesIdentityBasedAuthentication = azureFilesIdentityBasedAuthentication; + return this; + } + + /** + * Get the enableHttpsTrafficOnly property: Allows https traffic only to storage service if sets to true. The + * default value is true since API version 2019-04-01. + * + * @return the enableHttpsTrafficOnly value. + */ + public Boolean enableHttpsTrafficOnly() { + return this.enableHttpsTrafficOnly; + } + + /** + * Set the enableHttpsTrafficOnly property: Allows https traffic only to storage service if sets to true. The + * default value is true since API version 2019-04-01. + * + * @param enableHttpsTrafficOnly the enableHttpsTrafficOnly value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withEnableHttpsTrafficOnly(Boolean enableHttpsTrafficOnly) { + this.enableHttpsTrafficOnly = enableHttpsTrafficOnly; + return this; + } + + /** + * Get the isSftpEnabled property: Enables Secure File Transfer Protocol, if set to true. + * + * @return the isSftpEnabled value. + */ + public Boolean isSftpEnabled() { + return this.isSftpEnabled; + } + + /** + * Set the isSftpEnabled property: Enables Secure File Transfer Protocol, if set to true. + * + * @param isSftpEnabled the isSftpEnabled value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withIsSftpEnabled(Boolean isSftpEnabled) { + this.isSftpEnabled = isSftpEnabled; + return this; + } + + /** + * Get the isLocalUserEnabled property: Enables local users feature, if set to true. + * + * @return the isLocalUserEnabled value. + */ + public Boolean isLocalUserEnabled() { + return this.isLocalUserEnabled; + } + + /** + * Set the isLocalUserEnabled property: Enables local users feature, if set to true. + * + * @param isLocalUserEnabled the isLocalUserEnabled value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withIsLocalUserEnabled(Boolean isLocalUserEnabled) { + this.isLocalUserEnabled = isLocalUserEnabled; + return this; + } + + /** + * Get the enableExtendedGroups property: Enables extended group support with local users feature, if set to true. + * + * @return the enableExtendedGroups value. + */ + public Boolean enableExtendedGroups() { + return this.enableExtendedGroups; + } + + /** + * Set the enableExtendedGroups property: Enables extended group support with local users feature, if set to true. + * + * @param enableExtendedGroups the enableExtendedGroups value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withEnableExtendedGroups(Boolean enableExtendedGroups) { + this.enableExtendedGroups = enableExtendedGroups; + return this; + } + + /** + * Get the isHnsEnabled property: Account HierarchicalNamespace enabled if sets to true. + * + * @return the isHnsEnabled value. + */ + public Boolean isHnsEnabled() { + return this.isHnsEnabled; + } + + /** + * Set the isHnsEnabled property: Account HierarchicalNamespace enabled if sets to true. + * + * @param isHnsEnabled the isHnsEnabled value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withIsHnsEnabled(Boolean isHnsEnabled) { + this.isHnsEnabled = isHnsEnabled; + return this; + } + + /** + * Get the largeFileSharesState property: Allow large file shares if sets to Enabled. It cannot be disabled once it + * is enabled. + * + * @return the largeFileSharesState value. + */ + public LargeFileSharesState largeFileSharesState() { + return this.largeFileSharesState; + } + + /** + * Set the largeFileSharesState property: Allow large file shares if sets to Enabled. It cannot be disabled once it + * is enabled. + * + * @param largeFileSharesState the largeFileSharesState value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters + withLargeFileSharesState(LargeFileSharesState largeFileSharesState) { + this.largeFileSharesState = largeFileSharesState; + return this; + } + + /** + * Get the routingPreference property: Maintains information about the network routing choice opted by the user for + * data transfer. + * + * @return the routingPreference value. + */ + public RoutingPreference routingPreference() { + return this.routingPreference; + } + + /** + * Set the routingPreference property: Maintains information about the network routing choice opted by the user for + * data transfer. + * + * @param routingPreference the routingPreference value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withRoutingPreference(RoutingPreference routingPreference) { + this.routingPreference = routingPreference; + return this; + } + + /** + * Get the dualStackEndpointPreference property: Maintains information about the Internet protocol opted by the + * user. + * + * @return the dualStackEndpointPreference value. + */ + public DualStackEndpointPreference dualStackEndpointPreference() { + return this.dualStackEndpointPreference; + } + + /** + * Set the dualStackEndpointPreference property: Maintains information about the Internet protocol opted by the + * user. + * + * @param dualStackEndpointPreference the dualStackEndpointPreference value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters + withDualStackEndpointPreference(DualStackEndpointPreference dualStackEndpointPreference) { + this.dualStackEndpointPreference = dualStackEndpointPreference; + return this; + } + + /** + * Get the allowBlobPublicAccess property: Allow or disallow public access to all blobs or containers in the storage + * account. The default interpretation is false for this property. + * + * @return the allowBlobPublicAccess value. + */ + public Boolean allowBlobPublicAccess() { + return this.allowBlobPublicAccess; + } + + /** + * Set the allowBlobPublicAccess property: Allow or disallow public access to all blobs or containers in the storage + * account. The default interpretation is false for this property. + * + * @param allowBlobPublicAccess the allowBlobPublicAccess value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withAllowBlobPublicAccess(Boolean allowBlobPublicAccess) { + this.allowBlobPublicAccess = allowBlobPublicAccess; + return this; + } + + /** + * Get the minimumTlsVersion property: Set the minimum TLS version to be permitted on requests to storage. The + * default interpretation is TLS 1.0 for this property. Minimum TLS version 1.3 version is not supported. + * + * @return the minimumTlsVersion value. + */ + public MinimumTlsVersion minimumTlsVersion() { + return this.minimumTlsVersion; + } + + /** + * Set the minimumTlsVersion property: Set the minimum TLS version to be permitted on requests to storage. The + * default interpretation is TLS 1.0 for this property. Minimum TLS version 1.3 version is not supported. + * + * @param minimumTlsVersion the minimumTlsVersion value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withMinimumTlsVersion(MinimumTlsVersion minimumTlsVersion) { + this.minimumTlsVersion = minimumTlsVersion; + return this; + } + + /** + * Get the allowSharedKeyAccess property: Indicates whether the storage account permits requests to be authorized + * with the account access key via Shared Key. If false, then all requests, including shared access signatures, must + * be authorized with Azure Active Directory (Azure AD). The default value is null, which is equivalent to true. + * + * @return the allowSharedKeyAccess value. + */ + public Boolean allowSharedKeyAccess() { + return this.allowSharedKeyAccess; + } + + /** + * Set the allowSharedKeyAccess property: Indicates whether the storage account permits requests to be authorized + * with the account access key via Shared Key. If false, then all requests, including shared access signatures, must + * be authorized with Azure Active Directory (Azure AD). The default value is null, which is equivalent to true. + * + * @param allowSharedKeyAccess the allowSharedKeyAccess value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withAllowSharedKeyAccess(Boolean allowSharedKeyAccess) { + this.allowSharedKeyAccess = allowSharedKeyAccess; + return this; + } + + /** + * Get the enableNfsV3 property: NFS 3.0 protocol support enabled if set to true. + * + * @return the enableNfsV3 value. + */ + public Boolean enableNfsV3() { + return this.enableNfsV3; + } + + /** + * Set the enableNfsV3 property: NFS 3.0 protocol support enabled if set to true. + * + * @param enableNfsV3 the enableNfsV3 value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withEnableNfsV3(Boolean enableNfsV3) { + this.enableNfsV3 = enableNfsV3; + return this; + } + + /** + * Get the allowCrossTenantReplication property: Allow or disallow cross AAD tenant object replication. Set this + * property to true for new or existing accounts only if object replication policies will involve storage accounts + * in different AAD tenants. The default interpretation is false for new accounts to follow best security practices + * by default. + * + * @return the allowCrossTenantReplication value. + */ + public Boolean allowCrossTenantReplication() { + return this.allowCrossTenantReplication; + } + + /** + * Set the allowCrossTenantReplication property: Allow or disallow cross AAD tenant object replication. Set this + * property to true for new or existing accounts only if object replication policies will involve storage accounts + * in different AAD tenants. The default interpretation is false for new accounts to follow best security practices + * by default. + * + * @param allowCrossTenantReplication the allowCrossTenantReplication value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters + withAllowCrossTenantReplication(Boolean allowCrossTenantReplication) { + this.allowCrossTenantReplication = allowCrossTenantReplication; + return this; + } + + /** + * Get the defaultToOAuthAuthentication property: A boolean flag which indicates whether the default authentication + * is OAuth or not. The default interpretation is false for this property. + * + * @return the defaultToOAuthAuthentication value. + */ + public Boolean defaultToOAuthAuthentication() { + return this.defaultToOAuthAuthentication; + } + + /** + * Set the defaultToOAuthAuthentication property: A boolean flag which indicates whether the default authentication + * is OAuth or not. The default interpretation is false for this property. + * + * @param defaultToOAuthAuthentication the defaultToOAuthAuthentication value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters + withDefaultToOAuthAuthentication(Boolean defaultToOAuthAuthentication) { + this.defaultToOAuthAuthentication = defaultToOAuthAuthentication; + return this; + } + + /** + * Get the immutableStorageWithVersioning property: The property is immutable and can only be set to true at the + * account creation time. When set to true, it enables object level immutability for all the new containers in the + * account by default. + * + * @return the immutableStorageWithVersioning value. + */ + public ImmutableStorageAccount immutableStorageWithVersioning() { + return this.immutableStorageWithVersioning; + } + + /** + * Set the immutableStorageWithVersioning property: The property is immutable and can only be set to true at the + * account creation time. When set to true, it enables object level immutability for all the new containers in the + * account by default. + * + * @param immutableStorageWithVersioning the immutableStorageWithVersioning value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters + withImmutableStorageWithVersioning(ImmutableStorageAccount immutableStorageWithVersioning) { + this.immutableStorageWithVersioning = immutableStorageWithVersioning; + return this; + } + + /** + * Get the dnsEndpointType property: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create + * a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint + * URL will have an alphanumeric DNS Zone identifier. + * + * @return the dnsEndpointType value. + */ + public DnsEndpointType dnsEndpointType() { + return this.dnsEndpointType; + } + + /** + * Set the dnsEndpointType property: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create + * a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint + * URL will have an alphanumeric DNS Zone identifier. + * + * @param dnsEndpointType the dnsEndpointType value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withDnsEndpointType(DnsEndpointType dnsEndpointType) { + this.dnsEndpointType = dnsEndpointType; + return this; + } + + /** + * Get the geoPriorityReplicationStatus property: Status indicating whether Geo Priority Replication is enabled for + * the account. + * + * @return the geoPriorityReplicationStatus value. + */ + public GeoPriorityReplicationStatus geoPriorityReplicationStatus() { + return this.geoPriorityReplicationStatus; + } + + /** + * Set the geoPriorityReplicationStatus property: Status indicating whether Geo Priority Replication is enabled for + * the account. + * + * @param geoPriorityReplicationStatus the geoPriorityReplicationStatus value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters + withGeoPriorityReplicationStatus(GeoPriorityReplicationStatus geoPriorityReplicationStatus) { + this.geoPriorityReplicationStatus = geoPriorityReplicationStatus; + return this; + } + + /** + * Get the allowSharedKeyAccessForServices property: Indicate shared key access properties at service level. + * + * @return the allowSharedKeyAccessForServices value. + */ + public StorageAccountSharedKeyAccessProperties allowSharedKeyAccessForServices() { + return this.allowSharedKeyAccessForServices; + } + + /** + * Set the allowSharedKeyAccessForServices property: Indicate shared key access properties at service level. + * + * @param allowSharedKeyAccessForServices the allowSharedKeyAccessForServices value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters + withAllowSharedKeyAccessForServices(StorageAccountSharedKeyAccessProperties allowSharedKeyAccessForServices) { + this.allowSharedKeyAccessForServices = allowSharedKeyAccessForServices; + return this; + } + + /** + * Get the dataCollaborationPolicyProperties property: Data Collaboration policy for the storage account. + * + * @return the dataCollaborationPolicyProperties value. + */ + public StorageDataCollaborationPolicyProperties dataCollaborationPolicyProperties() { + return this.dataCollaborationPolicyProperties; + } + + /** + * Set the dataCollaborationPolicyProperties property: Data Collaboration policy for the storage account. + * + * @param dataCollaborationPolicyProperties the dataCollaborationPolicyProperties value to set. + * @return the StorageAccountPropertiesCreateParameters object itself. + */ + public StorageAccountPropertiesCreateParameters withDataCollaborationPolicyProperties( + StorageDataCollaborationPolicyProperties dataCollaborationPolicyProperties) { + this.dataCollaborationPolicyProperties = dataCollaborationPolicyProperties; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (sasPolicy() != null) { + sasPolicy().validate(); + } + if (keyPolicy() != null) { + keyPolicy().validate(); + } + if (customDomain() != null) { + customDomain().validate(); + } + if (encryption() != null) { + encryption().validate(); + } + if (networkRuleSet() != null) { + networkRuleSet().validate(); + } + if (azureFilesIdentityBasedAuthentication() != null) { + azureFilesIdentityBasedAuthentication().validate(); + } + if (routingPreference() != null) { + routingPreference().validate(); + } + if (dualStackEndpointPreference() != null) { + dualStackEndpointPreference().validate(); + } + if (immutableStorageWithVersioning() != null) { + immutableStorageWithVersioning().validate(); + } + if (geoPriorityReplicationStatus() != null) { + geoPriorityReplicationStatus().validate(); + } + if (allowSharedKeyAccessForServices() != null) { + allowSharedKeyAccessForServices().validate(); + } + if (dataCollaborationPolicyProperties() != null) { + dataCollaborationPolicyProperties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("allowedCopyScope", + this.allowedCopyScope == null ? null : this.allowedCopyScope.toString()); + jsonWriter.writeStringField("publicNetworkAccess", + this.publicNetworkAccess == null ? null : this.publicNetworkAccess.toString()); + jsonWriter.writeJsonField("sasPolicy", this.sasPolicy); + jsonWriter.writeJsonField("keyPolicy", this.keyPolicy); + jsonWriter.writeJsonField("customDomain", this.customDomain); + jsonWriter.writeJsonField("encryption", this.encryption); + jsonWriter.writeJsonField("networkAcls", this.networkRuleSet); + jsonWriter.writeStringField("accessTier", this.accessTier == null ? null : this.accessTier.toString()); + jsonWriter.writeJsonField("azureFilesIdentityBasedAuthentication", this.azureFilesIdentityBasedAuthentication); + jsonWriter.writeBooleanField("supportsHttpsTrafficOnly", this.enableHttpsTrafficOnly); + jsonWriter.writeBooleanField("isSftpEnabled", this.isSftpEnabled); + jsonWriter.writeBooleanField("isLocalUserEnabled", this.isLocalUserEnabled); + jsonWriter.writeBooleanField("enableExtendedGroups", this.enableExtendedGroups); + jsonWriter.writeBooleanField("isHnsEnabled", this.isHnsEnabled); + jsonWriter.writeStringField("largeFileSharesState", + this.largeFileSharesState == null ? null : this.largeFileSharesState.toString()); + jsonWriter.writeJsonField("routingPreference", this.routingPreference); + jsonWriter.writeJsonField("dualStackEndpointPreference", this.dualStackEndpointPreference); + jsonWriter.writeBooleanField("allowBlobPublicAccess", this.allowBlobPublicAccess); + jsonWriter.writeStringField("minimumTlsVersion", + this.minimumTlsVersion == null ? null : this.minimumTlsVersion.toString()); + jsonWriter.writeBooleanField("allowSharedKeyAccess", this.allowSharedKeyAccess); + jsonWriter.writeBooleanField("isNfsV3Enabled", this.enableNfsV3); + jsonWriter.writeBooleanField("allowCrossTenantReplication", this.allowCrossTenantReplication); + jsonWriter.writeBooleanField("defaultToOAuthAuthentication", this.defaultToOAuthAuthentication); + jsonWriter.writeJsonField("immutableStorageWithVersioning", this.immutableStorageWithVersioning); + jsonWriter.writeStringField("dnsEndpointType", + this.dnsEndpointType == null ? null : this.dnsEndpointType.toString()); + jsonWriter.writeJsonField("geoPriorityReplicationStatus", this.geoPriorityReplicationStatus); + jsonWriter.writeJsonField("allowSharedKeyAccessForServices", this.allowSharedKeyAccessForServices); + jsonWriter.writeJsonField("dataCollaborationPolicyProperties", this.dataCollaborationPolicyProperties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StorageAccountPropertiesCreateParameters from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StorageAccountPropertiesCreateParameters if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the StorageAccountPropertiesCreateParameters. + */ + public static StorageAccountPropertiesCreateParameters fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StorageAccountPropertiesCreateParameters deserializedStorageAccountPropertiesCreateParameters + = new StorageAccountPropertiesCreateParameters(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("allowedCopyScope".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.allowedCopyScope + = AllowedCopyScope.fromString(reader.getString()); + } else if ("publicNetworkAccess".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.publicNetworkAccess + = PublicNetworkAccess.fromString(reader.getString()); + } else if ("sasPolicy".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.sasPolicy = SasPolicy.fromJson(reader); + } else if ("keyPolicy".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.keyPolicy = KeyPolicy.fromJson(reader); + } else if ("customDomain".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.customDomain = CustomDomain.fromJson(reader); + } else if ("encryption".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.encryption = Encryption.fromJson(reader); + } else if ("networkAcls".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.networkRuleSet + = NetworkRuleSet.fromJson(reader); + } else if ("accessTier".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.accessTier + = AccessTier.fromString(reader.getString()); + } else if ("azureFilesIdentityBasedAuthentication".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.azureFilesIdentityBasedAuthentication + = AzureFilesIdentityBasedAuthentication.fromJson(reader); + } else if ("supportsHttpsTrafficOnly".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.enableHttpsTrafficOnly + = reader.getNullable(JsonReader::getBoolean); + } else if ("isSftpEnabled".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.isSftpEnabled + = reader.getNullable(JsonReader::getBoolean); + } else if ("isLocalUserEnabled".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.isLocalUserEnabled + = reader.getNullable(JsonReader::getBoolean); + } else if ("enableExtendedGroups".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.enableExtendedGroups + = reader.getNullable(JsonReader::getBoolean); + } else if ("isHnsEnabled".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.isHnsEnabled + = reader.getNullable(JsonReader::getBoolean); + } else if ("largeFileSharesState".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.largeFileSharesState + = LargeFileSharesState.fromString(reader.getString()); + } else if ("routingPreference".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.routingPreference + = RoutingPreference.fromJson(reader); + } else if ("dualStackEndpointPreference".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.dualStackEndpointPreference + = DualStackEndpointPreference.fromJson(reader); + } else if ("allowBlobPublicAccess".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.allowBlobPublicAccess + = reader.getNullable(JsonReader::getBoolean); + } else if ("minimumTlsVersion".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.minimumTlsVersion + = MinimumTlsVersion.fromString(reader.getString()); + } else if ("allowSharedKeyAccess".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.allowSharedKeyAccess + = reader.getNullable(JsonReader::getBoolean); + } else if ("isNfsV3Enabled".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.enableNfsV3 + = reader.getNullable(JsonReader::getBoolean); + } else if ("allowCrossTenantReplication".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.allowCrossTenantReplication + = reader.getNullable(JsonReader::getBoolean); + } else if ("defaultToOAuthAuthentication".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.defaultToOAuthAuthentication + = reader.getNullable(JsonReader::getBoolean); + } else if ("immutableStorageWithVersioning".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.immutableStorageWithVersioning + = ImmutableStorageAccount.fromJson(reader); + } else if ("dnsEndpointType".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.dnsEndpointType + = DnsEndpointType.fromString(reader.getString()); + } else if ("geoPriorityReplicationStatus".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.geoPriorityReplicationStatus + = GeoPriorityReplicationStatus.fromJson(reader); + } else if ("allowSharedKeyAccessForServices".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.allowSharedKeyAccessForServices + = StorageAccountSharedKeyAccessProperties.fromJson(reader); + } else if ("dataCollaborationPolicyProperties".equals(fieldName)) { + deserializedStorageAccountPropertiesCreateParameters.dataCollaborationPolicyProperties + = StorageDataCollaborationPolicyProperties.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedStorageAccountPropertiesCreateParameters; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/models/package-info.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/models/package-info.java new file mode 100644 index 0000000000000..a9760b72158c1 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the inner data models for Storage. + * The Azure Storage Management API. + */ +package com.azure.resourcemanager.storage.fluent.models; diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/package-info.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/package-info.java new file mode 100644 index 0000000000000..aea3777d3084f --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/fluent/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the service clients for Storage. + * The Azure Storage Management API. + */ +package com.azure.resourcemanager.storage.fluent; diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/ResourceManagerUtils.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/ResourceManagerUtils.java new file mode 100644 index 0000000000000..cd22d6b479d97 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/ResourceManagerUtils.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.implementation; + +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.util.CoreUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import reactor.core.publisher.Flux; + +final class ResourceManagerUtils { + private ResourceManagerUtils() { + } + + static String getValueFromIdByName(String id, String name) { + if (id == null) { + return null; + } + Iterator itr = Arrays.stream(id.split("/")).iterator(); + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && !part.trim().isEmpty()) { + if (part.equalsIgnoreCase(name)) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + } + return null; + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + if (id == null || pathTemplate == null) { + return null; + } + String parameterNameParentheses = "{" + parameterName + "}"; + List idSegmentsReverted = Arrays.asList(id.split("/")); + List pathSegments = Arrays.asList(pathTemplate.split("/")); + Collections.reverse(idSegmentsReverted); + Iterator idItrReverted = idSegmentsReverted.iterator(); + int pathIndex = pathSegments.size(); + while (idItrReverted.hasNext() && pathIndex > 0) { + String idSegment = idItrReverted.next(); + String pathSegment = pathSegments.get(--pathIndex); + if (!CoreUtils.isNullOrEmpty(idSegment) && !CoreUtils.isNullOrEmpty(pathSegment)) { + if (pathSegment.equalsIgnoreCase(parameterNameParentheses)) { + if (pathIndex == 0 || (pathIndex == 1 && pathSegments.get(0).isEmpty())) { + List segments = new ArrayList<>(); + segments.add(idSegment); + idItrReverted.forEachRemaining(segments::add); + Collections.reverse(segments); + if (!segments.isEmpty() && segments.get(0).isEmpty()) { + segments.remove(0); + } + return String.join("/", segments); + } else { + return idSegment; + } + } + } + } + return null; + } + + static PagedIterable mapPage(PagedIterable pageIterable, Function mapper) { + return new PagedIterableImpl<>(pageIterable, mapper); + } + + private static final class PagedIterableImpl extends PagedIterable { + + private final PagedIterable pagedIterable; + private final Function mapper; + private final Function, PagedResponse> pageMapper; + + private PagedIterableImpl(PagedIterable pagedIterable, Function mapper) { + super(PagedFlux.create(() -> (continuationToken, pageSize) -> Flux + .fromStream(pagedIterable.streamByPage().map(getPageMapper(mapper))))); + this.pagedIterable = pagedIterable; + this.mapper = mapper; + this.pageMapper = getPageMapper(mapper); + } + + private static Function, PagedResponse> getPageMapper(Function mapper) { + return page -> new PagedResponseBase(page.getRequest(), page.getStatusCode(), page.getHeaders(), + page.getElements().stream().map(mapper).collect(Collectors.toList()), page.getContinuationToken(), + null); + } + + @Override + public Stream stream() { + return pagedIterable.stream().map(mapper); + } + + @Override + public Stream> streamByPage() { + return pagedIterable.streamByPage().map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken) { + return pagedIterable.streamByPage(continuationToken).map(pageMapper); + } + + @Override + public Stream> streamByPage(int preferredPageSize) { + return pagedIterable.streamByPage(preferredPageSize).map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken, int preferredPageSize) { + return pagedIterable.streamByPage(continuationToken, preferredPageSize).map(pageMapper); + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(pagedIterable.iterator(), mapper); + } + + @Override + public Iterable> iterableByPage() { + return new IterableImpl<>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken, preferredPageSize), pageMapper); + } + } + + private static final class IteratorImpl implements Iterator { + + private final Iterator iterator; + private final Function mapper; + + private IteratorImpl(Iterator iterator, Function mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public S next() { + return mapper.apply(iterator.next()); + } + + @Override + public void remove() { + iterator.remove(); + } + } + + private static final class IterableImpl implements Iterable { + + private final Iterable iterable; + private final Function mapper; + + private IterableImpl(Iterable iterable, Function mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + @Override + public Iterator iterator() { + return new IteratorImpl<>(iterable.iterator(), mapper); + } + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/ResourceProvidersClientImpl.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/ResourceProvidersClientImpl.java new file mode 100644 index 0000000000000..028d87264eaf6 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/ResourceProvidersClientImpl.java @@ -0,0 +1,346 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.storage.fluent.ResourceProvidersClient; +import com.azure.resourcemanager.storage.fluent.models.StorageAccountInner; +import com.azure.resourcemanager.storage.models.StorageAccountCreateParameters; +import java.nio.ByteBuffer; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in ResourceProvidersClient. + */ +public final class ResourceProvidersClientImpl implements ResourceProvidersClient { + /** + * The proxy service used to perform REST calls. + */ + private final ResourceProvidersService service; + + /** + * The service client containing this operation class. + */ + private final StorageManagementClientImpl client; + + /** + * Initializes an instance of ResourceProvidersClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ResourceProvidersClientImpl(StorageManagementClientImpl client) { + this.service + = RestProxy.create(ResourceProvidersService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for StorageManagementClientResourceProviders to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "StorageManagementClientResourceProviders") + public interface ResourceProvidersService { + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") + @ExpectedResponses({ 200, 202 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> create(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @PathParam("accountName") String accountName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") StorageAccountCreateParameters parameters, Context context); + } + + /** + * Asynchronously creates a new storage account with the specified parameters. If an account is already created and + * a subsequent create request is issued with different properties, the account properties will be updated. If an + * account is already created and a subsequent create or update request is issued with the exact same set of + * properties, the request will succeed. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the storage account within the specified resource group. Storage account names + * must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param parameters The parameters to provide for the created account. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the storage account along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createWithResponseAsync(String resourceGroupName, String accountName, + StorageAccountCreateParameters parameters) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (accountName == null) { + return Mono.error(new IllegalArgumentException("Parameter accountName is required and cannot be null.")); + } + if (parameters == null) { + return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null.")); + } else { + parameters.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil.withContext(context -> service.create(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, accountName, contentType, accept, parameters, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Asynchronously creates a new storage account with the specified parameters. If an account is already created and + * a subsequent create request is issued with different properties, the account properties will be updated. If an + * account is already created and a subsequent create or update request is issued with the exact same set of + * properties, the request will succeed. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the storage account within the specified resource group. Storage account names + * must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param parameters The parameters to provide for the created account. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the storage account along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createWithResponseAsync(String resourceGroupName, String accountName, + StorageAccountCreateParameters parameters, Context context) { + if (this.client.getEndpoint() == null) { + return Mono.error( + new IllegalArgumentException("Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono.error(new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (accountName == null) { + return Mono.error(new IllegalArgumentException("Parameter accountName is required and cannot be null.")); + } + if (parameters == null) { + return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null.")); + } else { + parameters.validate(); + } + final String contentType = "application/json"; + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.create(this.client.getEndpoint(), this.client.getApiVersion(), this.client.getSubscriptionId(), + resourceGroupName, accountName, contentType, accept, parameters, context); + } + + /** + * Asynchronously creates a new storage account with the specified parameters. If an account is already created and + * a subsequent create request is issued with different properties, the account properties will be updated. If an + * account is already created and a subsequent create or update request is issued with the exact same set of + * properties, the request will succeed. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the storage account within the specified resource group. Storage account names + * must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param parameters The parameters to provide for the created account. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of the storage account. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, StorageAccountInner> beginCreateAsync(String resourceGroupName, + String accountName, StorageAccountCreateParameters parameters) { + Mono>> mono = createWithResponseAsync(resourceGroupName, accountName, parameters); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + StorageAccountInner.class, StorageAccountInner.class, this.client.getContext()); + } + + /** + * Asynchronously creates a new storage account with the specified parameters. If an account is already created and + * a subsequent create request is issued with different properties, the account properties will be updated. If an + * account is already created and a subsequent create or update request is issued with the exact same set of + * properties, the request will succeed. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the storage account within the specified resource group. Storage account names + * must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param parameters The parameters to provide for the created account. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link PollerFlux} for polling of the storage account. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, StorageAccountInner> beginCreateAsync(String resourceGroupName, + String accountName, StorageAccountCreateParameters parameters, Context context) { + context = this.client.mergeContext(context); + Mono>> mono + = createWithResponseAsync(resourceGroupName, accountName, parameters, context); + return this.client.getLroResult(mono, this.client.getHttpPipeline(), + StorageAccountInner.class, StorageAccountInner.class, context); + } + + /** + * Asynchronously creates a new storage account with the specified parameters. If an account is already created and + * a subsequent create request is issued with different properties, the account properties will be updated. If an + * account is already created and a subsequent create or update request is issued with the exact same set of + * properties, the request will succeed. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the storage account within the specified resource group. Storage account names + * must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param parameters The parameters to provide for the created account. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of the storage account. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, StorageAccountInner> beginCreate(String resourceGroupName, + String accountName, StorageAccountCreateParameters parameters) { + return this.beginCreateAsync(resourceGroupName, accountName, parameters).getSyncPoller(); + } + + /** + * Asynchronously creates a new storage account with the specified parameters. If an account is already created and + * a subsequent create request is issued with different properties, the account properties will be updated. If an + * account is already created and a subsequent create or update request is issued with the exact same set of + * properties, the request will succeed. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the storage account within the specified resource group. Storage account names + * must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param parameters The parameters to provide for the created account. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link SyncPoller} for polling of the storage account. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, StorageAccountInner> beginCreate(String resourceGroupName, + String accountName, StorageAccountCreateParameters parameters, Context context) { + return this.beginCreateAsync(resourceGroupName, accountName, parameters, context).getSyncPoller(); + } + + /** + * Asynchronously creates a new storage account with the specified parameters. If an account is already created and + * a subsequent create request is issued with different properties, the account properties will be updated. If an + * account is already created and a subsequent create or update request is issued with the exact same set of + * properties, the request will succeed. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the storage account within the specified resource group. Storage account names + * must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param parameters The parameters to provide for the created account. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the storage account on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createAsync(String resourceGroupName, String accountName, + StorageAccountCreateParameters parameters) { + return beginCreateAsync(resourceGroupName, accountName, parameters).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Asynchronously creates a new storage account with the specified parameters. If an account is already created and + * a subsequent create request is issued with different properties, the account properties will be updated. If an + * account is already created and a subsequent create or update request is issued with the exact same set of + * properties, the request will succeed. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the storage account within the specified resource group. Storage account names + * must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param parameters The parameters to provide for the created account. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the storage account on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createAsync(String resourceGroupName, String accountName, + StorageAccountCreateParameters parameters, Context context) { + return beginCreateAsync(resourceGroupName, accountName, parameters, context).last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Asynchronously creates a new storage account with the specified parameters. If an account is already created and + * a subsequent create request is issued with different properties, the account properties will be updated. If an + * account is already created and a subsequent create or update request is issued with the exact same set of + * properties, the request will succeed. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the storage account within the specified resource group. Storage account names + * must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param parameters The parameters to provide for the created account. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the storage account. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public StorageAccountInner create(String resourceGroupName, String accountName, + StorageAccountCreateParameters parameters) { + return createAsync(resourceGroupName, accountName, parameters).block(); + } + + /** + * Asynchronously creates a new storage account with the specified parameters. If an account is already created and + * a subsequent create request is issued with different properties, the account properties will be updated. If an + * account is already created and a subsequent create or update request is issued with the exact same set of + * properties, the request will succeed. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param accountName The name of the storage account within the specified resource group. Storage account names + * must be between 3 and 24 characters in length and use numbers and lower-case letters only. + * @param parameters The parameters to provide for the created account. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the storage account. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public StorageAccountInner create(String resourceGroupName, String accountName, + StorageAccountCreateParameters parameters, Context context) { + return createAsync(resourceGroupName, accountName, parameters, context).block(); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/ResourceProvidersImpl.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/ResourceProvidersImpl.java new file mode 100644 index 0000000000000..3eb1c7f0b7d6e --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/ResourceProvidersImpl.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.implementation; + +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.storage.fluent.ResourceProvidersClient; +import com.azure.resourcemanager.storage.models.ResourceProviders; + +public final class ResourceProvidersImpl implements ResourceProviders { + private static final ClientLogger LOGGER = new ClientLogger(ResourceProvidersImpl.class); + + private final ResourceProvidersClient innerClient; + + private final com.azure.resourcemanager.storage.StorageManager serviceManager; + + public ResourceProvidersImpl(ResourceProvidersClient innerClient, + com.azure.resourcemanager.storage.StorageManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + private ResourceProvidersClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.storage.StorageManager manager() { + return this.serviceManager; + } + + public StorageAccountImpl define(String name) { + return new StorageAccountImpl(name, this.manager()); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/StorageAccountImpl.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/StorageAccountImpl.java new file mode 100644 index 0000000000000..a7139655e9807 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/StorageAccountImpl.java @@ -0,0 +1,540 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.implementation; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.storage.fluent.models.StorageAccountInner; +import com.azure.resourcemanager.storage.models.AccessTier; +import com.azure.resourcemanager.storage.models.AccountStatus; +import com.azure.resourcemanager.storage.models.AllowedCopyScope; +import com.azure.resourcemanager.storage.models.AzureFilesIdentityBasedAuthentication; +import com.azure.resourcemanager.storage.models.BlobRestoreStatus; +import com.azure.resourcemanager.storage.models.CustomDomain; +import com.azure.resourcemanager.storage.models.DnsEndpointType; +import com.azure.resourcemanager.storage.models.DualStackEndpointPreference; +import com.azure.resourcemanager.storage.models.Encryption; +import com.azure.resourcemanager.storage.models.Endpoints; +import com.azure.resourcemanager.storage.models.ExtendedLocation; +import com.azure.resourcemanager.storage.models.GeoPriorityReplicationStatus; +import com.azure.resourcemanager.storage.models.GeoReplicationStats; +import com.azure.resourcemanager.storage.models.Identity; +import com.azure.resourcemanager.storage.models.ImmutableStorageAccount; +import com.azure.resourcemanager.storage.models.KeyCreationTime; +import com.azure.resourcemanager.storage.models.KeyPolicy; +import com.azure.resourcemanager.storage.models.Kind; +import com.azure.resourcemanager.storage.models.LargeFileSharesState; +import com.azure.resourcemanager.storage.models.MinimumTlsVersion; +import com.azure.resourcemanager.storage.models.NetworkRuleSet; +import com.azure.resourcemanager.storage.models.Placement; +import com.azure.resourcemanager.storage.models.PrivateEndpointConnection; +import com.azure.resourcemanager.storage.models.ProvisioningState; +import com.azure.resourcemanager.storage.models.PublicNetworkAccess; +import com.azure.resourcemanager.storage.models.RoutingPreference; +import com.azure.resourcemanager.storage.models.SasPolicy; +import com.azure.resourcemanager.storage.models.Sku; +import com.azure.resourcemanager.storage.models.StorageAccount; +import com.azure.resourcemanager.storage.models.StorageAccountCreateParameters; +import com.azure.resourcemanager.storage.models.StorageAccountSharedKeyAccessProperties; +import com.azure.resourcemanager.storage.models.StorageAccountSkuConversionStatus; +import com.azure.resourcemanager.storage.models.StorageDataCollaborationPolicyProperties; +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +public final class StorageAccountImpl implements StorageAccount, StorageAccount.Definition { + private StorageAccountInner innerObject; + + private final com.azure.resourcemanager.storage.StorageManager serviceManager; + + StorageAccountImpl(StorageAccountInner innerObject, + com.azure.resourcemanager.storage.StorageManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public String location() { + return this.innerModel().location(); + } + + public Map tags() { + Map inner = this.innerModel().tags(); + if (inner != null) { + return Collections.unmodifiableMap(inner); + } else { + return Collections.emptyMap(); + } + } + + public Sku sku() { + return this.innerModel().sku(); + } + + public Kind kind() { + return this.innerModel().kind(); + } + + public Identity identity() { + return this.innerModel().identity(); + } + + public ExtendedLocation extendedLocation() { + return this.innerModel().extendedLocation(); + } + + public List zones() { + List inner = this.innerModel().zones(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public Placement placement() { + return this.innerModel().placement(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public ProvisioningState provisioningState() { + return this.innerModel().provisioningState(); + } + + public Endpoints primaryEndpoints() { + return this.innerModel().primaryEndpoints(); + } + + public String primaryLocation() { + return this.innerModel().primaryLocation(); + } + + public AccountStatus statusOfPrimary() { + return this.innerModel().statusOfPrimary(); + } + + public OffsetDateTime lastGeoFailoverTime() { + return this.innerModel().lastGeoFailoverTime(); + } + + public String secondaryLocation() { + return this.innerModel().secondaryLocation(); + } + + public AccountStatus statusOfSecondary() { + return this.innerModel().statusOfSecondary(); + } + + public OffsetDateTime creationTime() { + return this.innerModel().creationTime(); + } + + public CustomDomain customDomain() { + return this.innerModel().customDomain(); + } + + public SasPolicy sasPolicy() { + return this.innerModel().sasPolicy(); + } + + public KeyPolicy keyPolicy() { + return this.innerModel().keyPolicy(); + } + + public KeyCreationTime keyCreationTime() { + return this.innerModel().keyCreationTime(); + } + + public Endpoints secondaryEndpoints() { + return this.innerModel().secondaryEndpoints(); + } + + public Encryption encryption() { + return this.innerModel().encryption(); + } + + public AccessTier accessTier() { + return this.innerModel().accessTier(); + } + + public AzureFilesIdentityBasedAuthentication azureFilesIdentityBasedAuthentication() { + return this.innerModel().azureFilesIdentityBasedAuthentication(); + } + + public Boolean enableHttpsTrafficOnly() { + return this.innerModel().enableHttpsTrafficOnly(); + } + + public NetworkRuleSet networkRuleSet() { + return this.innerModel().networkRuleSet(); + } + + public Boolean isSftpEnabled() { + return this.innerModel().isSftpEnabled(); + } + + public Boolean isLocalUserEnabled() { + return this.innerModel().isLocalUserEnabled(); + } + + public Boolean enableExtendedGroups() { + return this.innerModel().enableExtendedGroups(); + } + + public Boolean isHnsEnabled() { + return this.innerModel().isHnsEnabled(); + } + + public GeoReplicationStats geoReplicationStats() { + return this.innerModel().geoReplicationStats(); + } + + public Boolean failoverInProgress() { + return this.innerModel().failoverInProgress(); + } + + public LargeFileSharesState largeFileSharesState() { + return this.innerModel().largeFileSharesState(); + } + + public List privateEndpointConnections() { + List inner = this.innerModel().privateEndpointConnections(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public RoutingPreference routingPreference() { + return this.innerModel().routingPreference(); + } + + public DualStackEndpointPreference dualStackEndpointPreference() { + return this.innerModel().dualStackEndpointPreference(); + } + + public BlobRestoreStatus blobRestoreStatus() { + return this.innerModel().blobRestoreStatus(); + } + + public Boolean allowBlobPublicAccess() { + return this.innerModel().allowBlobPublicAccess(); + } + + public MinimumTlsVersion minimumTlsVersion() { + return this.innerModel().minimumTlsVersion(); + } + + public Boolean allowSharedKeyAccess() { + return this.innerModel().allowSharedKeyAccess(); + } + + public Boolean enableNfsV3() { + return this.innerModel().enableNfsV3(); + } + + public Boolean allowCrossTenantReplication() { + return this.innerModel().allowCrossTenantReplication(); + } + + public Boolean defaultToOAuthAuthentication() { + return this.innerModel().defaultToOAuthAuthentication(); + } + + public PublicNetworkAccess publicNetworkAccess() { + return this.innerModel().publicNetworkAccess(); + } + + public ImmutableStorageAccount immutableStorageWithVersioning() { + return this.innerModel().immutableStorageWithVersioning(); + } + + public AllowedCopyScope allowedCopyScope() { + return this.innerModel().allowedCopyScope(); + } + + public StorageAccountSkuConversionStatus storageAccountSkuConversionStatus() { + return this.innerModel().storageAccountSkuConversionStatus(); + } + + public DnsEndpointType dnsEndpointType() { + return this.innerModel().dnsEndpointType(); + } + + public Boolean isSkuConversionBlocked() { + return this.innerModel().isSkuConversionBlocked(); + } + + public Boolean accountMigrationInProgress() { + return this.innerModel().accountMigrationInProgress(); + } + + public GeoPriorityReplicationStatus geoPriorityReplicationStatus() { + return this.innerModel().geoPriorityReplicationStatus(); + } + + public StorageAccountSharedKeyAccessProperties allowSharedKeyAccessForServices() { + return this.innerModel().allowSharedKeyAccessForServices(); + } + + public StorageDataCollaborationPolicyProperties dataCollaborationPolicyProperties() { + return this.innerModel().dataCollaborationPolicyProperties(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public StorageAccountInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.storage.StorageManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String accountName; + + private StorageAccountCreateParameters createParameters; + + public StorageAccountImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public StorageAccount create() { + this.innerObject = serviceManager.serviceClient() + .getResourceProviders() + .create(resourceGroupName, accountName, createParameters, Context.NONE); + return this; + } + + public StorageAccount create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getResourceProviders() + .create(resourceGroupName, accountName, createParameters, context); + return this; + } + + StorageAccountImpl(String name, com.azure.resourcemanager.storage.StorageManager serviceManager) { + this.innerObject = new StorageAccountInner(); + this.serviceManager = serviceManager; + this.accountName = name; + this.createParameters = new StorageAccountCreateParameters(); + } + + public StorageAccountImpl withRegion(Region location) { + this.createParameters.withLocation(location.toString()); + return this; + } + + public StorageAccountImpl withRegion(String location) { + this.createParameters.withLocation(location); + return this; + } + + public StorageAccountImpl withSku(Sku sku) { + this.createParameters.withSku(sku); + return this; + } + + public StorageAccountImpl withKind(Kind kind) { + this.createParameters.withKind(kind); + return this; + } + + public StorageAccountImpl withTags(Map tags) { + this.createParameters.withTags(tags); + return this; + } + + public StorageAccountImpl withExtendedLocation(ExtendedLocation extendedLocation) { + this.createParameters.withExtendedLocation(extendedLocation); + return this; + } + + public StorageAccountImpl withZones(List zones) { + this.createParameters.withZones(zones); + return this; + } + + public StorageAccountImpl withPlacement(Placement placement) { + this.createParameters.withPlacement(placement); + return this; + } + + public StorageAccountImpl withIdentity(Identity identity) { + this.createParameters.withIdentity(identity); + return this; + } + + public StorageAccountImpl withAllowedCopyScope(AllowedCopyScope allowedCopyScope) { + this.createParameters.withAllowedCopyScope(allowedCopyScope); + return this; + } + + public StorageAccountImpl withPublicNetworkAccess(PublicNetworkAccess publicNetworkAccess) { + this.createParameters.withPublicNetworkAccess(publicNetworkAccess); + return this; + } + + public StorageAccountImpl withSasPolicy(SasPolicy sasPolicy) { + this.createParameters.withSasPolicy(sasPolicy); + return this; + } + + public StorageAccountImpl withKeyPolicy(KeyPolicy keyPolicy) { + this.createParameters.withKeyPolicy(keyPolicy); + return this; + } + + public StorageAccountImpl withCustomDomain(CustomDomain customDomain) { + this.createParameters.withCustomDomain(customDomain); + return this; + } + + public StorageAccountImpl withEncryption(Encryption encryption) { + this.createParameters.withEncryption(encryption); + return this; + } + + public StorageAccountImpl withNetworkRuleSet(NetworkRuleSet networkRuleSet) { + this.createParameters.withNetworkRuleSet(networkRuleSet); + return this; + } + + public StorageAccountImpl withAccessTier(AccessTier accessTier) { + this.createParameters.withAccessTier(accessTier); + return this; + } + + public StorageAccountImpl withAzureFilesIdentityBasedAuthentication( + AzureFilesIdentityBasedAuthentication azureFilesIdentityBasedAuthentication) { + this.createParameters.withAzureFilesIdentityBasedAuthentication(azureFilesIdentityBasedAuthentication); + return this; + } + + public StorageAccountImpl withEnableHttpsTrafficOnly(Boolean enableHttpsTrafficOnly) { + this.createParameters.withEnableHttpsTrafficOnly(enableHttpsTrafficOnly); + return this; + } + + public StorageAccountImpl withIsSftpEnabled(Boolean isSftpEnabled) { + this.createParameters.withIsSftpEnabled(isSftpEnabled); + return this; + } + + public StorageAccountImpl withIsLocalUserEnabled(Boolean isLocalUserEnabled) { + this.createParameters.withIsLocalUserEnabled(isLocalUserEnabled); + return this; + } + + public StorageAccountImpl withEnableExtendedGroups(Boolean enableExtendedGroups) { + this.createParameters.withEnableExtendedGroups(enableExtendedGroups); + return this; + } + + public StorageAccountImpl withIsHnsEnabled(Boolean isHnsEnabled) { + this.createParameters.withIsHnsEnabled(isHnsEnabled); + return this; + } + + public StorageAccountImpl withLargeFileSharesState(LargeFileSharesState largeFileSharesState) { + this.createParameters.withLargeFileSharesState(largeFileSharesState); + return this; + } + + public StorageAccountImpl withRoutingPreference(RoutingPreference routingPreference) { + this.createParameters.withRoutingPreference(routingPreference); + return this; + } + + public StorageAccountImpl withDualStackEndpointPreference(DualStackEndpointPreference dualStackEndpointPreference) { + this.createParameters.withDualStackEndpointPreference(dualStackEndpointPreference); + return this; + } + + public StorageAccountImpl withAllowBlobPublicAccess(Boolean allowBlobPublicAccess) { + this.createParameters.withAllowBlobPublicAccess(allowBlobPublicAccess); + return this; + } + + public StorageAccountImpl withMinimumTlsVersion(MinimumTlsVersion minimumTlsVersion) { + this.createParameters.withMinimumTlsVersion(minimumTlsVersion); + return this; + } + + public StorageAccountImpl withAllowSharedKeyAccess(Boolean allowSharedKeyAccess) { + this.createParameters.withAllowSharedKeyAccess(allowSharedKeyAccess); + return this; + } + + public StorageAccountImpl withEnableNfsV3(Boolean enableNfsV3) { + this.createParameters.withEnableNfsV3(enableNfsV3); + return this; + } + + public StorageAccountImpl withAllowCrossTenantReplication(Boolean allowCrossTenantReplication) { + this.createParameters.withAllowCrossTenantReplication(allowCrossTenantReplication); + return this; + } + + public StorageAccountImpl withDefaultToOAuthAuthentication(Boolean defaultToOAuthAuthentication) { + this.createParameters.withDefaultToOAuthAuthentication(defaultToOAuthAuthentication); + return this; + } + + public StorageAccountImpl + withImmutableStorageWithVersioning(ImmutableStorageAccount immutableStorageWithVersioning) { + this.createParameters.withImmutableStorageWithVersioning(immutableStorageWithVersioning); + return this; + } + + public StorageAccountImpl withDnsEndpointType(DnsEndpointType dnsEndpointType) { + this.createParameters.withDnsEndpointType(dnsEndpointType); + return this; + } + + public StorageAccountImpl + withGeoPriorityReplicationStatus(GeoPriorityReplicationStatus geoPriorityReplicationStatus) { + this.createParameters.withGeoPriorityReplicationStatus(geoPriorityReplicationStatus); + return this; + } + + public StorageAccountImpl + withAllowSharedKeyAccessForServices(StorageAccountSharedKeyAccessProperties allowSharedKeyAccessForServices) { + this.createParameters.withAllowSharedKeyAccessForServices(allowSharedKeyAccessForServices); + return this; + } + + public StorageAccountImpl withDataCollaborationPolicyProperties( + StorageDataCollaborationPolicyProperties dataCollaborationPolicyProperties) { + this.createParameters.withDataCollaborationPolicyProperties(dataCollaborationPolicyProperties); + return this; + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/StorageManagementClientBuilder.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/StorageManagementClientBuilder.java new file mode 100644 index 0000000000000..e65d7359aa338 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/StorageManagementClientBuilder.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.implementation; + +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerAdapter; +import java.time.Duration; + +/** + * A builder for creating a new instance of the StorageManagementClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { StorageManagementClientImpl.class }) +public final class StorageManagementClientBuilder { + /* + * Service host + */ + private String endpoint; + + /** + * Sets Service host. + * + * @param endpoint the endpoint value. + * @return the StorageManagementClientBuilder. + */ + public StorageManagementClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The ID of the target subscription. The value must be an UUID. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. The value must be an UUID. + * + * @param subscriptionId the subscriptionId value. + * @return the StorageManagementClientBuilder. + */ + public StorageManagementClientBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the StorageManagementClientBuilder. + */ + public StorageManagementClientBuilder environment(AzureEnvironment environment) { + this.environment = environment; + 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 StorageManagementClientBuilder. + */ + public StorageManagementClientBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /* + * The default poll interval for long-running operation + */ + private Duration defaultPollInterval; + + /** + * Sets The default poll interval for long-running operation. + * + * @param defaultPollInterval the defaultPollInterval value. + * @return the StorageManagementClientBuilder. + */ + public StorageManagementClientBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + return this; + } + + /* + * The serializer to serialize an object into a string + */ + private SerializerAdapter serializerAdapter; + + /** + * Sets The serializer to serialize an object into a string. + * + * @param serializerAdapter the serializerAdapter value. + * @return the StorageManagementClientBuilder. + */ + public StorageManagementClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of StorageManagementClientImpl with the provided parameters. + * + * @return an instance of StorageManagementClientImpl. + */ + public StorageManagementClientImpl buildClient() { + String localEndpoint = (endpoint != null) ? endpoint : "https://management.azure.com"; + AzureEnvironment localEnvironment = (environment != null) ? environment : AzureEnvironment.AZURE; + HttpPipeline localPipeline = (pipeline != null) + ? pipeline + : new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(); + Duration localDefaultPollInterval + = (defaultPollInterval != null) ? defaultPollInterval : Duration.ofSeconds(30); + SerializerAdapter localSerializerAdapter = (serializerAdapter != null) + ? serializerAdapter + : SerializerFactory.createDefaultManagementSerializerAdapter(); + StorageManagementClientImpl client = new StorageManagementClientImpl(localPipeline, localSerializerAdapter, + localDefaultPollInterval, localEnvironment, localEndpoint, this.subscriptionId); + return client; + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/StorageManagementClientImpl.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/StorageManagementClientImpl.java new file mode 100644 index 0000000000000..44557d4a4c4ad --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/StorageManagementClientImpl.java @@ -0,0 +1,289 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.implementation; + +import com.azure.core.annotation.ServiceClient; +import com.azure.core.http.HttpHeaderName; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.rest.Response; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.exception.ManagementError; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.management.polling.PollerFactory; +import com.azure.core.util.Context; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.storage.fluent.ResourceProvidersClient; +import com.azure.resourcemanager.storage.fluent.StorageManagementClient; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the StorageManagementClientImpl type. + */ +@ServiceClient(builder = StorageManagementClientBuilder.class) +public final class StorageManagementClientImpl implements StorageManagementClient { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Version parameter. + */ + private final String apiVersion; + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** + * The ID of the target subscription. The value must be an UUID. + */ + private final String subscriptionId; + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * The default poll interval for long-running operation. + */ + private final Duration defaultPollInterval; + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + public Duration getDefaultPollInterval() { + return this.defaultPollInterval; + } + + /** + * The ResourceProvidersClient object to access its operations. + */ + private final ResourceProvidersClient resourceProviders; + + /** + * Gets the ResourceProvidersClient object to access its operations. + * + * @return the ResourceProvidersClient object. + */ + public ResourceProvidersClient getResourceProviders() { + return this.resourceProviders; + } + + /** + * Initializes an instance of StorageManagementClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param defaultPollInterval The default poll interval for long-running operation. + * @param environment The Azure environment. + * @param endpoint Service host. + * @param subscriptionId The ID of the target subscription. The value must be an UUID. + */ + StorageManagementClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + Duration defaultPollInterval, AzureEnvironment environment, String endpoint, String subscriptionId) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.subscriptionId = subscriptionId; + this.apiVersion = "2026-04-01"; + this.resourceProviders = new ResourceProvidersClientImpl(this); + } + + /** + * Gets default client context. + * + * @return the default client context. + */ + public Context getContext() { + return Context.NONE; + } + + /** + * Merges default client context with provided context. + * + * @param context the context to be merged with default client context. + * @return the merged context. + */ + public Context mergeContext(Context context) { + return CoreUtils.mergeContexts(this.getContext(), context); + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param httpPipeline the http pipeline. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return poller flux for poll result and final result. + */ + public PollerFlux, U> getLroResult(Mono>> activationResponse, + HttpPipeline httpPipeline, Type pollResultType, Type finalResultType, Context context) { + return PollerFactory.create(serializerAdapter, httpPipeline, pollResultType, finalResultType, + defaultPollInterval, activationResponse, context); + } + + /** + * Gets the final result, or an error, based on last async poll response. + * + * @param response the last async poll response. + * @param type of poll result. + * @param type of final result. + * @return the final result, or an error. + */ + public Mono getLroFinalResultOrError(AsyncPollResponse, U> response) { + if (response.getStatus() != LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + String errorMessage; + ManagementError managementError = null; + HttpResponse errorResponse = null; + PollResult.Error lroError = response.getValue().getError(); + if (lroError != null) { + errorResponse = new HttpResponseImpl(lroError.getResponseStatusCode(), lroError.getResponseHeaders(), + lroError.getResponseBody()); + + errorMessage = response.getValue().getError().getMessage(); + String errorBody = response.getValue().getError().getResponseBody(); + if (errorBody != null) { + // try to deserialize error body to ManagementError + try { + managementError = this.getSerializerAdapter() + .deserialize(errorBody, ManagementError.class, SerializerEncoding.JSON); + if (managementError.getCode() == null || managementError.getMessage() == null) { + managementError = null; + } + } catch (IOException | RuntimeException ioe) { + LOGGER.logThrowableAsWarning(ioe); + } + } + } else { + // fallback to default error message + errorMessage = "Long running operation failed."; + } + if (managementError == null) { + // fallback to default ManagementError + managementError = new ManagementError(response.getStatus().toString(), errorMessage); + } + return Mono.error(new ManagementException(errorMessage, errorResponse, managementError)); + } else { + return response.getFinalResult(); + } + } + + private static final class HttpResponseImpl extends HttpResponse { + private final int statusCode; + + private final byte[] responseBody; + + private final HttpHeaders httpHeaders; + + HttpResponseImpl(int statusCode, HttpHeaders httpHeaders, String responseBody) { + super(null); + this.statusCode = statusCode; + this.httpHeaders = httpHeaders; + this.responseBody = responseBody == null ? new byte[0] : responseBody.getBytes(StandardCharsets.UTF_8); + } + + public int getStatusCode() { + return statusCode; + } + + @SuppressWarnings("deprecation") + public String getHeaderValue(String s) { + return httpHeaders.getValue(HttpHeaderName.fromString(s)); + } + + public HttpHeaders getHeaders() { + return httpHeaders; + } + + public Flux getBody() { + return Flux.just(ByteBuffer.wrap(responseBody)); + } + + public Mono getBodyAsByteArray() { + return Mono.just(responseBody); + } + + public Mono getBodyAsString() { + return Mono.just(new String(responseBody, StandardCharsets.UTF_8)); + } + + public Mono getBodyAsString(Charset charset) { + return Mono.just(new String(responseBody, charset)); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(StorageManagementClientImpl.class); +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/package-info.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/package-info.java new file mode 100644 index 0000000000000..d4b4b64696777 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/implementation/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Storage. + * The Azure Storage Management API. + */ +package com.azure.resourcemanager.storage.implementation; diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/AccessTier.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/AccessTier.java new file mode 100644 index 0000000000000..91f891473a0e1 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/AccessTier.java @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +/** + * The default access tier for block blobs in the storage account. Required for storage accounts where kind = + * BlobStorage. See more details in: https://learn.microsoft.com/azure/storage/blobs/access-tiers-overview. + */ +public enum AccessTier { + /** + * Enum value Hot. + */ + HOT("Hot"), + + /** + * Enum value Cool. + */ + COOL("Cool"), + + /** + * Enum value Premium. + */ + PREMIUM("Premium"), + + /** + * Enum value Cold. + */ + COLD("Cold"), + + /** + * Enum value Smart. + */ + SMART("Smart"); + + /** + * The actual serialized value for a AccessTier instance. + */ + private final String value; + + AccessTier(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a AccessTier instance. + * + * @param value the serialized value to parse. + * @return the parsed AccessTier object, or null if unable to parse. + */ + public static AccessTier fromString(String value) { + if (value == null) { + return null; + } + AccessTier[] items = AccessTier.values(); + for (AccessTier item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/AccountImmutabilityPolicyProperties.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/AccountImmutabilityPolicyProperties.java new file mode 100644 index 0000000000000..8f6194aad871c --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/AccountImmutabilityPolicyProperties.java @@ -0,0 +1,178 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * This defines account-level immutability policy properties. + */ +@Fluent +public final class AccountImmutabilityPolicyProperties + implements JsonSerializable { + /* + * The immutability period for the blobs in the container since the policy creation, in days. + */ + private Integer immutabilityPeriodSinceCreationInDays; + + /* + * The ImmutabilityPolicy state defines the mode of the policy. Disabled state disables the policy, Unlocked state + * allows increase and decrease of immutability retention time and also allows toggling allowProtectedAppendWrites + * property, Locked state only allows the increase of the immutability retention time. A policy can only be created + * in a Disabled or Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state can + * transition to a Locked state which cannot be reverted. + */ + private AccountImmutabilityPolicyState state; + + /* + * This property can only be changed for disabled and unlocked time-based retention policies. When enabled, new + * blocks can be written to an append blob while maintaining immutability protection and compliance. Only new blocks + * can be added and any existing blocks cannot be modified or deleted. + */ + private Boolean allowProtectedAppendWrites; + + /** + * Creates an instance of AccountImmutabilityPolicyProperties class. + */ + public AccountImmutabilityPolicyProperties() { + } + + /** + * Get the immutabilityPeriodSinceCreationInDays property: The immutability period for the blobs in the container + * since the policy creation, in days. + * + * @return the immutabilityPeriodSinceCreationInDays value. + */ + public Integer immutabilityPeriodSinceCreationInDays() { + return this.immutabilityPeriodSinceCreationInDays; + } + + /** + * Set the immutabilityPeriodSinceCreationInDays property: The immutability period for the blobs in the container + * since the policy creation, in days. + * + * @param immutabilityPeriodSinceCreationInDays the immutabilityPeriodSinceCreationInDays value to set. + * @return the AccountImmutabilityPolicyProperties object itself. + */ + public AccountImmutabilityPolicyProperties + withImmutabilityPeriodSinceCreationInDays(Integer immutabilityPeriodSinceCreationInDays) { + this.immutabilityPeriodSinceCreationInDays = immutabilityPeriodSinceCreationInDays; + return this; + } + + /** + * Get the state property: The ImmutabilityPolicy state defines the mode of the policy. Disabled state disables the + * policy, Unlocked state allows increase and decrease of immutability retention time and also allows toggling + * allowProtectedAppendWrites property, Locked state only allows the increase of the immutability retention time. A + * policy can only be created in a Disabled or Unlocked state and can be toggled between the two states. Only a + * policy in an Unlocked state can transition to a Locked state which cannot be reverted. + * + * @return the state value. + */ + public AccountImmutabilityPolicyState state() { + return this.state; + } + + /** + * Set the state property: The ImmutabilityPolicy state defines the mode of the policy. Disabled state disables the + * policy, Unlocked state allows increase and decrease of immutability retention time and also allows toggling + * allowProtectedAppendWrites property, Locked state only allows the increase of the immutability retention time. A + * policy can only be created in a Disabled or Unlocked state and can be toggled between the two states. Only a + * policy in an Unlocked state can transition to a Locked state which cannot be reverted. + * + * @param state the state value to set. + * @return the AccountImmutabilityPolicyProperties object itself. + */ + public AccountImmutabilityPolicyProperties withState(AccountImmutabilityPolicyState state) { + this.state = state; + return this; + } + + /** + * Get the allowProtectedAppendWrites property: This property can only be changed for disabled and unlocked + * time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining + * immutability protection and compliance. Only new blocks can be added and any existing blocks cannot be modified + * or deleted. + * + * @return the allowProtectedAppendWrites value. + */ + public Boolean allowProtectedAppendWrites() { + return this.allowProtectedAppendWrites; + } + + /** + * Set the allowProtectedAppendWrites property: This property can only be changed for disabled and unlocked + * time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining + * immutability protection and compliance. Only new blocks can be added and any existing blocks cannot be modified + * or deleted. + * + * @param allowProtectedAppendWrites the allowProtectedAppendWrites value to set. + * @return the AccountImmutabilityPolicyProperties object itself. + */ + public AccountImmutabilityPolicyProperties withAllowProtectedAppendWrites(Boolean allowProtectedAppendWrites) { + this.allowProtectedAppendWrites = allowProtectedAppendWrites; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("immutabilityPeriodSinceCreationInDays", + this.immutabilityPeriodSinceCreationInDays); + jsonWriter.writeStringField("state", this.state == null ? null : this.state.toString()); + jsonWriter.writeBooleanField("allowProtectedAppendWrites", this.allowProtectedAppendWrites); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AccountImmutabilityPolicyProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AccountImmutabilityPolicyProperties if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the AccountImmutabilityPolicyProperties. + */ + public static AccountImmutabilityPolicyProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AccountImmutabilityPolicyProperties deserializedAccountImmutabilityPolicyProperties + = new AccountImmutabilityPolicyProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("immutabilityPeriodSinceCreationInDays".equals(fieldName)) { + deserializedAccountImmutabilityPolicyProperties.immutabilityPeriodSinceCreationInDays + = reader.getNullable(JsonReader::getInt); + } else if ("state".equals(fieldName)) { + deserializedAccountImmutabilityPolicyProperties.state + = AccountImmutabilityPolicyState.fromString(reader.getString()); + } else if ("allowProtectedAppendWrites".equals(fieldName)) { + deserializedAccountImmutabilityPolicyProperties.allowProtectedAppendWrites + = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + + return deserializedAccountImmutabilityPolicyProperties; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/AccountImmutabilityPolicyState.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/AccountImmutabilityPolicyState.java new file mode 100644 index 0000000000000..affcfb85d12ab --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/AccountImmutabilityPolicyState.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The ImmutabilityPolicy state defines the mode of the policy. Disabled state disables the policy, Unlocked state + * allows increase and decrease of immutability retention time and also allows toggling allowProtectedAppendWrites + * property, Locked state only allows the increase of the immutability retention time. A policy can only be created in a + * Disabled or Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state can + * transition to a Locked state which cannot be reverted. + */ +public final class AccountImmutabilityPolicyState extends ExpandableStringEnum { + /** + * Static value Unlocked for AccountImmutabilityPolicyState. + */ + public static final AccountImmutabilityPolicyState UNLOCKED = fromString("Unlocked"); + + /** + * Static value Locked for AccountImmutabilityPolicyState. + */ + public static final AccountImmutabilityPolicyState LOCKED = fromString("Locked"); + + /** + * Static value Disabled for AccountImmutabilityPolicyState. + */ + public static final AccountImmutabilityPolicyState DISABLED = fromString("Disabled"); + + /** + * Creates a new instance of AccountImmutabilityPolicyState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public AccountImmutabilityPolicyState() { + } + + /** + * Creates or finds a AccountImmutabilityPolicyState from its string representation. + * + * @param name a name to look for. + * @return the corresponding AccountImmutabilityPolicyState. + */ + public static AccountImmutabilityPolicyState fromString(String name) { + return fromString(name, AccountImmutabilityPolicyState.class); + } + + /** + * Gets known AccountImmutabilityPolicyState values. + * + * @return known AccountImmutabilityPolicyState values. + */ + public static Collection values() { + return values(AccountImmutabilityPolicyState.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/AccountStatus.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/AccountStatus.java new file mode 100644 index 0000000000000..305dbb627025d --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/AccountStatus.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +/** + * Gets the status indicating whether the primary location of the storage account is available or unavailable. + */ +public enum AccountStatus { + /** + * Enum value available. + */ + AVAILABLE("available"), + + /** + * Enum value unavailable. + */ + UNAVAILABLE("unavailable"); + + /** + * The actual serialized value for a AccountStatus instance. + */ + private final String value; + + AccountStatus(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a AccountStatus instance. + * + * @param value the serialized value to parse. + * @return the parsed AccountStatus object, or null if unable to parse. + */ + public static AccountStatus fromString(String value) { + if (value == null) { + return null; + } + AccountStatus[] items = AccountStatus.values(); + for (AccountStatus item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Action.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Action.java new file mode 100644 index 0000000000000..eb9a8e94d6f84 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Action.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +/** + * Defines values for Action. + */ +public enum Action { + /** + * Enum value Allow. + */ + ALLOW("Allow"); + + /** + * The actual serialized value for a Action instance. + */ + private final String value; + + Action(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a Action instance. + * + * @param value the serialized value to parse. + * @return the parsed Action object, or null if unable to parse. + */ + public static Action fromString(String value) { + if (value == null) { + return null; + } + Action[] items = Action.values(); + for (Action item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ActiveDirectoryProperties.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ActiveDirectoryProperties.java new file mode 100644 index 0000000000000..2c0f488866799 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ActiveDirectoryProperties.java @@ -0,0 +1,349 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Settings properties for Active Directory (AD). + */ +@Fluent +public final class ActiveDirectoryProperties implements JsonSerializable { + /* + * Specifies the primary domain that the AD DNS server is authoritative for. This property is required if + * directoryServiceOptions is set to AD (AD DS authentication). If directoryServiceOptions is set to AADDS (Entra DS + * authentication), providing this property is optional, as it will be inferred automatically if omitted. If + * directoryServiceOptions is set to AADKERB (Entra authentication), this property is optional; it is needed to + * support configuration of directory- and file-level permissions via Windows File Explorer, but is not required for + * authentication. + */ + private String domainName; + + /* + * Specifies the NetBIOS domain name. If directoryServiceOptions is set to AD (AD DS authentication), this property + * is required. Otherwise, it can be omitted. + */ + private String netBiosDomainName; + + /* + * Specifies the Active Directory forest to get. If directoryServiceOptions is set to AD (AD DS authentication), + * this property is required. Otherwise, it can be omitted. + */ + private String forestName; + + /* + * Specifies the domain GUID. If directoryServiceOptions is set to AD (AD DS authentication), this property is + * required. If directoryServiceOptions is set to AADDS (Entra DS authentication), this property can be omitted. If + * directoryServiceOptions is set to AADKERB (Entra authentication), this property is optional; it is needed to + * support configuration of directory- and file-level permissions via Windows File Explorer, but is not required for + * authentication. + */ + private String domainGuid; + + /* + * Specifies the security identifier (SID) of the AD domain. If directoryServiceOptions is set to AD (AD DS + * authentication), this property is required. Otherwise, it can be omitted. + */ + private String domainSid; + + /* + * Specifies the security identifier (SID) for Azure Storage. If directoryServiceOptions is set to AD (AD DS + * authentication), this property is required. Otherwise, it can be omitted. + */ + private String azureStorageSid; + + /* + * Specifies the Active Directory SAMAccountName for Azure Storage. If directoryServiceOptions is set to AD (AD DS + * authentication), this property is optional. If provided, accountType should also be provided. For + * directoryServiceOptions AADDS (Entra DS authentication) or AADKERB (Entra authentication), this property can be + * omitted. + */ + private String samAccountName; + + /* + * Specifies the Active Directory account type for Azure Storage. If directoryServiceOptions is set to AD (AD DS + * authentication), this property is optional. If provided, samAccountName should also be provided. For + * directoryServiceOptions AADDS (Entra DS authentication) or AADKERB (Entra authentication), this property can be + * omitted. + */ + private ActiveDirectoryPropertiesAccountType accountType; + + /** + * Creates an instance of ActiveDirectoryProperties class. + */ + public ActiveDirectoryProperties() { + } + + /** + * Get the domainName property: Specifies the primary domain that the AD DNS server is authoritative for. This + * property is required if directoryServiceOptions is set to AD (AD DS authentication). If directoryServiceOptions + * is set to AADDS (Entra DS authentication), providing this property is optional, as it will be inferred + * automatically if omitted. If directoryServiceOptions is set to AADKERB (Entra authentication), this property is + * optional; it is needed to support configuration of directory- and file-level permissions via Windows File + * Explorer, but is not required for authentication. + * + * @return the domainName value. + */ + public String domainName() { + return this.domainName; + } + + /** + * Set the domainName property: Specifies the primary domain that the AD DNS server is authoritative for. This + * property is required if directoryServiceOptions is set to AD (AD DS authentication). If directoryServiceOptions + * is set to AADDS (Entra DS authentication), providing this property is optional, as it will be inferred + * automatically if omitted. If directoryServiceOptions is set to AADKERB (Entra authentication), this property is + * optional; it is needed to support configuration of directory- and file-level permissions via Windows File + * Explorer, but is not required for authentication. + * + * @param domainName the domainName value to set. + * @return the ActiveDirectoryProperties object itself. + */ + public ActiveDirectoryProperties withDomainName(String domainName) { + this.domainName = domainName; + return this; + } + + /** + * Get the netBiosDomainName property: Specifies the NetBIOS domain name. If directoryServiceOptions is set to AD + * (AD DS authentication), this property is required. Otherwise, it can be omitted. + * + * @return the netBiosDomainName value. + */ + public String netBiosDomainName() { + return this.netBiosDomainName; + } + + /** + * Set the netBiosDomainName property: Specifies the NetBIOS domain name. If directoryServiceOptions is set to AD + * (AD DS authentication), this property is required. Otherwise, it can be omitted. + * + * @param netBiosDomainName the netBiosDomainName value to set. + * @return the ActiveDirectoryProperties object itself. + */ + public ActiveDirectoryProperties withNetBiosDomainName(String netBiosDomainName) { + this.netBiosDomainName = netBiosDomainName; + return this; + } + + /** + * Get the forestName property: Specifies the Active Directory forest to get. If directoryServiceOptions is set to + * AD (AD DS authentication), this property is required. Otherwise, it can be omitted. + * + * @return the forestName value. + */ + public String forestName() { + return this.forestName; + } + + /** + * Set the forestName property: Specifies the Active Directory forest to get. If directoryServiceOptions is set to + * AD (AD DS authentication), this property is required. Otherwise, it can be omitted. + * + * @param forestName the forestName value to set. + * @return the ActiveDirectoryProperties object itself. + */ + public ActiveDirectoryProperties withForestName(String forestName) { + this.forestName = forestName; + return this; + } + + /** + * Get the domainGuid property: Specifies the domain GUID. If directoryServiceOptions is set to AD (AD DS + * authentication), this property is required. If directoryServiceOptions is set to AADDS (Entra DS authentication), + * this property can be omitted. If directoryServiceOptions is set to AADKERB (Entra authentication), this property + * is optional; it is needed to support configuration of directory- and file-level permissions via Windows File + * Explorer, but is not required for authentication. + * + * @return the domainGuid value. + */ + public String domainGuid() { + return this.domainGuid; + } + + /** + * Set the domainGuid property: Specifies the domain GUID. If directoryServiceOptions is set to AD (AD DS + * authentication), this property is required. If directoryServiceOptions is set to AADDS (Entra DS authentication), + * this property can be omitted. If directoryServiceOptions is set to AADKERB (Entra authentication), this property + * is optional; it is needed to support configuration of directory- and file-level permissions via Windows File + * Explorer, but is not required for authentication. + * + * @param domainGuid the domainGuid value to set. + * @return the ActiveDirectoryProperties object itself. + */ + public ActiveDirectoryProperties withDomainGuid(String domainGuid) { + this.domainGuid = domainGuid; + return this; + } + + /** + * Get the domainSid property: Specifies the security identifier (SID) of the AD domain. If directoryServiceOptions + * is set to AD (AD DS authentication), this property is required. Otherwise, it can be omitted. + * + * @return the domainSid value. + */ + public String domainSid() { + return this.domainSid; + } + + /** + * Set the domainSid property: Specifies the security identifier (SID) of the AD domain. If directoryServiceOptions + * is set to AD (AD DS authentication), this property is required. Otherwise, it can be omitted. + * + * @param domainSid the domainSid value to set. + * @return the ActiveDirectoryProperties object itself. + */ + public ActiveDirectoryProperties withDomainSid(String domainSid) { + this.domainSid = domainSid; + return this; + } + + /** + * Get the azureStorageSid property: Specifies the security identifier (SID) for Azure Storage. If + * directoryServiceOptions is set to AD (AD DS authentication), this property is required. Otherwise, it can be + * omitted. + * + * @return the azureStorageSid value. + */ + public String azureStorageSid() { + return this.azureStorageSid; + } + + /** + * Set the azureStorageSid property: Specifies the security identifier (SID) for Azure Storage. If + * directoryServiceOptions is set to AD (AD DS authentication), this property is required. Otherwise, it can be + * omitted. + * + * @param azureStorageSid the azureStorageSid value to set. + * @return the ActiveDirectoryProperties object itself. + */ + public ActiveDirectoryProperties withAzureStorageSid(String azureStorageSid) { + this.azureStorageSid = azureStorageSid; + return this; + } + + /** + * Get the samAccountName property: Specifies the Active Directory SAMAccountName for Azure Storage. If + * directoryServiceOptions is set to AD (AD DS authentication), this property is optional. If provided, accountType + * should also be provided. For directoryServiceOptions AADDS (Entra DS authentication) or AADKERB (Entra + * authentication), this property can be omitted. + * + * @return the samAccountName value. + */ + public String samAccountName() { + return this.samAccountName; + } + + /** + * Set the samAccountName property: Specifies the Active Directory SAMAccountName for Azure Storage. If + * directoryServiceOptions is set to AD (AD DS authentication), this property is optional. If provided, accountType + * should also be provided. For directoryServiceOptions AADDS (Entra DS authentication) or AADKERB (Entra + * authentication), this property can be omitted. + * + * @param samAccountName the samAccountName value to set. + * @return the ActiveDirectoryProperties object itself. + */ + public ActiveDirectoryProperties withSamAccountName(String samAccountName) { + this.samAccountName = samAccountName; + return this; + } + + /** + * Get the accountType property: Specifies the Active Directory account type for Azure Storage. If + * directoryServiceOptions is set to AD (AD DS authentication), this property is optional. If provided, + * samAccountName should also be provided. For directoryServiceOptions AADDS (Entra DS authentication) or AADKERB + * (Entra authentication), this property can be omitted. + * + * @return the accountType value. + */ + public ActiveDirectoryPropertiesAccountType accountType() { + return this.accountType; + } + + /** + * Set the accountType property: Specifies the Active Directory account type for Azure Storage. If + * directoryServiceOptions is set to AD (AD DS authentication), this property is optional. If provided, + * samAccountName should also be provided. For directoryServiceOptions AADDS (Entra DS authentication) or AADKERB + * (Entra authentication), this property can be omitted. + * + * @param accountType the accountType value to set. + * @return the ActiveDirectoryProperties object itself. + */ + public ActiveDirectoryProperties withAccountType(ActiveDirectoryPropertiesAccountType accountType) { + this.accountType = accountType; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("domainName", this.domainName); + jsonWriter.writeStringField("netBiosDomainName", this.netBiosDomainName); + jsonWriter.writeStringField("forestName", this.forestName); + jsonWriter.writeStringField("domainGuid", this.domainGuid); + jsonWriter.writeStringField("domainSid", this.domainSid); + jsonWriter.writeStringField("azureStorageSid", this.azureStorageSid); + jsonWriter.writeStringField("samAccountName", this.samAccountName); + jsonWriter.writeStringField("accountType", this.accountType == null ? null : this.accountType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ActiveDirectoryProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ActiveDirectoryProperties if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the ActiveDirectoryProperties. + */ + public static ActiveDirectoryProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ActiveDirectoryProperties deserializedActiveDirectoryProperties = new ActiveDirectoryProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("domainName".equals(fieldName)) { + deserializedActiveDirectoryProperties.domainName = reader.getString(); + } else if ("netBiosDomainName".equals(fieldName)) { + deserializedActiveDirectoryProperties.netBiosDomainName = reader.getString(); + } else if ("forestName".equals(fieldName)) { + deserializedActiveDirectoryProperties.forestName = reader.getString(); + } else if ("domainGuid".equals(fieldName)) { + deserializedActiveDirectoryProperties.domainGuid = reader.getString(); + } else if ("domainSid".equals(fieldName)) { + deserializedActiveDirectoryProperties.domainSid = reader.getString(); + } else if ("azureStorageSid".equals(fieldName)) { + deserializedActiveDirectoryProperties.azureStorageSid = reader.getString(); + } else if ("samAccountName".equals(fieldName)) { + deserializedActiveDirectoryProperties.samAccountName = reader.getString(); + } else if ("accountType".equals(fieldName)) { + deserializedActiveDirectoryProperties.accountType + = ActiveDirectoryPropertiesAccountType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedActiveDirectoryProperties; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ActiveDirectoryPropertiesAccountType.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ActiveDirectoryPropertiesAccountType.java new file mode 100644 index 0000000000000..43efb9fb432a3 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ActiveDirectoryPropertiesAccountType.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Specifies the Active Directory account type for Azure Storage. If directoryServiceOptions is set to AD (AD DS + * authentication), this property is optional. If provided, samAccountName should also be provided. For + * directoryServiceOptions AADDS (Entra DS authentication) or AADKERB (Entra authentication), this property can be + * omitted. + */ +public final class ActiveDirectoryPropertiesAccountType + extends ExpandableStringEnum { + /** + * Static value User for ActiveDirectoryPropertiesAccountType. + */ + public static final ActiveDirectoryPropertiesAccountType USER = fromString("User"); + + /** + * Static value Computer for ActiveDirectoryPropertiesAccountType. + */ + public static final ActiveDirectoryPropertiesAccountType COMPUTER = fromString("Computer"); + + /** + * Creates a new instance of ActiveDirectoryPropertiesAccountType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ActiveDirectoryPropertiesAccountType() { + } + + /** + * Creates or finds a ActiveDirectoryPropertiesAccountType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ActiveDirectoryPropertiesAccountType. + */ + public static ActiveDirectoryPropertiesAccountType fromString(String name) { + return fromString(name, ActiveDirectoryPropertiesAccountType.class); + } + + /** + * Gets known ActiveDirectoryPropertiesAccountType values. + * + * @return known ActiveDirectoryPropertiesAccountType values. + */ + public static Collection values() { + return values(ActiveDirectoryPropertiesAccountType.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/AllowedCopyScope.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/AllowedCopyScope.java new file mode 100644 index 0000000000000..75ec14068235a --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/AllowedCopyScope.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Restrict copy to and from Storage Accounts within an AAD tenant or with Private Links to the same VNet. + */ +public final class AllowedCopyScope extends ExpandableStringEnum { + /** + * Static value PrivateLink for AllowedCopyScope. + */ + public static final AllowedCopyScope PRIVATE_LINK = fromString("PrivateLink"); + + /** + * Static value AAD for AllowedCopyScope. + */ + public static final AllowedCopyScope AAD = fromString("AAD"); + + /** + * Static value All for AllowedCopyScope. + */ + public static final AllowedCopyScope ALL = fromString("All"); + + /** + * Creates a new instance of AllowedCopyScope value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public AllowedCopyScope() { + } + + /** + * Creates or finds a AllowedCopyScope from its string representation. + * + * @param name a name to look for. + * @return the corresponding AllowedCopyScope. + */ + public static AllowedCopyScope fromString(String name) { + return fromString(name, AllowedCopyScope.class); + } + + /** + * Gets known AllowedCopyScope values. + * + * @return known AllowedCopyScope values. + */ + public static Collection values() { + return values(AllowedCopyScope.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/AzureFilesIdentityBasedAuthentication.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/AzureFilesIdentityBasedAuthentication.java new file mode 100644 index 0000000000000..c25fc3502ad11 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/AzureFilesIdentityBasedAuthentication.java @@ -0,0 +1,213 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Settings for Azure Files identity based authentication. + */ +@Fluent +public final class AzureFilesIdentityBasedAuthentication + implements JsonSerializable { + /* + * Indicates the directory service used. Note that this enum may be extended in the future. + */ + private DirectoryServiceOptions directoryServiceOptions; + + /* + * Additional information about the directory service. Required if directoryServiceOptions is AD (AD DS + * authentication). Optional for directoryServiceOptions AADDS (Entra DS authentication) and AADKERB (Entra + * authentication). + */ + private ActiveDirectoryProperties activeDirectoryProperties; + + /* + * Default share permission for users using Kerberos authentication if RBAC role is not assigned. + */ + private DefaultSharePermission defaultSharePermission; + + /* + * Required for Managed Identities access using OAuth over SMB. + */ + private SmbOAuthSettings smbOAuthSettings; + + /** + * Creates an instance of AzureFilesIdentityBasedAuthentication class. + */ + public AzureFilesIdentityBasedAuthentication() { + } + + /** + * Get the directoryServiceOptions property: Indicates the directory service used. Note that this enum may be + * extended in the future. + * + * @return the directoryServiceOptions value. + */ + public DirectoryServiceOptions directoryServiceOptions() { + return this.directoryServiceOptions; + } + + /** + * Set the directoryServiceOptions property: Indicates the directory service used. Note that this enum may be + * extended in the future. + * + * @param directoryServiceOptions the directoryServiceOptions value to set. + * @return the AzureFilesIdentityBasedAuthentication object itself. + */ + public AzureFilesIdentityBasedAuthentication + withDirectoryServiceOptions(DirectoryServiceOptions directoryServiceOptions) { + this.directoryServiceOptions = directoryServiceOptions; + return this; + } + + /** + * Get the activeDirectoryProperties property: Additional information about the directory service. Required if + * directoryServiceOptions is AD (AD DS authentication). Optional for directoryServiceOptions AADDS (Entra DS + * authentication) and AADKERB (Entra authentication). + * + * @return the activeDirectoryProperties value. + */ + public ActiveDirectoryProperties activeDirectoryProperties() { + return this.activeDirectoryProperties; + } + + /** + * Set the activeDirectoryProperties property: Additional information about the directory service. Required if + * directoryServiceOptions is AD (AD DS authentication). Optional for directoryServiceOptions AADDS (Entra DS + * authentication) and AADKERB (Entra authentication). + * + * @param activeDirectoryProperties the activeDirectoryProperties value to set. + * @return the AzureFilesIdentityBasedAuthentication object itself. + */ + public AzureFilesIdentityBasedAuthentication + withActiveDirectoryProperties(ActiveDirectoryProperties activeDirectoryProperties) { + this.activeDirectoryProperties = activeDirectoryProperties; + return this; + } + + /** + * Get the defaultSharePermission property: Default share permission for users using Kerberos authentication if RBAC + * role is not assigned. + * + * @return the defaultSharePermission value. + */ + public DefaultSharePermission defaultSharePermission() { + return this.defaultSharePermission; + } + + /** + * Set the defaultSharePermission property: Default share permission for users using Kerberos authentication if RBAC + * role is not assigned. + * + * @param defaultSharePermission the defaultSharePermission value to set. + * @return the AzureFilesIdentityBasedAuthentication object itself. + */ + public AzureFilesIdentityBasedAuthentication + withDefaultSharePermission(DefaultSharePermission defaultSharePermission) { + this.defaultSharePermission = defaultSharePermission; + return this; + } + + /** + * Get the smbOAuthSettings property: Required for Managed Identities access using OAuth over SMB. + * + * @return the smbOAuthSettings value. + */ + public SmbOAuthSettings smbOAuthSettings() { + return this.smbOAuthSettings; + } + + /** + * Set the smbOAuthSettings property: Required for Managed Identities access using OAuth over SMB. + * + * @param smbOAuthSettings the smbOAuthSettings value to set. + * @return the AzureFilesIdentityBasedAuthentication object itself. + */ + public AzureFilesIdentityBasedAuthentication withSmbOAuthSettings(SmbOAuthSettings smbOAuthSettings) { + this.smbOAuthSettings = smbOAuthSettings; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (directoryServiceOptions() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property directoryServiceOptions in model AzureFilesIdentityBasedAuthentication")); + } + if (activeDirectoryProperties() != null) { + activeDirectoryProperties().validate(); + } + if (smbOAuthSettings() != null) { + smbOAuthSettings().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(AzureFilesIdentityBasedAuthentication.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("directoryServiceOptions", + this.directoryServiceOptions == null ? null : this.directoryServiceOptions.toString()); + jsonWriter.writeJsonField("activeDirectoryProperties", this.activeDirectoryProperties); + jsonWriter.writeStringField("defaultSharePermission", + this.defaultSharePermission == null ? null : this.defaultSharePermission.toString()); + jsonWriter.writeJsonField("smbOAuthSettings", this.smbOAuthSettings); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of AzureFilesIdentityBasedAuthentication from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of AzureFilesIdentityBasedAuthentication if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the AzureFilesIdentityBasedAuthentication. + */ + public static AzureFilesIdentityBasedAuthentication fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + AzureFilesIdentityBasedAuthentication deserializedAzureFilesIdentityBasedAuthentication + = new AzureFilesIdentityBasedAuthentication(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("directoryServiceOptions".equals(fieldName)) { + deserializedAzureFilesIdentityBasedAuthentication.directoryServiceOptions + = DirectoryServiceOptions.fromString(reader.getString()); + } else if ("activeDirectoryProperties".equals(fieldName)) { + deserializedAzureFilesIdentityBasedAuthentication.activeDirectoryProperties + = ActiveDirectoryProperties.fromJson(reader); + } else if ("defaultSharePermission".equals(fieldName)) { + deserializedAzureFilesIdentityBasedAuthentication.defaultSharePermission + = DefaultSharePermission.fromString(reader.getString()); + } else if ("smbOAuthSettings".equals(fieldName)) { + deserializedAzureFilesIdentityBasedAuthentication.smbOAuthSettings + = SmbOAuthSettings.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedAzureFilesIdentityBasedAuthentication; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/BlobRestoreParameters.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/BlobRestoreParameters.java new file mode 100644 index 0000000000000..a8dbc7b2debdc --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/BlobRestoreParameters.java @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.List; + +/** + * Blob restore parameters. + */ +@Immutable +public final class BlobRestoreParameters implements JsonSerializable { + /* + * Restore blob to the specified time. + */ + private OffsetDateTime timeToRestore; + + /* + * Blob ranges to restore. + */ + private List blobRanges; + + /** + * Creates an instance of BlobRestoreParameters class. + */ + private BlobRestoreParameters() { + } + + /** + * Get the timeToRestore property: Restore blob to the specified time. + * + * @return the timeToRestore value. + */ + public OffsetDateTime timeToRestore() { + return this.timeToRestore; + } + + /** + * Get the blobRanges property: Blob ranges to restore. + * + * @return the blobRanges value. + */ + public List blobRanges() { + return this.blobRanges; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (timeToRestore() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property timeToRestore in model BlobRestoreParameters")); + } + if (blobRanges() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property blobRanges in model BlobRestoreParameters")); + } else { + blobRanges().forEach(e -> e.validate()); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(BlobRestoreParameters.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("timeToRestore", + this.timeToRestore == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.timeToRestore)); + jsonWriter.writeArrayField("blobRanges", this.blobRanges, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BlobRestoreParameters from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BlobRestoreParameters if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the BlobRestoreParameters. + */ + public static BlobRestoreParameters fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BlobRestoreParameters deserializedBlobRestoreParameters = new BlobRestoreParameters(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("timeToRestore".equals(fieldName)) { + deserializedBlobRestoreParameters.timeToRestore = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("blobRanges".equals(fieldName)) { + List blobRanges = reader.readArray(reader1 -> BlobRestoreRange.fromJson(reader1)); + deserializedBlobRestoreParameters.blobRanges = blobRanges; + } else { + reader.skipChildren(); + } + } + + return deserializedBlobRestoreParameters; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/BlobRestoreProgressStatus.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/BlobRestoreProgressStatus.java new file mode 100644 index 0000000000000..d05127d623ff7 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/BlobRestoreProgressStatus.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - + * Complete: Indicates that blob restore has been completed successfully. - Failed: Indicates that blob restore is + * failed. + */ +public final class BlobRestoreProgressStatus extends ExpandableStringEnum { + /** + * Static value InProgress for BlobRestoreProgressStatus. + */ + public static final BlobRestoreProgressStatus IN_PROGRESS = fromString("InProgress"); + + /** + * Static value Complete for BlobRestoreProgressStatus. + */ + public static final BlobRestoreProgressStatus COMPLETE = fromString("Complete"); + + /** + * Static value Failed for BlobRestoreProgressStatus. + */ + public static final BlobRestoreProgressStatus FAILED = fromString("Failed"); + + /** + * Creates a new instance of BlobRestoreProgressStatus value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public BlobRestoreProgressStatus() { + } + + /** + * Creates or finds a BlobRestoreProgressStatus from its string representation. + * + * @param name a name to look for. + * @return the corresponding BlobRestoreProgressStatus. + */ + public static BlobRestoreProgressStatus fromString(String name) { + return fromString(name, BlobRestoreProgressStatus.class); + } + + /** + * Gets known BlobRestoreProgressStatus values. + * + * @return known BlobRestoreProgressStatus values. + */ + public static Collection values() { + return values(BlobRestoreProgressStatus.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/BlobRestoreRange.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/BlobRestoreRange.java new file mode 100644 index 0000000000000..213ebcee3e7bd --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/BlobRestoreRange.java @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Blob range. + */ +@Immutable +public final class BlobRestoreRange implements JsonSerializable { + /* + * Blob start range. This is inclusive. Empty means account start. + */ + private String startRange; + + /* + * Blob end range. This is exclusive. Empty means account end. + */ + private String endRange; + + /** + * Creates an instance of BlobRestoreRange class. + */ + private BlobRestoreRange() { + } + + /** + * Get the startRange property: Blob start range. This is inclusive. Empty means account start. + * + * @return the startRange value. + */ + public String startRange() { + return this.startRange; + } + + /** + * Get the endRange property: Blob end range. This is exclusive. Empty means account end. + * + * @return the endRange value. + */ + public String endRange() { + return this.endRange; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (startRange() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property startRange in model BlobRestoreRange")); + } + if (endRange() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property endRange in model BlobRestoreRange")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(BlobRestoreRange.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("startRange", this.startRange); + jsonWriter.writeStringField("endRange", this.endRange); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BlobRestoreRange from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BlobRestoreRange if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the BlobRestoreRange. + */ + public static BlobRestoreRange fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BlobRestoreRange deserializedBlobRestoreRange = new BlobRestoreRange(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("startRange".equals(fieldName)) { + deserializedBlobRestoreRange.startRange = reader.getString(); + } else if ("endRange".equals(fieldName)) { + deserializedBlobRestoreRange.endRange = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedBlobRestoreRange; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/BlobRestoreStatus.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/BlobRestoreStatus.java new file mode 100644 index 0000000000000..2b8df8f93a73b --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/BlobRestoreStatus.java @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Blob restore status. + */ +@Immutable +public final class BlobRestoreStatus implements JsonSerializable { + /* + * The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - + * Complete: Indicates that blob restore has been completed successfully. - Failed: Indicates that blob restore is + * failed. + */ + private BlobRestoreProgressStatus status; + + /* + * Failure reason when blob restore is failed. + */ + private String failureReason; + + /* + * Id for tracking blob restore request. + */ + private String restoreId; + + /* + * Blob restore request parameters. + */ + private BlobRestoreParameters parameters; + + /** + * Creates an instance of BlobRestoreStatus class. + */ + private BlobRestoreStatus() { + } + + /** + * Get the status property: The status of blob restore progress. Possible values are: - InProgress: Indicates that + * blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - Failed: + * Indicates that blob restore is failed. + * + * @return the status value. + */ + public BlobRestoreProgressStatus status() { + return this.status; + } + + /** + * Get the failureReason property: Failure reason when blob restore is failed. + * + * @return the failureReason value. + */ + public String failureReason() { + return this.failureReason; + } + + /** + * Get the restoreId property: Id for tracking blob restore request. + * + * @return the restoreId value. + */ + public String restoreId() { + return this.restoreId; + } + + /** + * Get the parameters property: Blob restore request parameters. + * + * @return the parameters value. + */ + public BlobRestoreParameters parameters() { + return this.parameters; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (parameters() != null) { + parameters().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BlobRestoreStatus from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BlobRestoreStatus if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the BlobRestoreStatus. + */ + public static BlobRestoreStatus fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BlobRestoreStatus deserializedBlobRestoreStatus = new BlobRestoreStatus(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("status".equals(fieldName)) { + deserializedBlobRestoreStatus.status = BlobRestoreProgressStatus.fromString(reader.getString()); + } else if ("failureReason".equals(fieldName)) { + deserializedBlobRestoreStatus.failureReason = reader.getString(); + } else if ("restoreId".equals(fieldName)) { + deserializedBlobRestoreStatus.restoreId = reader.getString(); + } else if ("parameters".equals(fieldName)) { + deserializedBlobRestoreStatus.parameters = BlobRestoreParameters.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedBlobRestoreStatus; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Bypass.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Bypass.java new file mode 100644 index 0000000000000..baa514232f912 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Bypass.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of + * Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. + */ +public final class Bypass extends ExpandableStringEnum { + /** + * Static value None for Bypass. + */ + public static final Bypass NONE = fromString("None"); + + /** + * Static value Logging for Bypass. + */ + public static final Bypass LOGGING = fromString("Logging"); + + /** + * Static value Metrics for Bypass. + */ + public static final Bypass METRICS = fromString("Metrics"); + + /** + * Static value AzureServices for Bypass. + */ + public static final Bypass AZURE_SERVICES = fromString("AzureServices"); + + /** + * Creates a new instance of Bypass value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public Bypass() { + } + + /** + * Creates or finds a Bypass from its string representation. + * + * @param name a name to look for. + * @return the corresponding Bypass. + */ + public static Bypass fromString(String name) { + return fromString(name, Bypass.class); + } + + /** + * Gets known Bypass values. + * + * @return known Bypass values. + */ + public static Collection values() { + return values(Bypass.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/CustomDomain.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/CustomDomain.java new file mode 100644 index 0000000000000..d1f954a92da2f --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/CustomDomain.java @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The custom domain assigned to this storage account. This can be set via Update. + */ +@Fluent +public final class CustomDomain implements JsonSerializable { + /* + * Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. + */ + private String name; + + /* + * Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on + * updates. + */ + private Boolean useSubDomainName; + + /** + * Creates an instance of CustomDomain class. + */ + public CustomDomain() { + } + + /** + * Get the name property: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME + * source. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: Gets or sets the custom domain name assigned to the storage account. Name is the CNAME + * source. + * + * @param name the name value to set. + * @return the CustomDomain object itself. + */ + public CustomDomain withName(String name) { + this.name = name; + return this; + } + + /** + * Get the useSubDomainName property: Indicates whether indirect CName validation is enabled. Default value is + * false. This should only be set on updates. + * + * @return the useSubDomainName value. + */ + public Boolean useSubDomainName() { + return this.useSubDomainName; + } + + /** + * Set the useSubDomainName property: Indicates whether indirect CName validation is enabled. Default value is + * false. This should only be set on updates. + * + * @param useSubDomainName the useSubDomainName value to set. + * @return the CustomDomain object itself. + */ + public CustomDomain withUseSubDomainName(Boolean useSubDomainName) { + this.useSubDomainName = useSubDomainName; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property name in model CustomDomain")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(CustomDomain.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeBooleanField("useSubDomainName", this.useSubDomainName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CustomDomain from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CustomDomain if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the CustomDomain. + */ + public static CustomDomain fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CustomDomain deserializedCustomDomain = new CustomDomain(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedCustomDomain.name = reader.getString(); + } else if ("useSubDomainName".equals(fieldName)) { + deserializedCustomDomain.useSubDomainName = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + + return deserializedCustomDomain; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/DefaultAction.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/DefaultAction.java new file mode 100644 index 0000000000000..eb272618f7177 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/DefaultAction.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +/** + * Specifies the default action of allow or deny when no other rules match. + */ +public enum DefaultAction { + /** + * Enum value Allow. + */ + ALLOW("Allow"), + + /** + * Enum value Deny. + */ + DENY("Deny"); + + /** + * The actual serialized value for a DefaultAction instance. + */ + private final String value; + + DefaultAction(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a DefaultAction instance. + * + * @param value the serialized value to parse. + * @return the parsed DefaultAction object, or null if unable to parse. + */ + public static DefaultAction fromString(String value) { + if (value == null) { + return null; + } + DefaultAction[] items = DefaultAction.values(); + for (DefaultAction item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/DefaultSharePermission.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/DefaultSharePermission.java new file mode 100644 index 0000000000000..0dca6ada3a73e --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/DefaultSharePermission.java @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Default share permission for users using Kerberos authentication if RBAC role is not assigned. + */ +public final class DefaultSharePermission extends ExpandableStringEnum { + /** + * Static value None for DefaultSharePermission. + */ + public static final DefaultSharePermission NONE = fromString("None"); + + /** + * Static value StorageFileDataSmbShareReader for DefaultSharePermission. + */ + public static final DefaultSharePermission STORAGE_FILE_DATA_SMB_SHARE_READER + = fromString("StorageFileDataSmbShareReader"); + + /** + * Static value StorageFileDataSmbShareContributor for DefaultSharePermission. + */ + public static final DefaultSharePermission STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR + = fromString("StorageFileDataSmbShareContributor"); + + /** + * Static value StorageFileDataSmbShareElevatedContributor for DefaultSharePermission. + */ + public static final DefaultSharePermission STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR + = fromString("StorageFileDataSmbShareElevatedContributor"); + + /** + * Creates a new instance of DefaultSharePermission value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public DefaultSharePermission() { + } + + /** + * Creates or finds a DefaultSharePermission from its string representation. + * + * @param name a name to look for. + * @return the corresponding DefaultSharePermission. + */ + public static DefaultSharePermission fromString(String name) { + return fromString(name, DefaultSharePermission.class); + } + + /** + * Gets known DefaultSharePermission values. + * + * @return known DefaultSharePermission values. + */ + public static Collection values() { + return values(DefaultSharePermission.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/DirectoryServiceOptions.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/DirectoryServiceOptions.java new file mode 100644 index 0000000000000..6834c14c42de0 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/DirectoryServiceOptions.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Indicates the directory service used. Note that this enum may be extended in the future. + */ +public final class DirectoryServiceOptions extends ExpandableStringEnum { + /** + * Static value None for DirectoryServiceOptions. + */ + public static final DirectoryServiceOptions NONE = fromString("None"); + + /** + * Static value AADDS for DirectoryServiceOptions. + */ + public static final DirectoryServiceOptions AADDS = fromString("AADDS"); + + /** + * Static value AD for DirectoryServiceOptions. + */ + public static final DirectoryServiceOptions AD = fromString("AD"); + + /** + * Static value AADKERB for DirectoryServiceOptions. + */ + public static final DirectoryServiceOptions AADKERB = fromString("AADKERB"); + + /** + * Creates a new instance of DirectoryServiceOptions value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public DirectoryServiceOptions() { + } + + /** + * Creates or finds a DirectoryServiceOptions from its string representation. + * + * @param name a name to look for. + * @return the corresponding DirectoryServiceOptions. + */ + public static DirectoryServiceOptions fromString(String name) { + return fromString(name, DirectoryServiceOptions.class); + } + + /** + * Gets known DirectoryServiceOptions values. + * + * @return known DirectoryServiceOptions values. + */ + public static Collection values() { + return values(DirectoryServiceOptions.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/DnsEndpointType.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/DnsEndpointType.java new file mode 100644 index 0000000000000..9da1e599a3478 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/DnsEndpointType.java @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single + * subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone + * identifier. + */ +public final class DnsEndpointType extends ExpandableStringEnum { + /** + * Static value Standard for DnsEndpointType. + */ + public static final DnsEndpointType STANDARD = fromString("Standard"); + + /** + * Static value AzureDnsZone for DnsEndpointType. + */ + public static final DnsEndpointType AZURE_DNS_ZONE = fromString("AzureDnsZone"); + + /** + * Creates a new instance of DnsEndpointType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public DnsEndpointType() { + } + + /** + * Creates or finds a DnsEndpointType from its string representation. + * + * @param name a name to look for. + * @return the corresponding DnsEndpointType. + */ + public static DnsEndpointType fromString(String name) { + return fromString(name, DnsEndpointType.class); + } + + /** + * Gets known DnsEndpointType values. + * + * @return known DnsEndpointType values. + */ + public static Collection values() { + return values(DnsEndpointType.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/DualStackEndpointPreference.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/DualStackEndpointPreference.java new file mode 100644 index 0000000000000..23109556872c3 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/DualStackEndpointPreference.java @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Dual-stack endpoint preference defines whether IPv6 endpoints are going to be published. + */ +@Fluent +public final class DualStackEndpointPreference implements JsonSerializable { + /* + * A boolean flag which indicates whether IPv6 storage endpoints are to be published. + */ + private Boolean publishIpv6Endpoint; + + /** + * Creates an instance of DualStackEndpointPreference class. + */ + public DualStackEndpointPreference() { + } + + /** + * Get the publishIpv6Endpoint property: A boolean flag which indicates whether IPv6 storage endpoints are to be + * published. + * + * @return the publishIpv6Endpoint value. + */ + public Boolean publishIpv6Endpoint() { + return this.publishIpv6Endpoint; + } + + /** + * Set the publishIpv6Endpoint property: A boolean flag which indicates whether IPv6 storage endpoints are to be + * published. + * + * @param publishIpv6Endpoint the publishIpv6Endpoint value to set. + * @return the DualStackEndpointPreference object itself. + */ + public DualStackEndpointPreference withPublishIpv6Endpoint(Boolean publishIpv6Endpoint) { + this.publishIpv6Endpoint = publishIpv6Endpoint; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("publishIpv6Endpoint", this.publishIpv6Endpoint); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DualStackEndpointPreference from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DualStackEndpointPreference if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the DualStackEndpointPreference. + */ + public static DualStackEndpointPreference fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DualStackEndpointPreference deserializedDualStackEndpointPreference = new DualStackEndpointPreference(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("publishIpv6Endpoint".equals(fieldName)) { + deserializedDualStackEndpointPreference.publishIpv6Endpoint + = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + + return deserializedDualStackEndpointPreference; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Encryption.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Encryption.java new file mode 100644 index 0000000000000..e81ecfbf79b49 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Encryption.java @@ -0,0 +1,219 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The encryption settings on the storage account. + */ +@Fluent +public final class Encryption implements JsonSerializable { + /* + * List of services which support encryption. + */ + private EncryptionServices services; + + /* + * The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault + */ + private KeySource keySource; + + /* + * A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed + * keys for data at rest. + */ + private Boolean requireInfrastructureEncryption; + + /* + * Properties provided by key vault. + */ + private KeyVaultProperties keyVaultProperties; + + /* + * The identity to be used with service-side encryption at rest. + */ + private EncryptionIdentity encryptionIdentity; + + /** + * Creates an instance of Encryption class. + */ + public Encryption() { + } + + /** + * Get the services property: List of services which support encryption. + * + * @return the services value. + */ + public EncryptionServices services() { + return this.services; + } + + /** + * Set the services property: List of services which support encryption. + * + * @param services the services value to set. + * @return the Encryption object itself. + */ + public Encryption withServices(EncryptionServices services) { + this.services = services; + return this; + } + + /** + * Get the keySource property: The encryption keySource (provider). Possible values (case-insensitive): + * Microsoft.Storage, Microsoft.Keyvault. + * + * @return the keySource value. + */ + public KeySource keySource() { + return this.keySource; + } + + /** + * Set the keySource property: The encryption keySource (provider). Possible values (case-insensitive): + * Microsoft.Storage, Microsoft.Keyvault. + * + * @param keySource the keySource value to set. + * @return the Encryption object itself. + */ + public Encryption withKeySource(KeySource keySource) { + this.keySource = keySource; + return this; + } + + /** + * Get the requireInfrastructureEncryption property: A boolean indicating whether or not the service applies a + * secondary layer of encryption with platform managed keys for data at rest. + * + * @return the requireInfrastructureEncryption value. + */ + public Boolean requireInfrastructureEncryption() { + return this.requireInfrastructureEncryption; + } + + /** + * Set the requireInfrastructureEncryption property: A boolean indicating whether or not the service applies a + * secondary layer of encryption with platform managed keys for data at rest. + * + * @param requireInfrastructureEncryption the requireInfrastructureEncryption value to set. + * @return the Encryption object itself. + */ + public Encryption withRequireInfrastructureEncryption(Boolean requireInfrastructureEncryption) { + this.requireInfrastructureEncryption = requireInfrastructureEncryption; + return this; + } + + /** + * Get the keyVaultProperties property: Properties provided by key vault. + * + * @return the keyVaultProperties value. + */ + public KeyVaultProperties keyVaultProperties() { + return this.keyVaultProperties; + } + + /** + * Set the keyVaultProperties property: Properties provided by key vault. + * + * @param keyVaultProperties the keyVaultProperties value to set. + * @return the Encryption object itself. + */ + public Encryption withKeyVaultProperties(KeyVaultProperties keyVaultProperties) { + this.keyVaultProperties = keyVaultProperties; + return this; + } + + /** + * Get the encryptionIdentity property: The identity to be used with service-side encryption at rest. + * + * @return the encryptionIdentity value. + */ + public EncryptionIdentity encryptionIdentity() { + return this.encryptionIdentity; + } + + /** + * Set the encryptionIdentity property: The identity to be used with service-side encryption at rest. + * + * @param encryptionIdentity the encryptionIdentity value to set. + * @return the Encryption object itself. + */ + public Encryption withEncryptionIdentity(EncryptionIdentity encryptionIdentity) { + this.encryptionIdentity = encryptionIdentity; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (services() != null) { + services().validate(); + } + if (keyVaultProperties() != null) { + keyVaultProperties().validate(); + } + if (encryptionIdentity() != null) { + encryptionIdentity().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("services", this.services); + jsonWriter.writeStringField("keySource", this.keySource == null ? null : this.keySource.toString()); + jsonWriter.writeBooleanField("requireInfrastructureEncryption", this.requireInfrastructureEncryption); + jsonWriter.writeJsonField("keyvaultproperties", this.keyVaultProperties); + jsonWriter.writeJsonField("identity", this.encryptionIdentity); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Encryption from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Encryption if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IOException If an error occurs while reading the Encryption. + */ + public static Encryption fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Encryption deserializedEncryption = new Encryption(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("services".equals(fieldName)) { + deserializedEncryption.services = EncryptionServices.fromJson(reader); + } else if ("keySource".equals(fieldName)) { + deserializedEncryption.keySource = KeySource.fromString(reader.getString()); + } else if ("requireInfrastructureEncryption".equals(fieldName)) { + deserializedEncryption.requireInfrastructureEncryption = reader.getNullable(JsonReader::getBoolean); + } else if ("keyvaultproperties".equals(fieldName)) { + deserializedEncryption.keyVaultProperties = KeyVaultProperties.fromJson(reader); + } else if ("identity".equals(fieldName)) { + deserializedEncryption.encryptionIdentity = EncryptionIdentity.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedEncryption; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/EncryptionIdentity.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/EncryptionIdentity.java new file mode 100644 index 0000000000000..052c8fdf51d33 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/EncryptionIdentity.java @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Encryption identity for the storage account. + */ +@Fluent +public final class EncryptionIdentity implements JsonSerializable { + /* + * Resource identifier of the UserAssigned identity to be associated with server-side encryption on the storage + * account. + */ + private String encryptionUserAssignedIdentity; + + /* + * ClientId of the multi-tenant application to be used in conjunction with the user-assigned identity for + * cross-tenant customer-managed-keys server-side encryption on the storage account. + */ + private String encryptionFederatedIdentityClientId; + + /** + * Creates an instance of EncryptionIdentity class. + */ + public EncryptionIdentity() { + } + + /** + * Get the encryptionUserAssignedIdentity property: Resource identifier of the UserAssigned identity to be + * associated with server-side encryption on the storage account. + * + * @return the encryptionUserAssignedIdentity value. + */ + public String encryptionUserAssignedIdentity() { + return this.encryptionUserAssignedIdentity; + } + + /** + * Set the encryptionUserAssignedIdentity property: Resource identifier of the UserAssigned identity to be + * associated with server-side encryption on the storage account. + * + * @param encryptionUserAssignedIdentity the encryptionUserAssignedIdentity value to set. + * @return the EncryptionIdentity object itself. + */ + public EncryptionIdentity withEncryptionUserAssignedIdentity(String encryptionUserAssignedIdentity) { + this.encryptionUserAssignedIdentity = encryptionUserAssignedIdentity; + return this; + } + + /** + * Get the encryptionFederatedIdentityClientId property: ClientId of the multi-tenant application to be used in + * conjunction with the user-assigned identity for cross-tenant customer-managed-keys server-side encryption on the + * storage account. + * + * @return the encryptionFederatedIdentityClientId value. + */ + public String encryptionFederatedIdentityClientId() { + return this.encryptionFederatedIdentityClientId; + } + + /** + * Set the encryptionFederatedIdentityClientId property: ClientId of the multi-tenant application to be used in + * conjunction with the user-assigned identity for cross-tenant customer-managed-keys server-side encryption on the + * storage account. + * + * @param encryptionFederatedIdentityClientId the encryptionFederatedIdentityClientId value to set. + * @return the EncryptionIdentity object itself. + */ + public EncryptionIdentity withEncryptionFederatedIdentityClientId(String encryptionFederatedIdentityClientId) { + this.encryptionFederatedIdentityClientId = encryptionFederatedIdentityClientId; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (encryptionUserAssignedIdentity() != null) { + jsonWriter.writeStringField("userAssignedIdentity", this.encryptionUserAssignedIdentity); + } else { + jsonWriter.writeNullField("userAssignedIdentity"); + } + jsonWriter.writeStringField("federatedIdentityClientId", this.encryptionFederatedIdentityClientId); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EncryptionIdentity from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EncryptionIdentity if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the EncryptionIdentity. + */ + public static EncryptionIdentity fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EncryptionIdentity deserializedEncryptionIdentity = new EncryptionIdentity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("userAssignedIdentity".equals(fieldName)) { + deserializedEncryptionIdentity.encryptionUserAssignedIdentity = reader.getString(); + } else if ("federatedIdentityClientId".equals(fieldName)) { + deserializedEncryptionIdentity.encryptionFederatedIdentityClientId = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedEncryptionIdentity; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/EncryptionService.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/EncryptionService.java new file mode 100644 index 0000000000000..07c2cb4595382 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/EncryptionService.java @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; + +/** + * A service that allows server-side encryption to be used. + */ +@Fluent +public final class EncryptionService implements JsonSerializable { + /* + * A boolean indicating whether or not the service encrypts the data as it is stored. Encryption at rest is enabled + * by default today and cannot be disabled. + */ + private Boolean enabled; + + /* + * Gets a rough estimate of the date/time when the encryption was last enabled by the user. Data is encrypted at + * rest by default today and cannot be disabled. + */ + private OffsetDateTime lastEnabledTime; + + /* + * Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped + * encryption key will be used. 'Service' key type implies that a default service key is used. + */ + private KeyType keyType; + + /** + * Creates an instance of EncryptionService class. + */ + public EncryptionService() { + } + + /** + * Get the enabled property: A boolean indicating whether or not the service encrypts the data as it is stored. + * Encryption at rest is enabled by default today and cannot be disabled. + * + * @return the enabled value. + */ + public Boolean enabled() { + return this.enabled; + } + + /** + * Set the enabled property: A boolean indicating whether or not the service encrypts the data as it is stored. + * Encryption at rest is enabled by default today and cannot be disabled. + * + * @param enabled the enabled value to set. + * @return the EncryptionService object itself. + */ + public EncryptionService withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Get the lastEnabledTime property: Gets a rough estimate of the date/time when the encryption was last enabled by + * the user. Data is encrypted at rest by default today and cannot be disabled. + * + * @return the lastEnabledTime value. + */ + public OffsetDateTime lastEnabledTime() { + return this.lastEnabledTime; + } + + /** + * Get the keyType property: Encryption key type to be used for the encryption service. 'Account' key type implies + * that an account-scoped encryption key will be used. 'Service' key type implies that a default service key is + * used. + * + * @return the keyType value. + */ + public KeyType keyType() { + return this.keyType; + } + + /** + * Set the keyType property: Encryption key type to be used for the encryption service. 'Account' key type implies + * that an account-scoped encryption key will be used. 'Service' key type implies that a default service key is + * used. + * + * @param keyType the keyType value to set. + * @return the EncryptionService object itself. + */ + public EncryptionService withKeyType(KeyType keyType) { + this.keyType = keyType; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("enabled", this.enabled); + jsonWriter.writeStringField("keyType", this.keyType == null ? null : this.keyType.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EncryptionService from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EncryptionService if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the EncryptionService. + */ + public static EncryptionService fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EncryptionService deserializedEncryptionService = new EncryptionService(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("enabled".equals(fieldName)) { + deserializedEncryptionService.enabled = reader.getNullable(JsonReader::getBoolean); + } else if ("lastEnabledTime".equals(fieldName)) { + deserializedEncryptionService.lastEnabledTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("keyType".equals(fieldName)) { + deserializedEncryptionService.keyType = KeyType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedEncryptionService; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/EncryptionServices.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/EncryptionServices.java new file mode 100644 index 0000000000000..19d6926e7b857 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/EncryptionServices.java @@ -0,0 +1,189 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A list of services that support encryption. + */ +@Fluent +public final class EncryptionServices implements JsonSerializable { + /* + * The encryption function of the blob storage service. + */ + private EncryptionService blob; + + /* + * The encryption function of the file storage service. + */ + private EncryptionService file; + + /* + * The encryption function of the table storage service. + */ + private EncryptionService table; + + /* + * The encryption function of the queue storage service. + */ + private EncryptionService queue; + + /** + * Creates an instance of EncryptionServices class. + */ + public EncryptionServices() { + } + + /** + * Get the blob property: The encryption function of the blob storage service. + * + * @return the blob value. + */ + public EncryptionService blob() { + return this.blob; + } + + /** + * Set the blob property: The encryption function of the blob storage service. + * + * @param blob the blob value to set. + * @return the EncryptionServices object itself. + */ + public EncryptionServices withBlob(EncryptionService blob) { + this.blob = blob; + return this; + } + + /** + * Get the file property: The encryption function of the file storage service. + * + * @return the file value. + */ + public EncryptionService file() { + return this.file; + } + + /** + * Set the file property: The encryption function of the file storage service. + * + * @param file the file value to set. + * @return the EncryptionServices object itself. + */ + public EncryptionServices withFile(EncryptionService file) { + this.file = file; + return this; + } + + /** + * Get the table property: The encryption function of the table storage service. + * + * @return the table value. + */ + public EncryptionService table() { + return this.table; + } + + /** + * Set the table property: The encryption function of the table storage service. + * + * @param table the table value to set. + * @return the EncryptionServices object itself. + */ + public EncryptionServices withTable(EncryptionService table) { + this.table = table; + return this; + } + + /** + * Get the queue property: The encryption function of the queue storage service. + * + * @return the queue value. + */ + public EncryptionService queue() { + return this.queue; + } + + /** + * Set the queue property: The encryption function of the queue storage service. + * + * @param queue the queue value to set. + * @return the EncryptionServices object itself. + */ + public EncryptionServices withQueue(EncryptionService queue) { + this.queue = queue; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (blob() != null) { + blob().validate(); + } + if (file() != null) { + file().validate(); + } + if (table() != null) { + table().validate(); + } + if (queue() != null) { + queue().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("blob", this.blob); + jsonWriter.writeJsonField("file", this.file); + jsonWriter.writeJsonField("table", this.table); + jsonWriter.writeJsonField("queue", this.queue); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EncryptionServices from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EncryptionServices if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the EncryptionServices. + */ + public static EncryptionServices fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EncryptionServices deserializedEncryptionServices = new EncryptionServices(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("blob".equals(fieldName)) { + deserializedEncryptionServices.blob = EncryptionService.fromJson(reader); + } else if ("file".equals(fieldName)) { + deserializedEncryptionServices.file = EncryptionService.fromJson(reader); + } else if ("table".equals(fieldName)) { + deserializedEncryptionServices.table = EncryptionService.fromJson(reader); + } else if ("queue".equals(fieldName)) { + deserializedEncryptionServices.queue = EncryptionService.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedEncryptionServices; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Endpoints.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Endpoints.java new file mode 100644 index 0000000000000..acfd2cad46d2c --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Endpoints.java @@ -0,0 +1,221 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object. + */ +@Immutable +public final class Endpoints implements JsonSerializable { + /* + * Gets the blob endpoint. + */ + private String blob; + + /* + * Gets the queue endpoint. + */ + private String queue; + + /* + * Gets the table endpoint. + */ + private String table; + + /* + * Gets the file endpoint. + */ + private String file; + + /* + * Gets the web endpoint. + */ + private String web; + + /* + * Gets the dfs endpoint. + */ + private String dfs; + + /* + * Gets the microsoft routing storage endpoints. + */ + private StorageAccountMicrosoftEndpoints microsoftEndpoints; + + /* + * Gets the internet routing storage endpoints + */ + private StorageAccountInternetEndpoints internetEndpoints; + + /* + * Gets the IPv6 storage endpoints. + */ + private StorageAccountIpv6Endpoints ipv6Endpoints; + + /** + * Creates an instance of Endpoints class. + */ + private Endpoints() { + } + + /** + * Get the blob property: Gets the blob endpoint. + * + * @return the blob value. + */ + public String blob() { + return this.blob; + } + + /** + * Get the queue property: Gets the queue endpoint. + * + * @return the queue value. + */ + public String queue() { + return this.queue; + } + + /** + * Get the table property: Gets the table endpoint. + * + * @return the table value. + */ + public String table() { + return this.table; + } + + /** + * Get the file property: Gets the file endpoint. + * + * @return the file value. + */ + public String file() { + return this.file; + } + + /** + * Get the web property: Gets the web endpoint. + * + * @return the web value. + */ + public String web() { + return this.web; + } + + /** + * Get the dfs property: Gets the dfs endpoint. + * + * @return the dfs value. + */ + public String dfs() { + return this.dfs; + } + + /** + * Get the microsoftEndpoints property: Gets the microsoft routing storage endpoints. + * + * @return the microsoftEndpoints value. + */ + public StorageAccountMicrosoftEndpoints microsoftEndpoints() { + return this.microsoftEndpoints; + } + + /** + * Get the internetEndpoints property: Gets the internet routing storage endpoints. + * + * @return the internetEndpoints value. + */ + public StorageAccountInternetEndpoints internetEndpoints() { + return this.internetEndpoints; + } + + /** + * Get the ipv6Endpoints property: Gets the IPv6 storage endpoints. + * + * @return the ipv6Endpoints value. + */ + public StorageAccountIpv6Endpoints ipv6Endpoints() { + return this.ipv6Endpoints; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (microsoftEndpoints() != null) { + microsoftEndpoints().validate(); + } + if (internetEndpoints() != null) { + internetEndpoints().validate(); + } + if (ipv6Endpoints() != null) { + ipv6Endpoints().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("microsoftEndpoints", this.microsoftEndpoints); + jsonWriter.writeJsonField("internetEndpoints", this.internetEndpoints); + jsonWriter.writeJsonField("ipv6Endpoints", this.ipv6Endpoints); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Endpoints from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Endpoints if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IOException If an error occurs while reading the Endpoints. + */ + public static Endpoints fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Endpoints deserializedEndpoints = new Endpoints(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("blob".equals(fieldName)) { + deserializedEndpoints.blob = reader.getString(); + } else if ("queue".equals(fieldName)) { + deserializedEndpoints.queue = reader.getString(); + } else if ("table".equals(fieldName)) { + deserializedEndpoints.table = reader.getString(); + } else if ("file".equals(fieldName)) { + deserializedEndpoints.file = reader.getString(); + } else if ("web".equals(fieldName)) { + deserializedEndpoints.web = reader.getString(); + } else if ("dfs".equals(fieldName)) { + deserializedEndpoints.dfs = reader.getString(); + } else if ("microsoftEndpoints".equals(fieldName)) { + deserializedEndpoints.microsoftEndpoints = StorageAccountMicrosoftEndpoints.fromJson(reader); + } else if ("internetEndpoints".equals(fieldName)) { + deserializedEndpoints.internetEndpoints = StorageAccountInternetEndpoints.fromJson(reader); + } else if ("ipv6Endpoints".equals(fieldName)) { + deserializedEndpoints.ipv6Endpoints = StorageAccountIpv6Endpoints.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedEndpoints; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ExpirationAction.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ExpirationAction.java new file mode 100644 index 0000000000000..7787092875683 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ExpirationAction.java @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The SAS Expiration Action defines the action to be performed when sasPolicy.sasExpirationPeriod is violated. The + * 'Log' action can be used for audit purposes and the 'Block' action can be used to block and deny the usage of SAS + * tokens that do not adhere to the sas policy expiration period. + */ +public final class ExpirationAction extends ExpandableStringEnum { + /** + * Static value Log for ExpirationAction. + */ + public static final ExpirationAction LOG = fromString("Log"); + + /** + * Static value Block for ExpirationAction. + */ + public static final ExpirationAction BLOCK = fromString("Block"); + + /** + * Creates a new instance of ExpirationAction value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ExpirationAction() { + } + + /** + * Creates or finds a ExpirationAction from its string representation. + * + * @param name a name to look for. + * @return the corresponding ExpirationAction. + */ + public static ExpirationAction fromString(String name) { + return fromString(name, ExpirationAction.class); + } + + /** + * Gets known ExpirationAction values. + * + * @return known ExpirationAction values. + */ + public static Collection values() { + return values(ExpirationAction.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ExtendedLocation.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ExtendedLocation.java new file mode 100644 index 0000000000000..80d61baa1a88e --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ExtendedLocation.java @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The complex type of the extended location. + */ +@Fluent +public final class ExtendedLocation implements JsonSerializable { + /* + * The name of the extended location. + */ + private String name; + + /* + * The type of the extended location. + */ + private ExtendedLocationTypes type; + + /** + * Creates an instance of ExtendedLocation class. + */ + public ExtendedLocation() { + } + + /** + * Get the name property: The name of the extended location. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name of the extended location. + * + * @param name the name value to set. + * @return the ExtendedLocation object itself. + */ + public ExtendedLocation withName(String name) { + this.name = name; + return this; + } + + /** + * Get the type property: The type of the extended location. + * + * @return the type value. + */ + public ExtendedLocationTypes type() { + return this.type; + } + + /** + * Set the type property: The type of the extended location. + * + * @param type the type value to set. + * @return the ExtendedLocation object itself. + */ + public ExtendedLocation withType(ExtendedLocationTypes type) { + this.type = type; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExtendedLocation from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExtendedLocation if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the ExtendedLocation. + */ + public static ExtendedLocation fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ExtendedLocation deserializedExtendedLocation = new ExtendedLocation(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedExtendedLocation.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedExtendedLocation.type = ExtendedLocationTypes.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedExtendedLocation; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ExtendedLocationTypes.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ExtendedLocationTypes.java new file mode 100644 index 0000000000000..6f0962dc0b46f --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ExtendedLocationTypes.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The type of extendedLocation. + */ +public final class ExtendedLocationTypes extends ExpandableStringEnum { + /** + * Static value EdgeZone for ExtendedLocationTypes. + */ + public static final ExtendedLocationTypes EDGE_ZONE = fromString("EdgeZone"); + + /** + * Creates a new instance of ExtendedLocationTypes value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ExtendedLocationTypes() { + } + + /** + * Creates or finds a ExtendedLocationTypes from its string representation. + * + * @param name a name to look for. + * @return the corresponding ExtendedLocationTypes. + */ + public static ExtendedLocationTypes fromString(String name) { + return fromString(name, ExtendedLocationTypes.class); + } + + /** + * Gets known ExtendedLocationTypes values. + * + * @return known ExtendedLocationTypes values. + */ + public static Collection values() { + return values(ExtendedLocationTypes.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/GeoPriorityReplicationStatus.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/GeoPriorityReplicationStatus.java new file mode 100644 index 0000000000000..2ee09cebe7ab8 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/GeoPriorityReplicationStatus.java @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Geo Priority Replication enablement status for the storage account. + */ +@Fluent +public final class GeoPriorityReplicationStatus implements JsonSerializable { + /* + * Indicates whether Blob Geo Priority Replication is enabled for the storage account. + */ + private Boolean isBlobEnabled; + + /** + * Creates an instance of GeoPriorityReplicationStatus class. + */ + public GeoPriorityReplicationStatus() { + } + + /** + * Get the isBlobEnabled property: Indicates whether Blob Geo Priority Replication is enabled for the storage + * account. + * + * @return the isBlobEnabled value. + */ + public Boolean isBlobEnabled() { + return this.isBlobEnabled; + } + + /** + * Set the isBlobEnabled property: Indicates whether Blob Geo Priority Replication is enabled for the storage + * account. + * + * @param isBlobEnabled the isBlobEnabled value to set. + * @return the GeoPriorityReplicationStatus object itself. + */ + public GeoPriorityReplicationStatus withIsBlobEnabled(Boolean isBlobEnabled) { + this.isBlobEnabled = isBlobEnabled; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("isBlobEnabled", this.isBlobEnabled); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GeoPriorityReplicationStatus from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GeoPriorityReplicationStatus if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the GeoPriorityReplicationStatus. + */ + public static GeoPriorityReplicationStatus fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GeoPriorityReplicationStatus deserializedGeoPriorityReplicationStatus = new GeoPriorityReplicationStatus(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("isBlobEnabled".equals(fieldName)) { + deserializedGeoPriorityReplicationStatus.isBlobEnabled = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + + return deserializedGeoPriorityReplicationStatus; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/GeoReplicationStats.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/GeoReplicationStats.java new file mode 100644 index 0000000000000..1cd64bc48106d --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/GeoReplicationStats.java @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; + +/** + * Statistics related to replication for storage account's Blob, Table, Queue and File services. It is only available + * when geo-redundant replication is enabled for the storage account. + */ +@Immutable +public final class GeoReplicationStats implements JsonSerializable { + /* + * The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is + * active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary + * location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that + * the secondary location is temporarily unavailable. + */ + private GeoReplicationStatus status; + + /* + * All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary + * writes following this point in time may or may not be available for reads. Element may be default value if value + * of LastSyncTime is not available, this can happen if secondary is offline or we are in bootstrap. + */ + private OffsetDateTime lastSyncTime; + + /* + * A boolean flag which indicates whether or not account failover is supported for the account. + */ + private Boolean canFailover; + + /* + * A boolean flag which indicates whether or not planned account failover is supported for the account. + */ + private Boolean canPlannedFailover; + + /* + * The redundancy type of the account after an account failover is performed. + */ + private PostFailoverRedundancy postFailoverRedundancy; + + /* + * The redundancy type of the account after a planned account failover is performed. + */ + private PostPlannedFailoverRedundancy postPlannedFailoverRedundancy; + + /** + * Creates an instance of GeoReplicationStats class. + */ + private GeoReplicationStats() { + } + + /** + * Get the status property: The status of the secondary location. Possible values are: - Live: Indicates that the + * secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary + * location to the secondary location is in progress.This typically occurs when replication is first enabled. - + * Unavailable: Indicates that the secondary location is temporarily unavailable. + * + * @return the status value. + */ + public GeoReplicationStatus status() { + return this.status; + } + + /** + * Get the lastSyncTime property: All primary writes preceding this UTC date/time value are guaranteed to be + * available for read operations. Primary writes following this point in time may or may not be available for reads. + * Element may be default value if value of LastSyncTime is not available, this can happen if secondary is offline + * or we are in bootstrap. + * + * @return the lastSyncTime value. + */ + public OffsetDateTime lastSyncTime() { + return this.lastSyncTime; + } + + /** + * Get the canFailover property: A boolean flag which indicates whether or not account failover is supported for the + * account. + * + * @return the canFailover value. + */ + public Boolean canFailover() { + return this.canFailover; + } + + /** + * Get the canPlannedFailover property: A boolean flag which indicates whether or not planned account failover is + * supported for the account. + * + * @return the canPlannedFailover value. + */ + public Boolean canPlannedFailover() { + return this.canPlannedFailover; + } + + /** + * Get the postFailoverRedundancy property: The redundancy type of the account after an account failover is + * performed. + * + * @return the postFailoverRedundancy value. + */ + public PostFailoverRedundancy postFailoverRedundancy() { + return this.postFailoverRedundancy; + } + + /** + * Get the postPlannedFailoverRedundancy property: The redundancy type of the account after a planned account + * failover is performed. + * + * @return the postPlannedFailoverRedundancy value. + */ + public PostPlannedFailoverRedundancy postPlannedFailoverRedundancy() { + return this.postPlannedFailoverRedundancy; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GeoReplicationStats from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GeoReplicationStats if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the GeoReplicationStats. + */ + public static GeoReplicationStats fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GeoReplicationStats deserializedGeoReplicationStats = new GeoReplicationStats(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("status".equals(fieldName)) { + deserializedGeoReplicationStats.status = GeoReplicationStatus.fromString(reader.getString()); + } else if ("lastSyncTime".equals(fieldName)) { + deserializedGeoReplicationStats.lastSyncTime = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("canFailover".equals(fieldName)) { + deserializedGeoReplicationStats.canFailover = reader.getNullable(JsonReader::getBoolean); + } else if ("canPlannedFailover".equals(fieldName)) { + deserializedGeoReplicationStats.canPlannedFailover = reader.getNullable(JsonReader::getBoolean); + } else if ("postFailoverRedundancy".equals(fieldName)) { + deserializedGeoReplicationStats.postFailoverRedundancy + = PostFailoverRedundancy.fromString(reader.getString()); + } else if ("postPlannedFailoverRedundancy".equals(fieldName)) { + deserializedGeoReplicationStats.postPlannedFailoverRedundancy + = PostPlannedFailoverRedundancy.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedGeoReplicationStats; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/GeoReplicationStatus.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/GeoReplicationStatus.java new file mode 100644 index 0000000000000..2364cad52efea --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/GeoReplicationStatus.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active + * and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location + * is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary + * location is temporarily unavailable. + */ +public final class GeoReplicationStatus extends ExpandableStringEnum { + /** + * Static value Live for GeoReplicationStatus. + */ + public static final GeoReplicationStatus LIVE = fromString("Live"); + + /** + * Static value Bootstrap for GeoReplicationStatus. + */ + public static final GeoReplicationStatus BOOTSTRAP = fromString("Bootstrap"); + + /** + * Static value Unavailable for GeoReplicationStatus. + */ + public static final GeoReplicationStatus UNAVAILABLE = fromString("Unavailable"); + + /** + * Creates a new instance of GeoReplicationStatus value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public GeoReplicationStatus() { + } + + /** + * Creates or finds a GeoReplicationStatus from its string representation. + * + * @param name a name to look for. + * @return the corresponding GeoReplicationStatus. + */ + public static GeoReplicationStatus fromString(String name) { + return fromString(name, GeoReplicationStatus.class); + } + + /** + * Gets known GeoReplicationStatus values. + * + * @return known GeoReplicationStatus values. + */ + public static Collection values() { + return values(GeoReplicationStatus.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Identity.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Identity.java new file mode 100644 index 0000000000000..9705236a59725 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Identity.java @@ -0,0 +1,178 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Identity for the resource. + */ +@Fluent +public final class Identity implements JsonSerializable { + /* + * The principal ID of resource identity. + */ + private String principalId; + + /* + * The tenant ID of resource. + */ + private String tenantId; + + /* + * The identity type. + */ + private IdentityType type; + + /* + * Gets or sets a list of key value pairs that describe the set of User Assigned identities that will be used with + * this storage account. The key is the ARM resource identifier of the identity. Only 1 User Assigned identity is + * permitted here. + */ + private Map userAssignedIdentities; + + /** + * Creates an instance of Identity class. + */ + public Identity() { + } + + /** + * Get the principalId property: The principal ID of resource identity. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the tenantId property: The tenant ID of resource. + * + * @return the tenantId value. + */ + public String tenantId() { + return this.tenantId; + } + + /** + * Get the type property: The identity type. + * + * @return the type value. + */ + public IdentityType type() { + return this.type; + } + + /** + * Set the type property: The identity type. + * + * @param type the type value to set. + * @return the Identity object itself. + */ + public Identity withType(IdentityType type) { + this.type = type; + return this; + } + + /** + * Get the userAssignedIdentities property: Gets or sets a list of key value pairs that describe the set of User + * Assigned identities that will be used with this storage account. The key is the ARM resource identifier of the + * identity. Only 1 User Assigned identity is permitted here. + * + * @return the userAssignedIdentities value. + */ + public Map userAssignedIdentities() { + return this.userAssignedIdentities; + } + + /** + * Set the userAssignedIdentities property: Gets or sets a list of key value pairs that describe the set of User + * Assigned identities that will be used with this storage account. The key is the ARM resource identifier of the + * identity. Only 1 User Assigned identity is permitted here. + * + * @param userAssignedIdentities the userAssignedIdentities value to set. + * @return the Identity object itself. + */ + public Identity withUserAssignedIdentities(Map userAssignedIdentities) { + this.userAssignedIdentities = userAssignedIdentities; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (type() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property type in model Identity")); + } + if (userAssignedIdentities() != null) { + userAssignedIdentities().values().forEach(e -> { + if (e != null) { + e.validate(); + } + }); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(Identity.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeMapField("userAssignedIdentities", this.userAssignedIdentities, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Identity from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Identity if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Identity. + */ + public static Identity fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Identity deserializedIdentity = new Identity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedIdentity.type = IdentityType.fromString(reader.getString()); + } else if ("principalId".equals(fieldName)) { + deserializedIdentity.principalId = reader.getString(); + } else if ("tenantId".equals(fieldName)) { + deserializedIdentity.tenantId = reader.getString(); + } else if ("userAssignedIdentities".equals(fieldName)) { + Map userAssignedIdentities + = reader.readMap(reader1 -> UserAssignedIdentity.fromJson(reader1)); + deserializedIdentity.userAssignedIdentities = userAssignedIdentities; + } else { + reader.skipChildren(); + } + } + + return deserializedIdentity; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/IdentityType.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/IdentityType.java new file mode 100644 index 0000000000000..74d1793bf83f5 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/IdentityType.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The identity type. + */ +public final class IdentityType extends ExpandableStringEnum { + /** + * Static value None for IdentityType. + */ + public static final IdentityType NONE = fromString("None"); + + /** + * Static value SystemAssigned for IdentityType. + */ + public static final IdentityType SYSTEM_ASSIGNED = fromString("SystemAssigned"); + + /** + * Static value UserAssigned for IdentityType. + */ + public static final IdentityType USER_ASSIGNED = fromString("UserAssigned"); + + /** + * Static value SystemAssigned,UserAssigned for IdentityType. + */ + public static final IdentityType SYSTEM_ASSIGNED_USER_ASSIGNED = fromString("SystemAssigned,UserAssigned"); + + /** + * Creates a new instance of IdentityType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public IdentityType() { + } + + /** + * Creates or finds a IdentityType from its string representation. + * + * @param name a name to look for. + * @return the corresponding IdentityType. + */ + public static IdentityType fromString(String name) { + return fromString(name, IdentityType.class); + } + + /** + * Gets known IdentityType values. + * + * @return known IdentityType values. + */ + public static Collection values() { + return values(IdentityType.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ImmutableStorageAccount.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ImmutableStorageAccount.java new file mode 100644 index 0000000000000..d95e1e3bcda13 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ImmutableStorageAccount.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * This property enables and defines account-level immutability. Enabling the feature auto-enables Blob Versioning. + */ +@Fluent +public final class ImmutableStorageAccount implements JsonSerializable { + /* + * A boolean flag which enables account-level immutability. All the containers under such an account have + * object-level immutability enabled by default. + */ + private Boolean enabled; + + /* + * Specifies the default account-level immutability policy which is inherited and applied to objects that do not + * possess an explicit immutability policy at the object level. The object-level immutability policy has higher + * precedence than the container-level immutability policy, which has a higher precedence than the account-level + * immutability policy. + */ + private AccountImmutabilityPolicyProperties immutabilityPolicy; + + /** + * Creates an instance of ImmutableStorageAccount class. + */ + public ImmutableStorageAccount() { + } + + /** + * Get the enabled property: A boolean flag which enables account-level immutability. All the containers under such + * an account have object-level immutability enabled by default. + * + * @return the enabled value. + */ + public Boolean enabled() { + return this.enabled; + } + + /** + * Set the enabled property: A boolean flag which enables account-level immutability. All the containers under such + * an account have object-level immutability enabled by default. + * + * @param enabled the enabled value to set. + * @return the ImmutableStorageAccount object itself. + */ + public ImmutableStorageAccount withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Get the immutabilityPolicy property: Specifies the default account-level immutability policy which is inherited + * and applied to objects that do not possess an explicit immutability policy at the object level. The object-level + * immutability policy has higher precedence than the container-level immutability policy, which has a higher + * precedence than the account-level immutability policy. + * + * @return the immutabilityPolicy value. + */ + public AccountImmutabilityPolicyProperties immutabilityPolicy() { + return this.immutabilityPolicy; + } + + /** + * Set the immutabilityPolicy property: Specifies the default account-level immutability policy which is inherited + * and applied to objects that do not possess an explicit immutability policy at the object level. The object-level + * immutability policy has higher precedence than the container-level immutability policy, which has a higher + * precedence than the account-level immutability policy. + * + * @param immutabilityPolicy the immutabilityPolicy value to set. + * @return the ImmutableStorageAccount object itself. + */ + public ImmutableStorageAccount withImmutabilityPolicy(AccountImmutabilityPolicyProperties immutabilityPolicy) { + this.immutabilityPolicy = immutabilityPolicy; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (immutabilityPolicy() != null) { + immutabilityPolicy().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("enabled", this.enabled); + jsonWriter.writeJsonField("immutabilityPolicy", this.immutabilityPolicy); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ImmutableStorageAccount from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ImmutableStorageAccount if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the ImmutableStorageAccount. + */ + public static ImmutableStorageAccount fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ImmutableStorageAccount deserializedImmutableStorageAccount = new ImmutableStorageAccount(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("enabled".equals(fieldName)) { + deserializedImmutableStorageAccount.enabled = reader.getNullable(JsonReader::getBoolean); + } else if ("immutabilityPolicy".equals(fieldName)) { + deserializedImmutableStorageAccount.immutabilityPolicy + = AccountImmutabilityPolicyProperties.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedImmutableStorageAccount; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/IpRule.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/IpRule.java new file mode 100644 index 0000000000000..fc155f6c6fb95 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/IpRule.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * IP rule with specific IP or IP range in CIDR format. + */ +@Fluent +public final class IpRule implements JsonSerializable { + /* + * Specifies the IP or IP range in CIDR format. + */ + private String ipAddressOrRange; + + /* + * The action of IP ACL rule. + */ + private Action action; + + /** + * Creates an instance of IpRule class. + */ + public IpRule() { + } + + /** + * Get the ipAddressOrRange property: Specifies the IP or IP range in CIDR format. + * + * @return the ipAddressOrRange value. + */ + public String ipAddressOrRange() { + return this.ipAddressOrRange; + } + + /** + * Set the ipAddressOrRange property: Specifies the IP or IP range in CIDR format. + * + * @param ipAddressOrRange the ipAddressOrRange value to set. + * @return the IpRule object itself. + */ + public IpRule withIpAddressOrRange(String ipAddressOrRange) { + this.ipAddressOrRange = ipAddressOrRange; + return this; + } + + /** + * Get the action property: The action of IP ACL rule. + * + * @return the action value. + */ + public Action action() { + return this.action; + } + + /** + * Set the action property: The action of IP ACL rule. + * + * @param action the action value to set. + * @return the IpRule object itself. + */ + public IpRule withAction(Action action) { + this.action = action; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (ipAddressOrRange() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property ipAddressOrRange in model IpRule")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(IpRule.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("value", this.ipAddressOrRange); + jsonWriter.writeStringField("action", this.action == null ? null : this.action.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IpRule from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IpRule if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the IpRule. + */ + public static IpRule fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + IpRule deserializedIpRule = new IpRule(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + deserializedIpRule.ipAddressOrRange = reader.getString(); + } else if ("action".equals(fieldName)) { + deserializedIpRule.action = Action.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedIpRule; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/KeyCreationTime.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/KeyCreationTime.java new file mode 100644 index 0000000000000..38658701a25e7 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/KeyCreationTime.java @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; + +/** + * Storage account keys creation time. + */ +@Immutable +public final class KeyCreationTime implements JsonSerializable { + /* + * The key1 property. + */ + private OffsetDateTime key1; + + /* + * The key2 property. + */ + private OffsetDateTime key2; + + /** + * Creates an instance of KeyCreationTime class. + */ + private KeyCreationTime() { + } + + /** + * Get the key1 property: The key1 property. + * + * @return the key1 value. + */ + public OffsetDateTime key1() { + return this.key1; + } + + /** + * Get the key2 property: The key2 property. + * + * @return the key2 value. + */ + public OffsetDateTime key2() { + return this.key2; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("key1", + this.key1 == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.key1)); + jsonWriter.writeStringField("key2", + this.key2 == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.key2)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of KeyCreationTime from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of KeyCreationTime if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the KeyCreationTime. + */ + public static KeyCreationTime fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + KeyCreationTime deserializedKeyCreationTime = new KeyCreationTime(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("key1".equals(fieldName)) { + deserializedKeyCreationTime.key1 = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("key2".equals(fieldName)) { + deserializedKeyCreationTime.key2 = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedKeyCreationTime; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/KeyPolicy.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/KeyPolicy.java new file mode 100644 index 0000000000000..b55d7dc8910b0 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/KeyPolicy.java @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * KeyPolicy assigned to the storage account. + */ +@Fluent +public final class KeyPolicy implements JsonSerializable { + /* + * The key expiration period in days. + */ + private int keyExpirationPeriodInDays; + + /** + * Creates an instance of KeyPolicy class. + */ + public KeyPolicy() { + } + + /** + * Get the keyExpirationPeriodInDays property: The key expiration period in days. + * + * @return the keyExpirationPeriodInDays value. + */ + public int keyExpirationPeriodInDays() { + return this.keyExpirationPeriodInDays; + } + + /** + * Set the keyExpirationPeriodInDays property: The key expiration period in days. + * + * @param keyExpirationPeriodInDays the keyExpirationPeriodInDays value to set. + * @return the KeyPolicy object itself. + */ + public KeyPolicy withKeyExpirationPeriodInDays(int keyExpirationPeriodInDays) { + this.keyExpirationPeriodInDays = keyExpirationPeriodInDays; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("keyExpirationPeriodInDays", this.keyExpirationPeriodInDays); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of KeyPolicy from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of KeyPolicy if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the KeyPolicy. + */ + public static KeyPolicy fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + KeyPolicy deserializedKeyPolicy = new KeyPolicy(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("keyExpirationPeriodInDays".equals(fieldName)) { + deserializedKeyPolicy.keyExpirationPeriodInDays = reader.getInt(); + } else { + reader.skipChildren(); + } + } + + return deserializedKeyPolicy; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/KeySource.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/KeySource.java new file mode 100644 index 0000000000000..73653da169e11 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/KeySource.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. + */ +public final class KeySource extends ExpandableStringEnum { + /** + * Static value Microsoft.Storage for KeySource. + */ + public static final KeySource MICROSOFT_STORAGE = fromString("Microsoft.Storage"); + + /** + * Static value Microsoft.Keyvault for KeySource. + */ + public static final KeySource MICROSOFT_KEYVAULT = fromString("Microsoft.Keyvault"); + + /** + * Creates a new instance of KeySource value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public KeySource() { + } + + /** + * Creates or finds a KeySource from its string representation. + * + * @param name a name to look for. + * @return the corresponding KeySource. + */ + public static KeySource fromString(String name) { + return fromString(name, KeySource.class); + } + + /** + * Gets known KeySource values. + * + * @return known KeySource values. + */ + public static Collection values() { + return values(KeySource.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/KeyType.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/KeyType.java new file mode 100644 index 0000000000000..755cb62628fc8 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/KeyType.java @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped + * encryption key will be used. 'Service' key type implies that a default service key is used. + */ +public final class KeyType extends ExpandableStringEnum { + /** + * Static value Service for KeyType. + */ + public static final KeyType SERVICE = fromString("Service"); + + /** + * Static value Account for KeyType. + */ + public static final KeyType ACCOUNT = fromString("Account"); + + /** + * Creates a new instance of KeyType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public KeyType() { + } + + /** + * Creates or finds a KeyType from its string representation. + * + * @param name a name to look for. + * @return the corresponding KeyType. + */ + public static KeyType fromString(String name) { + return fromString(name, KeyType.class); + } + + /** + * Gets known KeyType values. + * + * @return known KeyType values. + */ + public static Collection values() { + return values(KeyType.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/KeyVaultProperties.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/KeyVaultProperties.java new file mode 100644 index 0000000000000..c04087bb814b5 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/KeyVaultProperties.java @@ -0,0 +1,204 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.CoreUtils; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; + +/** + * Properties of key vault. + */ +@Fluent +public final class KeyVaultProperties implements JsonSerializable { + /* + * The name of KeyVault key. + */ + private String keyName; + + /* + * The version of KeyVault key. + */ + private String keyVersion; + + /* + * The Uri of KeyVault. + */ + private String keyVaultUri; + + /* + * The object identifier of the current versioned Key Vault Key in use. + */ + private String currentVersionedKeyIdentifier; + + /* + * Timestamp of last rotation of the Key Vault Key. + */ + private OffsetDateTime lastKeyRotationTimestamp; + + /* + * This is a read only property that represents the expiration time of the current version of the customer managed + * key used for encryption. + */ + private OffsetDateTime currentVersionedKeyExpirationTimestamp; + + /** + * Creates an instance of KeyVaultProperties class. + */ + public KeyVaultProperties() { + } + + /** + * Get the keyName property: The name of KeyVault key. + * + * @return the keyName value. + */ + public String keyName() { + return this.keyName; + } + + /** + * Set the keyName property: The name of KeyVault key. + * + * @param keyName the keyName value to set. + * @return the KeyVaultProperties object itself. + */ + public KeyVaultProperties withKeyName(String keyName) { + this.keyName = keyName; + return this; + } + + /** + * Get the keyVersion property: The version of KeyVault key. + * + * @return the keyVersion value. + */ + public String keyVersion() { + return this.keyVersion; + } + + /** + * Set the keyVersion property: The version of KeyVault key. + * + * @param keyVersion the keyVersion value to set. + * @return the KeyVaultProperties object itself. + */ + public KeyVaultProperties withKeyVersion(String keyVersion) { + this.keyVersion = keyVersion; + return this; + } + + /** + * Get the keyVaultUri property: The Uri of KeyVault. + * + * @return the keyVaultUri value. + */ + public String keyVaultUri() { + return this.keyVaultUri; + } + + /** + * Set the keyVaultUri property: The Uri of KeyVault. + * + * @param keyVaultUri the keyVaultUri value to set. + * @return the KeyVaultProperties object itself. + */ + public KeyVaultProperties withKeyVaultUri(String keyVaultUri) { + this.keyVaultUri = keyVaultUri; + return this; + } + + /** + * Get the currentVersionedKeyIdentifier property: The object identifier of the current versioned Key Vault Key in + * use. + * + * @return the currentVersionedKeyIdentifier value. + */ + public String currentVersionedKeyIdentifier() { + return this.currentVersionedKeyIdentifier; + } + + /** + * Get the lastKeyRotationTimestamp property: Timestamp of last rotation of the Key Vault Key. + * + * @return the lastKeyRotationTimestamp value. + */ + public OffsetDateTime lastKeyRotationTimestamp() { + return this.lastKeyRotationTimestamp; + } + + /** + * Get the currentVersionedKeyExpirationTimestamp property: This is a read only property that represents the + * expiration time of the current version of the customer managed key used for encryption. + * + * @return the currentVersionedKeyExpirationTimestamp value. + */ + public OffsetDateTime currentVersionedKeyExpirationTimestamp() { + return this.currentVersionedKeyExpirationTimestamp; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("keyname", this.keyName); + jsonWriter.writeStringField("keyversion", this.keyVersion); + jsonWriter.writeStringField("keyvaulturi", this.keyVaultUri); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of KeyVaultProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of KeyVaultProperties if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the KeyVaultProperties. + */ + public static KeyVaultProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + KeyVaultProperties deserializedKeyVaultProperties = new KeyVaultProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("keyname".equals(fieldName)) { + deserializedKeyVaultProperties.keyName = reader.getString(); + } else if ("keyversion".equals(fieldName)) { + deserializedKeyVaultProperties.keyVersion = reader.getString(); + } else if ("keyvaulturi".equals(fieldName)) { + deserializedKeyVaultProperties.keyVaultUri = reader.getString(); + } else if ("currentVersionedKeyIdentifier".equals(fieldName)) { + deserializedKeyVaultProperties.currentVersionedKeyIdentifier = reader.getString(); + } else if ("lastKeyRotationTimestamp".equals(fieldName)) { + deserializedKeyVaultProperties.lastKeyRotationTimestamp = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else if ("currentVersionedKeyExpirationTimestamp".equals(fieldName)) { + deserializedKeyVaultProperties.currentVersionedKeyExpirationTimestamp = reader + .getNullable(nonNullReader -> CoreUtils.parseBestOffsetDateTime(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedKeyVaultProperties; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Kind.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Kind.java new file mode 100644 index 0000000000000..c455ca7f48605 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Kind.java @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Indicates the type of storage account. + */ +public final class Kind extends ExpandableStringEnum { + /** + * Static value Storage for Kind. + */ + public static final Kind STORAGE = fromString("Storage"); + + /** + * Static value StorageV2 for Kind. + */ + public static final Kind STORAGE_V2 = fromString("StorageV2"); + + /** + * Static value BlobStorage for Kind. + */ + public static final Kind BLOB_STORAGE = fromString("BlobStorage"); + + /** + * Static value FileStorage for Kind. + */ + public static final Kind FILE_STORAGE = fromString("FileStorage"); + + /** + * Static value BlockBlobStorage for Kind. + */ + public static final Kind BLOCK_BLOB_STORAGE = fromString("BlockBlobStorage"); + + /** + * Creates a new instance of Kind value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public Kind() { + } + + /** + * Creates or finds a Kind from its string representation. + * + * @param name a name to look for. + * @return the corresponding Kind. + */ + public static Kind fromString(String name) { + return fromString(name, Kind.class); + } + + /** + * Gets known Kind values. + * + * @return known Kind values. + */ + public static Collection values() { + return values(Kind.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/LargeFileSharesState.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/LargeFileSharesState.java new file mode 100644 index 0000000000000..ff340470cba39 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/LargeFileSharesState.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. + */ +public final class LargeFileSharesState extends ExpandableStringEnum { + /** + * Static value Disabled for LargeFileSharesState. + */ + public static final LargeFileSharesState DISABLED = fromString("Disabled"); + + /** + * Static value Enabled for LargeFileSharesState. + */ + public static final LargeFileSharesState ENABLED = fromString("Enabled"); + + /** + * Creates a new instance of LargeFileSharesState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public LargeFileSharesState() { + } + + /** + * Creates or finds a LargeFileSharesState from its string representation. + * + * @param name a name to look for. + * @return the corresponding LargeFileSharesState. + */ + public static LargeFileSharesState fromString(String name) { + return fromString(name, LargeFileSharesState.class); + } + + /** + * Gets known LargeFileSharesState values. + * + * @return known LargeFileSharesState values. + */ + public static Collection values() { + return values(LargeFileSharesState.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/MinimumTlsVersion.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/MinimumTlsVersion.java new file mode 100644 index 0000000000000..70f395e59ee70 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/MinimumTlsVersion.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this + * property. Minimum TLS version 1.3 version is not supported. + */ +public final class MinimumTlsVersion extends ExpandableStringEnum { + /** + * Static value TLS1_0 for MinimumTlsVersion. + */ + public static final MinimumTlsVersion TLS1_0 = fromString("TLS1_0"); + + /** + * Static value TLS1_1 for MinimumTlsVersion. + */ + public static final MinimumTlsVersion TLS1_1 = fromString("TLS1_1"); + + /** + * Static value TLS1_2 for MinimumTlsVersion. + */ + public static final MinimumTlsVersion TLS1_2 = fromString("TLS1_2"); + + /** + * Static value TLS1_3 for MinimumTlsVersion. + */ + public static final MinimumTlsVersion TLS1_3 = fromString("TLS1_3"); + + /** + * Creates a new instance of MinimumTlsVersion value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public MinimumTlsVersion() { + } + + /** + * Creates or finds a MinimumTlsVersion from its string representation. + * + * @param name a name to look for. + * @return the corresponding MinimumTlsVersion. + */ + public static MinimumTlsVersion fromString(String name) { + return fromString(name, MinimumTlsVersion.class); + } + + /** + * Gets known MinimumTlsVersion values. + * + * @return known MinimumTlsVersion values. + */ + public static Collection values() { + return values(MinimumTlsVersion.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/NetworkRuleSet.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/NetworkRuleSet.java new file mode 100644 index 0000000000000..946934fdf4f2a --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/NetworkRuleSet.java @@ -0,0 +1,267 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Network rule set. + */ +@Fluent +public final class NetworkRuleSet implements JsonSerializable { + /* + * Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of + * Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. + */ + private Bypass bypass; + + /* + * Sets the resource access rules + */ + private List resourceAccessRules; + + /* + * Sets the virtual network rules + */ + private List virtualNetworkRules; + + /* + * Sets the IP ACL rules + */ + private List ipRules; + + /* + * Sets the IPv6 ACL rules. + */ + private List ipv6Rules; + + /* + * Specifies the default action of allow or deny when no other rules match. + */ + private DefaultAction defaultAction; + + /** + * Creates an instance of NetworkRuleSet class. + */ + public NetworkRuleSet() { + } + + /** + * Get the bypass property: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values + * are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of + * those traffics. + * + * @return the bypass value. + */ + public Bypass bypass() { + return this.bypass; + } + + /** + * Set the bypass property: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values + * are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of + * those traffics. + * + * @param bypass the bypass value to set. + * @return the NetworkRuleSet object itself. + */ + public NetworkRuleSet withBypass(Bypass bypass) { + this.bypass = bypass; + return this; + } + + /** + * Get the resourceAccessRules property: Sets the resource access rules. + * + * @return the resourceAccessRules value. + */ + public List resourceAccessRules() { + return this.resourceAccessRules; + } + + /** + * Set the resourceAccessRules property: Sets the resource access rules. + * + * @param resourceAccessRules the resourceAccessRules value to set. + * @return the NetworkRuleSet object itself. + */ + public NetworkRuleSet withResourceAccessRules(List resourceAccessRules) { + this.resourceAccessRules = resourceAccessRules; + return this; + } + + /** + * Get the virtualNetworkRules property: Sets the virtual network rules. + * + * @return the virtualNetworkRules value. + */ + public List virtualNetworkRules() { + return this.virtualNetworkRules; + } + + /** + * Set the virtualNetworkRules property: Sets the virtual network rules. + * + * @param virtualNetworkRules the virtualNetworkRules value to set. + * @return the NetworkRuleSet object itself. + */ + public NetworkRuleSet withVirtualNetworkRules(List virtualNetworkRules) { + this.virtualNetworkRules = virtualNetworkRules; + return this; + } + + /** + * Get the ipRules property: Sets the IP ACL rules. + * + * @return the ipRules value. + */ + public List ipRules() { + return this.ipRules; + } + + /** + * Set the ipRules property: Sets the IP ACL rules. + * + * @param ipRules the ipRules value to set. + * @return the NetworkRuleSet object itself. + */ + public NetworkRuleSet withIpRules(List ipRules) { + this.ipRules = ipRules; + return this; + } + + /** + * Get the ipv6Rules property: Sets the IPv6 ACL rules. + * + * @return the ipv6Rules value. + */ + public List ipv6Rules() { + return this.ipv6Rules; + } + + /** + * Set the ipv6Rules property: Sets the IPv6 ACL rules. + * + * @param ipv6Rules the ipv6Rules value to set. + * @return the NetworkRuleSet object itself. + */ + public NetworkRuleSet withIpv6Rules(List ipv6Rules) { + this.ipv6Rules = ipv6Rules; + return this; + } + + /** + * Get the defaultAction property: Specifies the default action of allow or deny when no other rules match. + * + * @return the defaultAction value. + */ + public DefaultAction defaultAction() { + return this.defaultAction; + } + + /** + * Set the defaultAction property: Specifies the default action of allow or deny when no other rules match. + * + * @param defaultAction the defaultAction value to set. + * @return the NetworkRuleSet object itself. + */ + public NetworkRuleSet withDefaultAction(DefaultAction defaultAction) { + this.defaultAction = defaultAction; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (resourceAccessRules() != null) { + resourceAccessRules().forEach(e -> e.validate()); + } + if (virtualNetworkRules() != null) { + virtualNetworkRules().forEach(e -> e.validate()); + } + if (ipRules() != null) { + ipRules().forEach(e -> e.validate()); + } + if (ipv6Rules() != null) { + ipv6Rules().forEach(e -> e.validate()); + } + if (defaultAction() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property defaultAction in model NetworkRuleSet")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(NetworkRuleSet.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("defaultAction", this.defaultAction == null ? null : this.defaultAction.toString()); + jsonWriter.writeStringField("bypass", this.bypass == null ? null : this.bypass.toString()); + jsonWriter.writeArrayField("resourceAccessRules", this.resourceAccessRules, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("virtualNetworkRules", this.virtualNetworkRules, + (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("ipRules", this.ipRules, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("ipv6Rules", this.ipv6Rules, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of NetworkRuleSet from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of NetworkRuleSet if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the NetworkRuleSet. + */ + public static NetworkRuleSet fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + NetworkRuleSet deserializedNetworkRuleSet = new NetworkRuleSet(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("defaultAction".equals(fieldName)) { + deserializedNetworkRuleSet.defaultAction = DefaultAction.fromString(reader.getString()); + } else if ("bypass".equals(fieldName)) { + deserializedNetworkRuleSet.bypass = Bypass.fromString(reader.getString()); + } else if ("resourceAccessRules".equals(fieldName)) { + List resourceAccessRules + = reader.readArray(reader1 -> ResourceAccessRule.fromJson(reader1)); + deserializedNetworkRuleSet.resourceAccessRules = resourceAccessRules; + } else if ("virtualNetworkRules".equals(fieldName)) { + List virtualNetworkRules + = reader.readArray(reader1 -> VirtualNetworkRule.fromJson(reader1)); + deserializedNetworkRuleSet.virtualNetworkRules = virtualNetworkRules; + } else if ("ipRules".equals(fieldName)) { + List ipRules = reader.readArray(reader1 -> IpRule.fromJson(reader1)); + deserializedNetworkRuleSet.ipRules = ipRules; + } else if ("ipv6Rules".equals(fieldName)) { + List ipv6Rules = reader.readArray(reader1 -> IpRule.fromJson(reader1)); + deserializedNetworkRuleSet.ipv6Rules = ipv6Rules; + } else { + reader.skipChildren(); + } + } + + return deserializedNetworkRuleSet; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Placement.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Placement.java new file mode 100644 index 0000000000000..53bf341d2fe43 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Placement.java @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The complex type of the zonal placement details. + */ +@Fluent +public final class Placement implements JsonSerializable { + /* + * The availability zone pinning policy for the storage account. + */ + private ZonePlacementPolicy zonePlacementPolicy; + + /** + * Creates an instance of Placement class. + */ + public Placement() { + } + + /** + * Get the zonePlacementPolicy property: The availability zone pinning policy for the storage account. + * + * @return the zonePlacementPolicy value. + */ + public ZonePlacementPolicy zonePlacementPolicy() { + return this.zonePlacementPolicy; + } + + /** + * Set the zonePlacementPolicy property: The availability zone pinning policy for the storage account. + * + * @param zonePlacementPolicy the zonePlacementPolicy value to set. + * @return the Placement object itself. + */ + public Placement withZonePlacementPolicy(ZonePlacementPolicy zonePlacementPolicy) { + this.zonePlacementPolicy = zonePlacementPolicy; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("zonePlacementPolicy", + this.zonePlacementPolicy == null ? null : this.zonePlacementPolicy.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Placement from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Placement if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IOException If an error occurs while reading the Placement. + */ + public static Placement fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Placement deserializedPlacement = new Placement(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("zonePlacementPolicy".equals(fieldName)) { + deserializedPlacement.zonePlacementPolicy = ZonePlacementPolicy.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedPlacement; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PostFailoverRedundancy.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PostFailoverRedundancy.java new file mode 100644 index 0000000000000..0b5a5896ee89c --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PostFailoverRedundancy.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The redundancy type of the account after an account failover is performed. + */ +public final class PostFailoverRedundancy extends ExpandableStringEnum { + /** + * Static value Standard_LRS for PostFailoverRedundancy. + */ + public static final PostFailoverRedundancy STANDARD_LRS = fromString("Standard_LRS"); + + /** + * Static value Standard_ZRS for PostFailoverRedundancy. + */ + public static final PostFailoverRedundancy STANDARD_ZRS = fromString("Standard_ZRS"); + + /** + * Creates a new instance of PostFailoverRedundancy value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public PostFailoverRedundancy() { + } + + /** + * Creates or finds a PostFailoverRedundancy from its string representation. + * + * @param name a name to look for. + * @return the corresponding PostFailoverRedundancy. + */ + public static PostFailoverRedundancy fromString(String name) { + return fromString(name, PostFailoverRedundancy.class); + } + + /** + * Gets known PostFailoverRedundancy values. + * + * @return known PostFailoverRedundancy values. + */ + public static Collection values() { + return values(PostFailoverRedundancy.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PostPlannedFailoverRedundancy.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PostPlannedFailoverRedundancy.java new file mode 100644 index 0000000000000..4587140166b2b --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PostPlannedFailoverRedundancy.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The redundancy type of the account after a planned account failover is performed. + */ +public final class PostPlannedFailoverRedundancy extends ExpandableStringEnum { + /** + * Static value Standard_GRS for PostPlannedFailoverRedundancy. + */ + public static final PostPlannedFailoverRedundancy STANDARD_GRS = fromString("Standard_GRS"); + + /** + * Static value Standard_GZRS for PostPlannedFailoverRedundancy. + */ + public static final PostPlannedFailoverRedundancy STANDARD_GZRS = fromString("Standard_GZRS"); + + /** + * Static value Standard_RAGRS for PostPlannedFailoverRedundancy. + */ + public static final PostPlannedFailoverRedundancy STANDARD_RAGRS = fromString("Standard_RAGRS"); + + /** + * Static value Standard_RAGZRS for PostPlannedFailoverRedundancy. + */ + public static final PostPlannedFailoverRedundancy STANDARD_RAGZRS = fromString("Standard_RAGZRS"); + + /** + * Creates a new instance of PostPlannedFailoverRedundancy value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public PostPlannedFailoverRedundancy() { + } + + /** + * Creates or finds a PostPlannedFailoverRedundancy from its string representation. + * + * @param name a name to look for. + * @return the corresponding PostPlannedFailoverRedundancy. + */ + public static PostPlannedFailoverRedundancy fromString(String name) { + return fromString(name, PostPlannedFailoverRedundancy.class); + } + + /** + * Gets known PostPlannedFailoverRedundancy values. + * + * @return known PostPlannedFailoverRedundancy values. + */ + public static Collection values() { + return values(PostPlannedFailoverRedundancy.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PrivateEndpoint.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PrivateEndpoint.java new file mode 100644 index 0000000000000..6c3caf41e2cd6 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PrivateEndpoint.java @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The Private Endpoint resource. + */ +@Immutable +public final class PrivateEndpoint implements JsonSerializable { + /* + * The ARM identifier for Private Endpoint + */ + private String id; + + /** + * Creates an instance of PrivateEndpoint class. + */ + private PrivateEndpoint() { + } + + /** + * Get the id property: The ARM identifier for Private Endpoint. + * + * @return the id value. + */ + public String id() { + return this.id; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PrivateEndpoint from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PrivateEndpoint if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the PrivateEndpoint. + */ + public static PrivateEndpoint fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PrivateEndpoint deserializedPrivateEndpoint = new PrivateEndpoint(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedPrivateEndpoint.id = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedPrivateEndpoint; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PrivateEndpointConnection.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PrivateEndpointConnection.java new file mode 100644 index 0000000000000..5c6459aaf0331 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PrivateEndpointConnection.java @@ -0,0 +1,184 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.storage.fluent.models.PrivateEndpointConnectionProperties; +import java.io.IOException; + +/** + * The Private Endpoint Connection resource. + */ +@Immutable +public final class PrivateEndpointConnection extends ProxyResource { + /* + * Resource properties. + */ + private PrivateEndpointConnectionProperties innerProperties; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of PrivateEndpointConnection class. + */ + private PrivateEndpointConnection() { + } + + /** + * Get the innerProperties property: Resource properties. + * + * @return the innerProperties value. + */ + private PrivateEndpointConnectionProperties innerProperties() { + return this.innerProperties; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * Get the privateEndpoint property: The resource of private end point. + * + * @return the privateEndpoint value. + */ + public PrivateEndpoint privateEndpoint() { + return this.innerProperties() == null ? null : this.innerProperties().privateEndpoint(); + } + + /** + * Get the privateLinkServiceConnectionState property: A collection of information about the state of the connection + * between service consumer and provider. + * + * @return the privateLinkServiceConnectionState value. + */ + public PrivateLinkServiceConnectionState privateLinkServiceConnectionState() { + return this.innerProperties() == null ? null : this.innerProperties().privateLinkServiceConnectionState(); + } + + /** + * Get the provisioningState property: The provisioning state of the private endpoint connection resource. + * + * @return the provisioningState value. + */ + public PrivateEndpointConnectionProvisioningState provisioningState() { + return this.innerProperties() == null ? null : this.innerProperties().provisioningState(); + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (innerProperties() != null) { + innerProperties().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("properties", this.innerProperties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PrivateEndpointConnection from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PrivateEndpointConnection if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the PrivateEndpointConnection. + */ + public static PrivateEndpointConnection fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PrivateEndpointConnection deserializedPrivateEndpointConnection = new PrivateEndpointConnection(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedPrivateEndpointConnection.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedPrivateEndpointConnection.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedPrivateEndpointConnection.type = reader.getString(); + } else if ("properties".equals(fieldName)) { + deserializedPrivateEndpointConnection.innerProperties + = PrivateEndpointConnectionProperties.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedPrivateEndpointConnection.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedPrivateEndpointConnection; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PrivateEndpointConnectionProvisioningState.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PrivateEndpointConnectionProvisioningState.java new file mode 100644 index 0000000000000..b6263d6d0108b --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PrivateEndpointConnectionProvisioningState.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The current provisioning state. + */ +public final class PrivateEndpointConnectionProvisioningState + extends ExpandableStringEnum { + /** + * Static value Succeeded for PrivateEndpointConnectionProvisioningState. + */ + public static final PrivateEndpointConnectionProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Static value Creating for PrivateEndpointConnectionProvisioningState. + */ + public static final PrivateEndpointConnectionProvisioningState CREATING = fromString("Creating"); + + /** + * Static value Deleting for PrivateEndpointConnectionProvisioningState. + */ + public static final PrivateEndpointConnectionProvisioningState DELETING = fromString("Deleting"); + + /** + * Static value Failed for PrivateEndpointConnectionProvisioningState. + */ + public static final PrivateEndpointConnectionProvisioningState FAILED = fromString("Failed"); + + /** + * Creates a new instance of PrivateEndpointConnectionProvisioningState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public PrivateEndpointConnectionProvisioningState() { + } + + /** + * Creates or finds a PrivateEndpointConnectionProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding PrivateEndpointConnectionProvisioningState. + */ + public static PrivateEndpointConnectionProvisioningState fromString(String name) { + return fromString(name, PrivateEndpointConnectionProvisioningState.class); + } + + /** + * Gets known PrivateEndpointConnectionProvisioningState values. + * + * @return known PrivateEndpointConnectionProvisioningState values. + */ + public static Collection values() { + return values(PrivateEndpointConnectionProvisioningState.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PrivateEndpointServiceConnectionStatus.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PrivateEndpointServiceConnectionStatus.java new file mode 100644 index 0000000000000..17dfd21b8c52f --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PrivateEndpointServiceConnectionStatus.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The private endpoint connection status. + */ +public final class PrivateEndpointServiceConnectionStatus + extends ExpandableStringEnum { + /** + * Static value Pending for PrivateEndpointServiceConnectionStatus. + */ + public static final PrivateEndpointServiceConnectionStatus PENDING = fromString("Pending"); + + /** + * Static value Approved for PrivateEndpointServiceConnectionStatus. + */ + public static final PrivateEndpointServiceConnectionStatus APPROVED = fromString("Approved"); + + /** + * Static value Rejected for PrivateEndpointServiceConnectionStatus. + */ + public static final PrivateEndpointServiceConnectionStatus REJECTED = fromString("Rejected"); + + /** + * Creates a new instance of PrivateEndpointServiceConnectionStatus value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public PrivateEndpointServiceConnectionStatus() { + } + + /** + * Creates or finds a PrivateEndpointServiceConnectionStatus from its string representation. + * + * @param name a name to look for. + * @return the corresponding PrivateEndpointServiceConnectionStatus. + */ + public static PrivateEndpointServiceConnectionStatus fromString(String name) { + return fromString(name, PrivateEndpointServiceConnectionStatus.class); + } + + /** + * Gets known PrivateEndpointServiceConnectionStatus values. + * + * @return known PrivateEndpointServiceConnectionStatus values. + */ + public static Collection values() { + return values(PrivateEndpointServiceConnectionStatus.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PrivateLinkServiceConnectionState.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PrivateLinkServiceConnectionState.java new file mode 100644 index 0000000000000..73cc700b2aa46 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PrivateLinkServiceConnectionState.java @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * A collection of information about the state of the connection between service consumer and provider. + */ +@Immutable +public final class PrivateLinkServiceConnectionState implements JsonSerializable { + /* + * Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. + */ + private PrivateEndpointServiceConnectionStatus status; + + /* + * The reason for approval/rejection of the connection. + */ + private String description; + + /* + * A message indicating if changes on the service provider require any updates on the consumer. + */ + private String actionRequired; + + /** + * Creates an instance of PrivateLinkServiceConnectionState class. + */ + private PrivateLinkServiceConnectionState() { + } + + /** + * Get the status property: Indicates whether the connection has been Approved/Rejected/Removed by the owner of the + * service. + * + * @return the status value. + */ + public PrivateEndpointServiceConnectionStatus status() { + return this.status; + } + + /** + * Get the description property: The reason for approval/rejection of the connection. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Get the actionRequired property: A message indicating if changes on the service provider require any updates on + * the consumer. + * + * @return the actionRequired value. + */ + public String actionRequired() { + return this.actionRequired; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("status", this.status == null ? null : this.status.toString()); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeStringField("actionRequired", this.actionRequired); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PrivateLinkServiceConnectionState from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PrivateLinkServiceConnectionState if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the PrivateLinkServiceConnectionState. + */ + public static PrivateLinkServiceConnectionState fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PrivateLinkServiceConnectionState deserializedPrivateLinkServiceConnectionState + = new PrivateLinkServiceConnectionState(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("status".equals(fieldName)) { + deserializedPrivateLinkServiceConnectionState.status + = PrivateEndpointServiceConnectionStatus.fromString(reader.getString()); + } else if ("description".equals(fieldName)) { + deserializedPrivateLinkServiceConnectionState.description = reader.getString(); + } else if ("actionRequired".equals(fieldName)) { + deserializedPrivateLinkServiceConnectionState.actionRequired = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedPrivateLinkServiceConnectionState; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ProvisioningState.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ProvisioningState.java new file mode 100644 index 0000000000000..1b916c642867f --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ProvisioningState.java @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +/** + * Defines values for ProvisioningState. + */ +public enum ProvisioningState { + /** + * Enum value Creating. + */ + CREATING("Creating"), + + /** + * Enum value ResolvingDNS. + */ + RESOLVING_DNS("ResolvingDNS"), + + /** + * Enum value Succeeded. + */ + SUCCEEDED("Succeeded"), + + /** + * Enum value ValidateSubscriptionQuotaBegin. + */ + VALIDATE_SUBSCRIPTION_QUOTA_BEGIN("ValidateSubscriptionQuotaBegin"), + + /** + * Enum value ValidateSubscriptionQuotaEnd. + */ + VALIDATE_SUBSCRIPTION_QUOTA_END("ValidateSubscriptionQuotaEnd"), + + /** + * Enum value Accepted. + */ + ACCEPTED("Accepted"), + + /** + * Enum value Deleting. + */ + DELETING("Deleting"), + + /** + * Enum value Canceled. + */ + CANCELED("Canceled"), + + /** + * Enum value Failed. + */ + FAILED("Failed"); + + /** + * The actual serialized value for a ProvisioningState instance. + */ + private final String value; + + ProvisioningState(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ProvisioningState instance. + * + * @param value the serialized value to parse. + * @return the parsed ProvisioningState object, or null if unable to parse. + */ + public static ProvisioningState fromString(String value) { + if (value == null) { + return null; + } + ProvisioningState[] items = ProvisioningState.values(); + for (ProvisioningState item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PublicNetworkAccess.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PublicNetworkAccess.java new file mode 100644 index 0000000000000..e06dbfc7d9962 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/PublicNetworkAccess.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Allow, disallow, or let Network Security Perimeter configuration to evaluate public network access to Storage + * Account. Value is optional but if passed in, must be 'Enabled', 'Disabled' or 'SecuredByPerimeter'. + */ +public final class PublicNetworkAccess extends ExpandableStringEnum { + /** + * Static value Enabled for PublicNetworkAccess. + */ + public static final PublicNetworkAccess ENABLED = fromString("Enabled"); + + /** + * Static value Disabled for PublicNetworkAccess. + */ + public static final PublicNetworkAccess DISABLED = fromString("Disabled"); + + /** + * Static value SecuredByPerimeter for PublicNetworkAccess. + */ + public static final PublicNetworkAccess SECURED_BY_PERIMETER = fromString("SecuredByPerimeter"); + + /** + * Creates a new instance of PublicNetworkAccess value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public PublicNetworkAccess() { + } + + /** + * Creates or finds a PublicNetworkAccess from its string representation. + * + * @param name a name to look for. + * @return the corresponding PublicNetworkAccess. + */ + public static PublicNetworkAccess fromString(String name) { + return fromString(name, PublicNetworkAccess.class); + } + + /** + * Gets known PublicNetworkAccess values. + * + * @return known PublicNetworkAccess values. + */ + public static Collection values() { + return values(PublicNetworkAccess.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ResourceAccessRule.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ResourceAccessRule.java new file mode 100644 index 0000000000000..dcf4ca8aa81c3 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ResourceAccessRule.java @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Resource Access Rule. + */ +@Fluent +public final class ResourceAccessRule implements JsonSerializable { + /* + * Tenant Id + */ + private String tenantId; + + /* + * Resource Id + */ + private String resourceId; + + /** + * Creates an instance of ResourceAccessRule class. + */ + public ResourceAccessRule() { + } + + /** + * Get the tenantId property: Tenant Id. + * + * @return the tenantId value. + */ + public String tenantId() { + return this.tenantId; + } + + /** + * Set the tenantId property: Tenant Id. + * + * @param tenantId the tenantId value to set. + * @return the ResourceAccessRule object itself. + */ + public ResourceAccessRule withTenantId(String tenantId) { + this.tenantId = tenantId; + return this; + } + + /** + * Get the resourceId property: Resource Id. + * + * @return the resourceId value. + */ + public String resourceId() { + return this.resourceId; + } + + /** + * Set the resourceId property: Resource Id. + * + * @param resourceId the resourceId value to set. + * @return the ResourceAccessRule object itself. + */ + public ResourceAccessRule withResourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("tenantId", this.tenantId); + jsonWriter.writeStringField("resourceId", this.resourceId); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourceAccessRule from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourceAccessRule if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the ResourceAccessRule. + */ + public static ResourceAccessRule fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ResourceAccessRule deserializedResourceAccessRule = new ResourceAccessRule(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("tenantId".equals(fieldName)) { + deserializedResourceAccessRule.tenantId = reader.getString(); + } else if ("resourceId".equals(fieldName)) { + deserializedResourceAccessRule.resourceId = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedResourceAccessRule; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ResourceProviders.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ResourceProviders.java new file mode 100644 index 0000000000000..34369bbe6aac4 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ResourceProviders.java @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +/** + * Resource collection API of ResourceProviders. + */ +public interface ResourceProviders { + /** + * Begins definition for a new StorageAccount resource. + * + * @param name resource name. + * @return the first stage of the new StorageAccount definition. + */ + StorageAccount.DefinitionStages.Blank define(String name); +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/RoutingChoice.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/RoutingChoice.java new file mode 100644 index 0000000000000..8668f2b58d595 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/RoutingChoice.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Routing Choice defines the kind of network routing opted by the user. + */ +public final class RoutingChoice extends ExpandableStringEnum { + /** + * Static value MicrosoftRouting for RoutingChoice. + */ + public static final RoutingChoice MICROSOFT_ROUTING = fromString("MicrosoftRouting"); + + /** + * Static value InternetRouting for RoutingChoice. + */ + public static final RoutingChoice INTERNET_ROUTING = fromString("InternetRouting"); + + /** + * Creates a new instance of RoutingChoice value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public RoutingChoice() { + } + + /** + * Creates or finds a RoutingChoice from its string representation. + * + * @param name a name to look for. + * @return the corresponding RoutingChoice. + */ + public static RoutingChoice fromString(String name) { + return fromString(name, RoutingChoice.class); + } + + /** + * Gets known RoutingChoice values. + * + * @return known RoutingChoice values. + */ + public static Collection values() { + return values(RoutingChoice.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/RoutingPreference.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/RoutingPreference.java new file mode 100644 index 0000000000000..416863e15d88c --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/RoutingPreference.java @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user + * data, the default option is microsoft routing. + */ +@Fluent +public final class RoutingPreference implements JsonSerializable { + /* + * Routing Choice defines the kind of network routing opted by the user. + */ + private RoutingChoice routingChoice; + + /* + * A boolean flag which indicates whether microsoft routing storage endpoints are to be published + */ + private Boolean publishMicrosoftEndpoints; + + /* + * A boolean flag which indicates whether internet routing storage endpoints are to be published + */ + private Boolean publishInternetEndpoints; + + /** + * Creates an instance of RoutingPreference class. + */ + public RoutingPreference() { + } + + /** + * Get the routingChoice property: Routing Choice defines the kind of network routing opted by the user. + * + * @return the routingChoice value. + */ + public RoutingChoice routingChoice() { + return this.routingChoice; + } + + /** + * Set the routingChoice property: Routing Choice defines the kind of network routing opted by the user. + * + * @param routingChoice the routingChoice value to set. + * @return the RoutingPreference object itself. + */ + public RoutingPreference withRoutingChoice(RoutingChoice routingChoice) { + this.routingChoice = routingChoice; + return this; + } + + /** + * Get the publishMicrosoftEndpoints property: A boolean flag which indicates whether microsoft routing storage + * endpoints are to be published. + * + * @return the publishMicrosoftEndpoints value. + */ + public Boolean publishMicrosoftEndpoints() { + return this.publishMicrosoftEndpoints; + } + + /** + * Set the publishMicrosoftEndpoints property: A boolean flag which indicates whether microsoft routing storage + * endpoints are to be published. + * + * @param publishMicrosoftEndpoints the publishMicrosoftEndpoints value to set. + * @return the RoutingPreference object itself. + */ + public RoutingPreference withPublishMicrosoftEndpoints(Boolean publishMicrosoftEndpoints) { + this.publishMicrosoftEndpoints = publishMicrosoftEndpoints; + return this; + } + + /** + * Get the publishInternetEndpoints property: A boolean flag which indicates whether internet routing storage + * endpoints are to be published. + * + * @return the publishInternetEndpoints value. + */ + public Boolean publishInternetEndpoints() { + return this.publishInternetEndpoints; + } + + /** + * Set the publishInternetEndpoints property: A boolean flag which indicates whether internet routing storage + * endpoints are to be published. + * + * @param publishInternetEndpoints the publishInternetEndpoints value to set. + * @return the RoutingPreference object itself. + */ + public RoutingPreference withPublishInternetEndpoints(Boolean publishInternetEndpoints) { + this.publishInternetEndpoints = publishInternetEndpoints; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("routingChoice", this.routingChoice == null ? null : this.routingChoice.toString()); + jsonWriter.writeBooleanField("publishMicrosoftEndpoints", this.publishMicrosoftEndpoints); + jsonWriter.writeBooleanField("publishInternetEndpoints", this.publishInternetEndpoints); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RoutingPreference from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RoutingPreference if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the RoutingPreference. + */ + public static RoutingPreference fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + RoutingPreference deserializedRoutingPreference = new RoutingPreference(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("routingChoice".equals(fieldName)) { + deserializedRoutingPreference.routingChoice = RoutingChoice.fromString(reader.getString()); + } else if ("publishMicrosoftEndpoints".equals(fieldName)) { + deserializedRoutingPreference.publishMicrosoftEndpoints + = reader.getNullable(JsonReader::getBoolean); + } else if ("publishInternetEndpoints".equals(fieldName)) { + deserializedRoutingPreference.publishInternetEndpoints = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + + return deserializedRoutingPreference; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/SasPolicy.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/SasPolicy.java new file mode 100644 index 0000000000000..81cfe53a9e76a --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/SasPolicy.java @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * SasPolicy assigned to the storage account. + */ +@Fluent +public final class SasPolicy implements JsonSerializable { + /* + * The SAS expiration period, DD.HH:MM:SS. + */ + private String sasExpirationPeriod; + + /* + * The SAS Expiration Action defines the action to be performed when sasPolicy.sasExpirationPeriod is violated. The + * 'Log' action can be used for audit purposes and the 'Block' action can be used to block and deny the usage of SAS + * tokens that do not adhere to the sas policy expiration period. + */ + private ExpirationAction expirationAction; + + /** + * Creates an instance of SasPolicy class. + */ + public SasPolicy() { + } + + /** + * Get the sasExpirationPeriod property: The SAS expiration period, DD.HH:MM:SS. + * + * @return the sasExpirationPeriod value. + */ + public String sasExpirationPeriod() { + return this.sasExpirationPeriod; + } + + /** + * Set the sasExpirationPeriod property: The SAS expiration period, DD.HH:MM:SS. + * + * @param sasExpirationPeriod the sasExpirationPeriod value to set. + * @return the SasPolicy object itself. + */ + public SasPolicy withSasExpirationPeriod(String sasExpirationPeriod) { + this.sasExpirationPeriod = sasExpirationPeriod; + return this; + } + + /** + * Get the expirationAction property: The SAS Expiration Action defines the action to be performed when + * sasPolicy.sasExpirationPeriod is violated. The 'Log' action can be used for audit purposes and the 'Block' action + * can be used to block and deny the usage of SAS tokens that do not adhere to the sas policy expiration period. + * + * @return the expirationAction value. + */ + public ExpirationAction expirationAction() { + return this.expirationAction; + } + + /** + * Set the expirationAction property: The SAS Expiration Action defines the action to be performed when + * sasPolicy.sasExpirationPeriod is violated. The 'Log' action can be used for audit purposes and the 'Block' action + * can be used to block and deny the usage of SAS tokens that do not adhere to the sas policy expiration period. + * + * @param expirationAction the expirationAction value to set. + * @return the SasPolicy object itself. + */ + public SasPolicy withExpirationAction(ExpirationAction expirationAction) { + this.expirationAction = expirationAction; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (sasExpirationPeriod() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property sasExpirationPeriod in model SasPolicy")); + } + if (expirationAction() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException("Missing required property expirationAction in model SasPolicy")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(SasPolicy.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("sasExpirationPeriod", this.sasExpirationPeriod); + jsonWriter.writeStringField("expirationAction", + this.expirationAction == null ? null : this.expirationAction.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SasPolicy from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SasPolicy if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the SasPolicy. + */ + public static SasPolicy fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SasPolicy deserializedSasPolicy = new SasPolicy(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("sasExpirationPeriod".equals(fieldName)) { + deserializedSasPolicy.sasExpirationPeriod = reader.getString(); + } else if ("expirationAction".equals(fieldName)) { + deserializedSasPolicy.expirationAction = ExpirationAction.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedSasPolicy; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ServiceSharedKeyAccessProperties.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ServiceSharedKeyAccessProperties.java new file mode 100644 index 0000000000000..a90a1d679a3b2 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ServiceSharedKeyAccessProperties.java @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Defines shared key access settings for an individual storage service. + */ +@Fluent +public final class ServiceSharedKeyAccessProperties implements JsonSerializable { + /* + * Indicates whether shared key access is enabled for the service. + */ + private Boolean enabled; + + /** + * Creates an instance of ServiceSharedKeyAccessProperties class. + */ + public ServiceSharedKeyAccessProperties() { + } + + /** + * Get the enabled property: Indicates whether shared key access is enabled for the service. + * + * @return the enabled value. + */ + public Boolean enabled() { + return this.enabled; + } + + /** + * Set the enabled property: Indicates whether shared key access is enabled for the service. + * + * @param enabled the enabled value to set. + * @return the ServiceSharedKeyAccessProperties object itself. + */ + public ServiceSharedKeyAccessProperties withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("enabled", this.enabled); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ServiceSharedKeyAccessProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ServiceSharedKeyAccessProperties if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the ServiceSharedKeyAccessProperties. + */ + public static ServiceSharedKeyAccessProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ServiceSharedKeyAccessProperties deserializedServiceSharedKeyAccessProperties + = new ServiceSharedKeyAccessProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("enabled".equals(fieldName)) { + deserializedServiceSharedKeyAccessProperties.enabled = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + + return deserializedServiceSharedKeyAccessProperties; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Sku.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Sku.java new file mode 100644 index 0000000000000..906af5fa7a61e --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/Sku.java @@ -0,0 +1,119 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The SKU of the storage account. + */ +@Fluent +public final class Sku implements JsonSerializable { + /* + * The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was + * called accountType. + */ + private SkuName name; + + /* + * The SKU tier. This is based on the SKU name. + */ + private SkuTier tier; + + /** + * Creates an instance of Sku class. + */ + public Sku() { + } + + /** + * Get the name property: The SKU name. Required for account creation; optional for update. Note that in older + * versions, SKU name was called accountType. + * + * @return the name value. + */ + public SkuName name() { + return this.name; + } + + /** + * Set the name property: The SKU name. Required for account creation; optional for update. Note that in older + * versions, SKU name was called accountType. + * + * @param name the name value to set. + * @return the Sku object itself. + */ + public Sku withName(SkuName name) { + this.name = name; + return this; + } + + /** + * Get the tier property: The SKU tier. This is based on the SKU name. + * + * @return the tier value. + */ + public SkuTier tier() { + return this.tier; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER.atError().log(new IllegalArgumentException("Missing required property name in model Sku")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(Sku.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name == null ? null : this.name.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Sku from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Sku if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the Sku. + */ + public static Sku fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Sku deserializedSku = new Sku(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedSku.name = SkuName.fromString(reader.getString()); + } else if ("tier".equals(fieldName)) { + deserializedSku.tier = SkuTier.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedSku; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/SkuConversionStatus.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/SkuConversionStatus.java new file mode 100644 index 0000000000000..3db95d29dce9b --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/SkuConversionStatus.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * This property indicates the current sku conversion status. + */ +public final class SkuConversionStatus extends ExpandableStringEnum { + /** + * Static value InProgress for SkuConversionStatus. + */ + public static final SkuConversionStatus IN_PROGRESS = fromString("InProgress"); + + /** + * Static value Succeeded for SkuConversionStatus. + */ + public static final SkuConversionStatus SUCCEEDED = fromString("Succeeded"); + + /** + * Static value Failed for SkuConversionStatus. + */ + public static final SkuConversionStatus FAILED = fromString("Failed"); + + /** + * Creates a new instance of SkuConversionStatus value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public SkuConversionStatus() { + } + + /** + * Creates or finds a SkuConversionStatus from its string representation. + * + * @param name a name to look for. + * @return the corresponding SkuConversionStatus. + */ + public static SkuConversionStatus fromString(String name) { + return fromString(name, SkuConversionStatus.class); + } + + /** + * Gets known SkuConversionStatus values. + * + * @return known SkuConversionStatus values. + */ + public static Collection values() { + return values(SkuConversionStatus.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/SkuName.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/SkuName.java new file mode 100644 index 0000000000000..ca45cd478d7c5 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/SkuName.java @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called + * accountType. + */ +public final class SkuName extends ExpandableStringEnum { + /** + * Static value Standard_LRS for SkuName. + */ + public static final SkuName STANDARD_LRS = fromString("Standard_LRS"); + + /** + * Static value Standard_GRS for SkuName. + */ + public static final SkuName STANDARD_GRS = fromString("Standard_GRS"); + + /** + * Static value Standard_RAGRS for SkuName. + */ + public static final SkuName STANDARD_RAGRS = fromString("Standard_RAGRS"); + + /** + * Static value Standard_ZRS for SkuName. + */ + public static final SkuName STANDARD_ZRS = fromString("Standard_ZRS"); + + /** + * Static value Premium_LRS for SkuName. + */ + public static final SkuName PREMIUM_LRS = fromString("Premium_LRS"); + + /** + * Static value Premium_ZRS for SkuName. + */ + public static final SkuName PREMIUM_ZRS = fromString("Premium_ZRS"); + + /** + * Static value Standard_GZRS for SkuName. + */ + public static final SkuName STANDARD_GZRS = fromString("Standard_GZRS"); + + /** + * Static value Standard_RAGZRS for SkuName. + */ + public static final SkuName STANDARD_RAGZRS = fromString("Standard_RAGZRS"); + + /** + * Static value StandardV2_LRS for SkuName. + */ + public static final SkuName STANDARD_V2_LRS = fromString("StandardV2_LRS"); + + /** + * Static value StandardV2_GRS for SkuName. + */ + public static final SkuName STANDARD_V2_GRS = fromString("StandardV2_GRS"); + + /** + * Static value StandardV2_ZRS for SkuName. + */ + public static final SkuName STANDARD_V2_ZRS = fromString("StandardV2_ZRS"); + + /** + * Static value StandardV2_GZRS for SkuName. + */ + public static final SkuName STANDARD_V2_GZRS = fromString("StandardV2_GZRS"); + + /** + * Static value PremiumV2_LRS for SkuName. + */ + public static final SkuName PREMIUM_V2_LRS = fromString("PremiumV2_LRS"); + + /** + * Static value PremiumV2_ZRS for SkuName. + */ + public static final SkuName PREMIUM_V2_ZRS = fromString("PremiumV2_ZRS"); + + /** + * Creates a new instance of SkuName value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public SkuName() { + } + + /** + * Creates or finds a SkuName from its string representation. + * + * @param name a name to look for. + * @return the corresponding SkuName. + */ + public static SkuName fromString(String name) { + return fromString(name, SkuName.class); + } + + /** + * Gets known SkuName values. + * + * @return known SkuName values. + */ + public static Collection values() { + return values(SkuName.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/SkuTier.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/SkuTier.java new file mode 100644 index 0000000000000..1dfe62841884f --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/SkuTier.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +/** + * The SKU tier. This is based on the SKU name. + */ +public enum SkuTier { + /** + * Enum value Standard. + */ + STANDARD("Standard"), + + /** + * Enum value Premium. + */ + PREMIUM("Premium"); + + /** + * The actual serialized value for a SkuTier instance. + */ + private final String value; + + SkuTier(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a SkuTier instance. + * + * @param value the serialized value to parse. + * @return the parsed SkuTier object, or null if unable to parse. + */ + public static SkuTier fromString(String value) { + if (value == null) { + return null; + } + SkuTier[] items = SkuTier.values(); + for (SkuTier item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/SmbOAuthSettings.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/SmbOAuthSettings.java new file mode 100644 index 0000000000000..a5c06db1d45c9 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/SmbOAuthSettings.java @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Setting property for Managed Identity access over SMB using OAuth. + */ +@Fluent +public final class SmbOAuthSettings implements JsonSerializable { + /* + * Specifies if managed identities can access SMB shares using OAuth. The default interpretation is false for this + * property. + */ + private Boolean isSmbOAuthEnabled; + + /** + * Creates an instance of SmbOAuthSettings class. + */ + public SmbOAuthSettings() { + } + + /** + * Get the isSmbOAuthEnabled property: Specifies if managed identities can access SMB shares using OAuth. The + * default interpretation is false for this property. + * + * @return the isSmbOAuthEnabled value. + */ + public Boolean isSmbOAuthEnabled() { + return this.isSmbOAuthEnabled; + } + + /** + * Set the isSmbOAuthEnabled property: Specifies if managed identities can access SMB shares using OAuth. The + * default interpretation is false for this property. + * + * @param isSmbOAuthEnabled the isSmbOAuthEnabled value to set. + * @return the SmbOAuthSettings object itself. + */ + public SmbOAuthSettings withIsSmbOAuthEnabled(Boolean isSmbOAuthEnabled) { + this.isSmbOAuthEnabled = isSmbOAuthEnabled; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("isSmbOAuthEnabled", this.isSmbOAuthEnabled); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SmbOAuthSettings from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SmbOAuthSettings if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the SmbOAuthSettings. + */ + public static SmbOAuthSettings fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + SmbOAuthSettings deserializedSmbOAuthSettings = new SmbOAuthSettings(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("isSmbOAuthEnabled".equals(fieldName)) { + deserializedSmbOAuthSettings.isSmbOAuthEnabled = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + + return deserializedSmbOAuthSettings; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/State.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/State.java new file mode 100644 index 0000000000000..9912d0622555e --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/State.java @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Gets the state of virtual network rule. + */ +public final class State extends ExpandableStringEnum { + /** + * Static value Provisioning for State. + */ + public static final State PROVISIONING = fromString("Provisioning"); + + /** + * Static value Deprovisioning for State. + */ + public static final State DEPROVISIONING = fromString("Deprovisioning"); + + /** + * Static value Succeeded for State. + */ + public static final State SUCCEEDED = fromString("Succeeded"); + + /** + * Static value Failed for State. + */ + public static final State FAILED = fromString("Failed"); + + /** + * Static value NetworkSourceDeleted for State. + */ + public static final State NETWORK_SOURCE_DELETED = fromString("NetworkSourceDeleted"); + + /** + * Creates a new instance of State value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public State() { + } + + /** + * Creates or finds a State from its string representation. + * + * @param name a name to look for. + * @return the corresponding State. + */ + public static State fromString(String name) { + return fromString(name, State.class); + } + + /** + * Gets known State values. + * + * @return known State values. + */ + public static Collection values() { + return values(State.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccount.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccount.java new file mode 100644 index 0000000000000..eeeb73a700089 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccount.java @@ -0,0 +1,1093 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.storage.fluent.models.StorageAccountInner; +import java.time.OffsetDateTime; +import java.util.List; +import java.util.Map; + +/** + * An immutable client-side representation of StorageAccount. + */ +public interface StorageAccount { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the location property: The geo-location where the resource lives. + * + * @return the location value. + */ + String location(); + + /** + * Gets the tags property: Resource tags. + * + * @return the tags value. + */ + Map tags(); + + /** + * Gets the sku property: Gets the SKU. + * + * @return the sku value. + */ + Sku sku(); + + /** + * Gets the kind property: Gets the Kind. + * + * @return the kind value. + */ + Kind kind(); + + /** + * Gets the identity property: The identity of the resource. + * + * @return the identity value. + */ + Identity identity(); + + /** + * Gets the extendedLocation property: The extendedLocation of the resource. + * + * @return the extendedLocation value. + */ + ExtendedLocation extendedLocation(); + + /** + * Gets the zones property: The availability zones. + * + * @return the zones value. + */ + List zones(); + + /** + * Gets the placement property: Optional. Gets or sets the zonal placement details for the storage account. + * + * @return the placement value. + */ + Placement placement(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the provisioningState property: Gets the status of the storage account at the time the operation was called. + * + * @return the provisioningState value. + */ + ProvisioningState provisioningState(); + + /** + * Gets the primaryEndpoints property: Gets the URLs that are used to perform a retrieval of a public blob, queue, + * or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob endpoint. + * + * @return the primaryEndpoints value. + */ + Endpoints primaryEndpoints(); + + /** + * Gets the primaryLocation property: Gets the location of the primary data center for the storage account. + * + * @return the primaryLocation value. + */ + String primaryLocation(); + + /** + * Gets the statusOfPrimary property: Gets the status indicating whether the primary location of the storage account + * is available or unavailable. + * + * @return the statusOfPrimary value. + */ + AccountStatus statusOfPrimary(); + + /** + * Gets the lastGeoFailoverTime property: Gets the timestamp of the most recent instance of a failover to the + * secondary location. Only the most recent timestamp is retained. This element is not returned if there has never + * been a failover instance. Only available if the accountType is Standard_GRS or Standard_RAGRS. + * + * @return the lastGeoFailoverTime value. + */ + OffsetDateTime lastGeoFailoverTime(); + + /** + * Gets the secondaryLocation property: Gets the location of the geo-replicated secondary for the storage account. + * Only available if the accountType is Standard_GRS or Standard_RAGRS. + * + * @return the secondaryLocation value. + */ + String secondaryLocation(); + + /** + * Gets the statusOfSecondary property: Gets the status indicating whether the secondary location of the storage + * account is available or unavailable. Only available if the SKU name is Standard_GRS or Standard_RAGRS. + * + * @return the statusOfSecondary value. + */ + AccountStatus statusOfSecondary(); + + /** + * Gets the creationTime property: Gets the creation date and time of the storage account in UTC. + * + * @return the creationTime value. + */ + OffsetDateTime creationTime(); + + /** + * Gets the customDomain property: Gets the custom domain the user assigned to this storage account. + * + * @return the customDomain value. + */ + CustomDomain customDomain(); + + /** + * Gets the sasPolicy property: SasPolicy assigned to the storage account. + * + * @return the sasPolicy value. + */ + SasPolicy sasPolicy(); + + /** + * Gets the keyPolicy property: KeyPolicy assigned to the storage account. + * + * @return the keyPolicy value. + */ + KeyPolicy keyPolicy(); + + /** + * Gets the keyCreationTime property: Storage account keys creation time. + * + * @return the keyCreationTime value. + */ + KeyCreationTime keyCreationTime(); + + /** + * Gets the secondaryEndpoints property: Gets the URLs that are used to perform a retrieval of a public blob, queue, + * or table object from the secondary location of the storage account. Only available if the SKU name is + * Standard_RAGRS. + * + * @return the secondaryEndpoints value. + */ + Endpoints secondaryEndpoints(); + + /** + * Gets the encryption property: Encryption settings to be used for server-side encryption for the storage account. + * + * @return the encryption value. + */ + Encryption encryption(); + + /** + * Gets the accessTier property: Required for storage accounts where kind = BlobStorage. The access tier is used for + * billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it + * cannot be changed for the premium block blobs storage account type. + * + * @return the accessTier value. + */ + AccessTier accessTier(); + + /** + * Gets the azureFilesIdentityBasedAuthentication property: Provides the identity based authentication settings for + * Azure Files. + * + * @return the azureFilesIdentityBasedAuthentication value. + */ + AzureFilesIdentityBasedAuthentication azureFilesIdentityBasedAuthentication(); + + /** + * Gets the enableHttpsTrafficOnly property: Allows https traffic only to storage service if sets to true. + * + * @return the enableHttpsTrafficOnly value. + */ + Boolean enableHttpsTrafficOnly(); + + /** + * Gets the networkRuleSet property: Network rule set. + * + * @return the networkRuleSet value. + */ + NetworkRuleSet networkRuleSet(); + + /** + * Gets the isSftpEnabled property: Enables Secure File Transfer Protocol, if set to true. + * + * @return the isSftpEnabled value. + */ + Boolean isSftpEnabled(); + + /** + * Gets the isLocalUserEnabled property: Enables local users feature, if set to true. + * + * @return the isLocalUserEnabled value. + */ + Boolean isLocalUserEnabled(); + + /** + * Gets the enableExtendedGroups property: Enables extended group support with local users feature, if set to true. + * + * @return the enableExtendedGroups value. + */ + Boolean enableExtendedGroups(); + + /** + * Gets the isHnsEnabled property: Account HierarchicalNamespace enabled if sets to true. + * + * @return the isHnsEnabled value. + */ + Boolean isHnsEnabled(); + + /** + * Gets the geoReplicationStats property: Geo Replication Stats. + * + * @return the geoReplicationStats value. + */ + GeoReplicationStats geoReplicationStats(); + + /** + * Gets the failoverInProgress property: If the failover is in progress, the value will be true, otherwise, it will + * be null. + * + * @return the failoverInProgress value. + */ + Boolean failoverInProgress(); + + /** + * Gets the largeFileSharesState property: Allow large file shares if sets to Enabled. It cannot be disabled once it + * is enabled. + * + * @return the largeFileSharesState value. + */ + LargeFileSharesState largeFileSharesState(); + + /** + * Gets the privateEndpointConnections property: List of private endpoint connection associated with the specified + * storage account. + * + * @return the privateEndpointConnections value. + */ + List privateEndpointConnections(); + + /** + * Gets the routingPreference property: Maintains information about the network routing choice opted by the user for + * data transfer. + * + * @return the routingPreference value. + */ + RoutingPreference routingPreference(); + + /** + * Gets the dualStackEndpointPreference property: Maintains information about the Internet protocol opted by the + * user. + * + * @return the dualStackEndpointPreference value. + */ + DualStackEndpointPreference dualStackEndpointPreference(); + + /** + * Gets the blobRestoreStatus property: Blob restore status. + * + * @return the blobRestoreStatus value. + */ + BlobRestoreStatus blobRestoreStatus(); + + /** + * Gets the allowBlobPublicAccess property: Allow or disallow public access to all blobs or containers in the + * storage account. The default interpretation is false for this property. + * + * @return the allowBlobPublicAccess value. + */ + Boolean allowBlobPublicAccess(); + + /** + * Gets the minimumTlsVersion property: Set the minimum TLS version to be permitted on requests to storage. The + * default interpretation is TLS 1.0 for this property. Minimum TLS version 1.3 version is not supported. + * + * @return the minimumTlsVersion value. + */ + MinimumTlsVersion minimumTlsVersion(); + + /** + * Gets the allowSharedKeyAccess property: Indicates whether the storage account permits requests to be authorized + * with the account access key via Shared Key. If false, then all requests, including shared access signatures, must + * be authorized with Azure Active Directory (Azure AD). The default value is null, which is equivalent to true. + * + * @return the allowSharedKeyAccess value. + */ + Boolean allowSharedKeyAccess(); + + /** + * Gets the enableNfsV3 property: NFS 3.0 protocol support enabled if set to true. + * + * @return the enableNfsV3 value. + */ + Boolean enableNfsV3(); + + /** + * Gets the allowCrossTenantReplication property: Allow or disallow cross AAD tenant object replication. Set this + * property to true for new or existing accounts only if object replication policies will involve storage accounts + * in different AAD tenants. The default interpretation is false for new accounts to follow best security practices + * by default. + * + * @return the allowCrossTenantReplication value. + */ + Boolean allowCrossTenantReplication(); + + /** + * Gets the defaultToOAuthAuthentication property: A boolean flag which indicates whether the default authentication + * is OAuth or not. The default interpretation is false for this property. + * + * @return the defaultToOAuthAuthentication value. + */ + Boolean defaultToOAuthAuthentication(); + + /** + * Gets the publicNetworkAccess property: Allow, disallow, or let Network Security Perimeter configuration to + * evaluate public network access to Storage Account. + * + * @return the publicNetworkAccess value. + */ + PublicNetworkAccess publicNetworkAccess(); + + /** + * Gets the immutableStorageWithVersioning property: The property is immutable and can only be set to true at the + * account creation time. When set to true, it enables object level immutability for all the containers in the + * account by default. + * + * @return the immutableStorageWithVersioning value. + */ + ImmutableStorageAccount immutableStorageWithVersioning(); + + /** + * Gets the allowedCopyScope property: Restrict copy to and from Storage Accounts within an AAD tenant or with + * Private Links to the same VNet. + * + * @return the allowedCopyScope value. + */ + AllowedCopyScope allowedCopyScope(); + + /** + * Gets the storageAccountSkuConversionStatus property: This property is readOnly and is set by server during + * asynchronous storage account sku conversion operations. + * + * @return the storageAccountSkuConversionStatus value. + */ + StorageAccountSkuConversionStatus storageAccountSkuConversionStatus(); + + /** + * Gets the dnsEndpointType property: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create + * a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint + * URL will have an alphanumeric DNS Zone identifier. + * + * @return the dnsEndpointType value. + */ + DnsEndpointType dnsEndpointType(); + + /** + * Gets the isSkuConversionBlocked property: This property will be set to true or false on an event of ongoing + * migration. Default value is null. + * + * @return the isSkuConversionBlocked value. + */ + Boolean isSkuConversionBlocked(); + + /** + * Gets the accountMigrationInProgress property: If customer initiated account migration is in progress, the value + * will be true else it will be null. + * + * @return the accountMigrationInProgress value. + */ + Boolean accountMigrationInProgress(); + + /** + * Gets the geoPriorityReplicationStatus property: Status indicating whether Geo Priority Replication is enabled for + * the account. + * + * @return the geoPriorityReplicationStatus value. + */ + GeoPriorityReplicationStatus geoPriorityReplicationStatus(); + + /** + * Gets the allowSharedKeyAccessForServices property: Indicate shared key access properties at service level. + * + * @return the allowSharedKeyAccessForServices value. + */ + StorageAccountSharedKeyAccessProperties allowSharedKeyAccessForServices(); + + /** + * Gets the dataCollaborationPolicyProperties property: Data Collaboration policy for the storage account. + * + * @return the dataCollaborationPolicyProperties value. + */ + StorageDataCollaborationPolicyProperties dataCollaborationPolicyProperties(); + + /** + * Gets the region of the resource. + * + * @return the region of the resource. + */ + Region region(); + + /** + * Gets the name of the resource region. + * + * @return the name of the resource region. + */ + String regionName(); + + /** + * Gets the inner com.azure.resourcemanager.storage.fluent.models.StorageAccountInner object. + * + * @return the inner object. + */ + StorageAccountInner innerModel(); + + /** + * The entirety of the StorageAccount definition. + */ + interface Definition + extends DefinitionStages.Blank, DefinitionStages.WithLocation, DefinitionStages.WithResourceGroup, + DefinitionStages.WithSku, DefinitionStages.WithKind, DefinitionStages.WithCreate { + } + + /** + * The StorageAccount definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the StorageAccount definition. + */ + interface Blank extends WithLocation { + } + + /** + * The stage of the StorageAccount definition allowing to specify location. + */ + interface WithLocation { + /** + * Specifies the region for the resource. + * + * @param location Required. Gets or sets the location of the resource. This will be one of the supported + * and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region of a + * resource cannot be changed once it is created, but if an identical geo region is specified on update, the + * request will succeed. + * @return the next definition stage. + */ + WithResourceGroup withRegion(Region location); + + /** + * Specifies the region for the resource. + * + * @param location Required. Gets or sets the location of the resource. This will be one of the supported + * and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region of a + * resource cannot be changed once it is created, but if an identical geo region is specified on update, the + * request will succeed. + * @return the next definition stage. + */ + WithResourceGroup withRegion(String location); + } + + /** + * The stage of the StorageAccount definition allowing to specify parent resource. + */ + interface WithResourceGroup { + /** + * Specifies resourceGroupName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @return the next definition stage. + */ + WithSku withExistingResourceGroup(String resourceGroupName); + } + + /** + * The stage of the StorageAccount definition allowing to specify sku. + */ + interface WithSku { + /** + * Specifies the sku property: Required. Gets or sets the SKU name.. + * + * @param sku Required. Gets or sets the SKU name. + * @return the next definition stage. + */ + WithKind withSku(Sku sku); + } + + /** + * The stage of the StorageAccount definition allowing to specify kind. + */ + interface WithKind { + /** + * Specifies the kind property: Required. Indicates the type of storage account.. + * + * @param kind Required. Indicates the type of storage account. + * @return the next definition stage. + */ + WithCreate withKind(Kind kind); + } + + /** + * The stage of the StorageAccount definition which contains all the minimum required properties for the + * resource to be created, but also allows for any other optional properties to be specified. + */ + interface WithCreate + extends DefinitionStages.WithTags, DefinitionStages.WithExtendedLocation, DefinitionStages.WithZones, + DefinitionStages.WithPlacement, DefinitionStages.WithIdentity, DefinitionStages.WithAllowedCopyScope, + DefinitionStages.WithPublicNetworkAccess, DefinitionStages.WithSasPolicy, DefinitionStages.WithKeyPolicy, + DefinitionStages.WithCustomDomain, DefinitionStages.WithEncryption, DefinitionStages.WithNetworkRuleSet, + DefinitionStages.WithAccessTier, DefinitionStages.WithAzureFilesIdentityBasedAuthentication, + DefinitionStages.WithEnableHttpsTrafficOnly, DefinitionStages.WithIsSftpEnabled, + DefinitionStages.WithIsLocalUserEnabled, DefinitionStages.WithEnableExtendedGroups, + DefinitionStages.WithIsHnsEnabled, DefinitionStages.WithLargeFileSharesState, + DefinitionStages.WithRoutingPreference, DefinitionStages.WithDualStackEndpointPreference, + DefinitionStages.WithAllowBlobPublicAccess, DefinitionStages.WithMinimumTlsVersion, + DefinitionStages.WithAllowSharedKeyAccess, DefinitionStages.WithEnableNfsV3, + DefinitionStages.WithAllowCrossTenantReplication, DefinitionStages.WithDefaultToOAuthAuthentication, + DefinitionStages.WithImmutableStorageWithVersioning, DefinitionStages.WithDnsEndpointType, + DefinitionStages.WithGeoPriorityReplicationStatus, DefinitionStages.WithAllowSharedKeyAccessForServices, + DefinitionStages.WithDataCollaborationPolicyProperties { + /** + * Executes the create request. + * + * @return the created resource. + */ + StorageAccount create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + StorageAccount create(Context context); + } + + /** + * The stage of the StorageAccount definition allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Gets or sets a list of key value pairs that describe the resource. These + * tags can be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + * can be provided for a resource. Each tag must have a key with a length no greater than 128 characters and + * a value with a length no greater than 256 characters.. + * + * @param tags Gets or sets a list of key value pairs that describe the resource. These tags can be used for + * viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a + * resource. Each tag must have a key with a length no greater than 128 characters and a value with a length + * no greater than 256 characters. + * @return the next definition stage. + */ + WithCreate withTags(Map tags); + } + + /** + * The stage of the StorageAccount definition allowing to specify extendedLocation. + */ + interface WithExtendedLocation { + /** + * Specifies the extendedLocation property: Optional. Set the extended location of the resource. If not set, + * the storage account will be created in Azure main region. Otherwise it will be created in the specified + * extended location. + * + * @param extendedLocation Optional. Set the extended location of the resource. If not set, the storage + * account will be created in Azure main region. Otherwise it will be created in the specified extended + * location. + * @return the next definition stage. + */ + WithCreate withExtendedLocation(ExtendedLocation extendedLocation); + } + + /** + * The stage of the StorageAccount definition allowing to specify zones. + */ + interface WithZones { + /** + * Specifies the zones property: Optional. Gets or sets the pinned logical availability zone for the storage + * account.. + * + * @param zones Optional. Gets or sets the pinned logical availability zone for the storage account. + * @return the next definition stage. + */ + WithCreate withZones(List zones); + } + + /** + * The stage of the StorageAccount definition allowing to specify placement. + */ + interface WithPlacement { + /** + * Specifies the placement property: Optional. Gets or sets the zonal placement details for the storage + * account.. + * + * @param placement Optional. Gets or sets the zonal placement details for the storage account. + * @return the next definition stage. + */ + WithCreate withPlacement(Placement placement); + } + + /** + * The stage of the StorageAccount definition allowing to specify identity. + */ + interface WithIdentity { + /** + * Specifies the identity property: The identity of the resource.. + * + * @param identity The identity of the resource. + * @return the next definition stage. + */ + WithCreate withIdentity(Identity identity); + } + + /** + * The stage of the StorageAccount definition allowing to specify allowedCopyScope. + */ + interface WithAllowedCopyScope { + /** + * Specifies the allowedCopyScope property: Restrict copy to and from Storage Accounts within an AAD tenant + * or with Private Links to the same VNet.. + * + * @param allowedCopyScope Restrict copy to and from Storage Accounts within an AAD tenant or with Private + * Links to the same VNet. + * @return the next definition stage. + */ + WithCreate withAllowedCopyScope(AllowedCopyScope allowedCopyScope); + } + + /** + * The stage of the StorageAccount definition allowing to specify publicNetworkAccess. + */ + interface WithPublicNetworkAccess { + /** + * Specifies the publicNetworkAccess property: Allow, disallow, or let Network Security Perimeter + * configuration to evaluate public network access to Storage Account. Value is optional but if passed in, + * must be 'Enabled', 'Disabled' or 'SecuredByPerimeter'.. + * + * @param publicNetworkAccess Allow, disallow, or let Network Security Perimeter configuration to evaluate + * public network access to Storage Account. Value is optional but if passed in, must be 'Enabled', + * 'Disabled' or 'SecuredByPerimeter'. + * @return the next definition stage. + */ + WithCreate withPublicNetworkAccess(PublicNetworkAccess publicNetworkAccess); + } + + /** + * The stage of the StorageAccount definition allowing to specify sasPolicy. + */ + interface WithSasPolicy { + /** + * Specifies the sasPolicy property: SasPolicy assigned to the storage account.. + * + * @param sasPolicy SasPolicy assigned to the storage account. + * @return the next definition stage. + */ + WithCreate withSasPolicy(SasPolicy sasPolicy); + } + + /** + * The stage of the StorageAccount definition allowing to specify keyPolicy. + */ + interface WithKeyPolicy { + /** + * Specifies the keyPolicy property: KeyPolicy assigned to the storage account.. + * + * @param keyPolicy KeyPolicy assigned to the storage account. + * @return the next definition stage. + */ + WithCreate withKeyPolicy(KeyPolicy keyPolicy); + } + + /** + * The stage of the StorageAccount definition allowing to specify customDomain. + */ + interface WithCustomDomain { + /** + * Specifies the customDomain property: User domain assigned to the storage account. Name is the CNAME + * source. Only one custom domain is supported per storage account at this time. To clear the existing + * custom domain, use an empty string for the custom domain name property.. + * + * @param customDomain User domain assigned to the storage account. Name is the CNAME source. Only one + * custom domain is supported per storage account at this time. To clear the existing custom domain, use an + * empty string for the custom domain name property. + * @return the next definition stage. + */ + WithCreate withCustomDomain(CustomDomain customDomain); + } + + /** + * The stage of the StorageAccount definition allowing to specify encryption. + */ + interface WithEncryption { + /** + * Specifies the encryption property: Encryption settings to be used for server-side encryption for the + * storage account.. + * + * @param encryption Encryption settings to be used for server-side encryption for the storage account. + * @return the next definition stage. + */ + WithCreate withEncryption(Encryption encryption); + } + + /** + * The stage of the StorageAccount definition allowing to specify networkRuleSet. + */ + interface WithNetworkRuleSet { + /** + * Specifies the networkRuleSet property: Network rule set. + * + * @param networkRuleSet Network rule set. + * @return the next definition stage. + */ + WithCreate withNetworkRuleSet(NetworkRuleSet networkRuleSet); + } + + /** + * The stage of the StorageAccount definition allowing to specify accessTier. + */ + interface WithAccessTier { + /** + * Specifies the accessTier property: Required for storage accounts where kind = BlobStorage. The access + * tier is used for billing. The 'Premium' access tier is the default value for premium block blobs storage + * account type and it cannot be changed for the premium block blobs storage account type.. + * + * @param accessTier Required for storage accounts where kind = BlobStorage. The access tier is used for + * billing. The 'Premium' access tier is the default value for premium block blobs storage account type and + * it cannot be changed for the premium block blobs storage account type. + * @return the next definition stage. + */ + WithCreate withAccessTier(AccessTier accessTier); + } + + /** + * The stage of the StorageAccount definition allowing to specify azureFilesIdentityBasedAuthentication. + */ + interface WithAzureFilesIdentityBasedAuthentication { + /** + * Specifies the azureFilesIdentityBasedAuthentication property: Provides the identity based authentication + * settings for Azure Files.. + * + * @param azureFilesIdentityBasedAuthentication Provides the identity based authentication settings for + * Azure Files. + * @return the next definition stage. + */ + WithCreate withAzureFilesIdentityBasedAuthentication( + AzureFilesIdentityBasedAuthentication azureFilesIdentityBasedAuthentication); + } + + /** + * The stage of the StorageAccount definition allowing to specify enableHttpsTrafficOnly. + */ + interface WithEnableHttpsTrafficOnly { + /** + * Specifies the enableHttpsTrafficOnly property: Allows https traffic only to storage service if sets to + * true. The default value is true since API version 2019-04-01.. + * + * @param enableHttpsTrafficOnly Allows https traffic only to storage service if sets to true. The default + * value is true since API version 2019-04-01. + * @return the next definition stage. + */ + WithCreate withEnableHttpsTrafficOnly(Boolean enableHttpsTrafficOnly); + } + + /** + * The stage of the StorageAccount definition allowing to specify isSftpEnabled. + */ + interface WithIsSftpEnabled { + /** + * Specifies the isSftpEnabled property: Enables Secure File Transfer Protocol, if set to true. + * + * @param isSftpEnabled Enables Secure File Transfer Protocol, if set to true. + * @return the next definition stage. + */ + WithCreate withIsSftpEnabled(Boolean isSftpEnabled); + } + + /** + * The stage of the StorageAccount definition allowing to specify isLocalUserEnabled. + */ + interface WithIsLocalUserEnabled { + /** + * Specifies the isLocalUserEnabled property: Enables local users feature, if set to true. + * + * @param isLocalUserEnabled Enables local users feature, if set to true. + * @return the next definition stage. + */ + WithCreate withIsLocalUserEnabled(Boolean isLocalUserEnabled); + } + + /** + * The stage of the StorageAccount definition allowing to specify enableExtendedGroups. + */ + interface WithEnableExtendedGroups { + /** + * Specifies the enableExtendedGroups property: Enables extended group support with local users feature, if + * set to true. + * + * @param enableExtendedGroups Enables extended group support with local users feature, if set to true. + * @return the next definition stage. + */ + WithCreate withEnableExtendedGroups(Boolean enableExtendedGroups); + } + + /** + * The stage of the StorageAccount definition allowing to specify isHnsEnabled. + */ + interface WithIsHnsEnabled { + /** + * Specifies the isHnsEnabled property: Account HierarchicalNamespace enabled if sets to true.. + * + * @param isHnsEnabled Account HierarchicalNamespace enabled if sets to true. + * @return the next definition stage. + */ + WithCreate withIsHnsEnabled(Boolean isHnsEnabled); + } + + /** + * The stage of the StorageAccount definition allowing to specify largeFileSharesState. + */ + interface WithLargeFileSharesState { + /** + * Specifies the largeFileSharesState property: Allow large file shares if sets to Enabled. It cannot be + * disabled once it is enabled.. + * + * @param largeFileSharesState Allow large file shares if sets to Enabled. It cannot be disabled once it is + * enabled. + * @return the next definition stage. + */ + WithCreate withLargeFileSharesState(LargeFileSharesState largeFileSharesState); + } + + /** + * The stage of the StorageAccount definition allowing to specify routingPreference. + */ + interface WithRoutingPreference { + /** + * Specifies the routingPreference property: Maintains information about the network routing choice opted by + * the user for data transfer. + * + * @param routingPreference Maintains information about the network routing choice opted by the user for + * data transfer. + * @return the next definition stage. + */ + WithCreate withRoutingPreference(RoutingPreference routingPreference); + } + + /** + * The stage of the StorageAccount definition allowing to specify dualStackEndpointPreference. + */ + interface WithDualStackEndpointPreference { + /** + * Specifies the dualStackEndpointPreference property: Maintains information about the Internet protocol + * opted by the user.. + * + * @param dualStackEndpointPreference Maintains information about the Internet protocol opted by the user. + * @return the next definition stage. + */ + WithCreate withDualStackEndpointPreference(DualStackEndpointPreference dualStackEndpointPreference); + } + + /** + * The stage of the StorageAccount definition allowing to specify allowBlobPublicAccess. + */ + interface WithAllowBlobPublicAccess { + /** + * Specifies the allowBlobPublicAccess property: Allow or disallow public access to all blobs or containers + * in the storage account. The default interpretation is false for this property.. + * + * @param allowBlobPublicAccess Allow or disallow public access to all blobs or containers in the storage + * account. The default interpretation is false for this property. + * @return the next definition stage. + */ + WithCreate withAllowBlobPublicAccess(Boolean allowBlobPublicAccess); + } + + /** + * The stage of the StorageAccount definition allowing to specify minimumTlsVersion. + */ + interface WithMinimumTlsVersion { + /** + * Specifies the minimumTlsVersion property: Set the minimum TLS version to be permitted on requests to + * storage. The default interpretation is TLS 1.0 for this property. Minimum TLS version 1.3 version is not + * supported.. + * + * @param minimumTlsVersion Set the minimum TLS version to be permitted on requests to storage. The default + * interpretation is TLS 1.0 for this property. Minimum TLS version 1.3 version is not supported. + * @return the next definition stage. + */ + WithCreate withMinimumTlsVersion(MinimumTlsVersion minimumTlsVersion); + } + + /** + * The stage of the StorageAccount definition allowing to specify allowSharedKeyAccess. + */ + interface WithAllowSharedKeyAccess { + /** + * Specifies the allowSharedKeyAccess property: Indicates whether the storage account permits requests to be + * authorized with the account access key via Shared Key. If false, then all requests, including shared + * access signatures, must be authorized with Azure Active Directory (Azure AD). The default value is null, + * which is equivalent to true.. + * + * @param allowSharedKeyAccess Indicates whether the storage account permits requests to be authorized with + * the account access key via Shared Key. If false, then all requests, including shared access signatures, + * must be authorized with Azure Active Directory (Azure AD). The default value is null, which is equivalent + * to true. + * @return the next definition stage. + */ + WithCreate withAllowSharedKeyAccess(Boolean allowSharedKeyAccess); + } + + /** + * The stage of the StorageAccount definition allowing to specify enableNfsV3. + */ + interface WithEnableNfsV3 { + /** + * Specifies the enableNfsV3 property: NFS 3.0 protocol support enabled if set to true.. + * + * @param enableNfsV3 NFS 3.0 protocol support enabled if set to true. + * @return the next definition stage. + */ + WithCreate withEnableNfsV3(Boolean enableNfsV3); + } + + /** + * The stage of the StorageAccount definition allowing to specify allowCrossTenantReplication. + */ + interface WithAllowCrossTenantReplication { + /** + * Specifies the allowCrossTenantReplication property: Allow or disallow cross AAD tenant object + * replication. Set this property to true for new or existing accounts only if object replication policies + * will involve storage accounts in different AAD tenants. The default interpretation is false for new + * accounts to follow best security practices by default.. + * + * @param allowCrossTenantReplication Allow or disallow cross AAD tenant object replication. Set this + * property to true for new or existing accounts only if object replication policies will involve storage + * accounts in different AAD tenants. The default interpretation is false for new accounts to follow best + * security practices by default. + * @return the next definition stage. + */ + WithCreate withAllowCrossTenantReplication(Boolean allowCrossTenantReplication); + } + + /** + * The stage of the StorageAccount definition allowing to specify defaultToOAuthAuthentication. + */ + interface WithDefaultToOAuthAuthentication { + /** + * Specifies the defaultToOAuthAuthentication property: A boolean flag which indicates whether the default + * authentication is OAuth or not. The default interpretation is false for this property.. + * + * @param defaultToOAuthAuthentication A boolean flag which indicates whether the default authentication is + * OAuth or not. The default interpretation is false for this property. + * @return the next definition stage. + */ + WithCreate withDefaultToOAuthAuthentication(Boolean defaultToOAuthAuthentication); + } + + /** + * The stage of the StorageAccount definition allowing to specify immutableStorageWithVersioning. + */ + interface WithImmutableStorageWithVersioning { + /** + * Specifies the immutableStorageWithVersioning property: The property is immutable and can only be set to + * true at the account creation time. When set to true, it enables object level immutability for all the new + * containers in the account by default.. + * + * @param immutableStorageWithVersioning The property is immutable and can only be set to true at the + * account creation time. When set to true, it enables object level immutability for all the new containers + * in the account by default. + * @return the next definition stage. + */ + WithCreate withImmutableStorageWithVersioning(ImmutableStorageAccount immutableStorageWithVersioning); + } + + /** + * The stage of the StorageAccount definition allowing to specify dnsEndpointType. + */ + interface WithDnsEndpointType { + /** + * Specifies the dnsEndpointType property: Allows you to specify the type of endpoint. Set this to + * AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an + * Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier.. + * + * @param dnsEndpointType Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a + * large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the + * endpoint URL will have an alphanumeric DNS Zone identifier. + * @return the next definition stage. + */ + WithCreate withDnsEndpointType(DnsEndpointType dnsEndpointType); + } + + /** + * The stage of the StorageAccount definition allowing to specify geoPriorityReplicationStatus. + */ + interface WithGeoPriorityReplicationStatus { + /** + * Specifies the geoPriorityReplicationStatus property: Status indicating whether Geo Priority Replication + * is enabled for the account.. + * + * @param geoPriorityReplicationStatus Status indicating whether Geo Priority Replication is enabled for the + * account. + * @return the next definition stage. + */ + WithCreate withGeoPriorityReplicationStatus(GeoPriorityReplicationStatus geoPriorityReplicationStatus); + } + + /** + * The stage of the StorageAccount definition allowing to specify allowSharedKeyAccessForServices. + */ + interface WithAllowSharedKeyAccessForServices { + /** + * Specifies the allowSharedKeyAccessForServices property: Indicate shared key access properties at service + * level. + * + * @param allowSharedKeyAccessForServices Indicate shared key access properties at service level. + * @return the next definition stage. + */ + WithCreate withAllowSharedKeyAccessForServices( + StorageAccountSharedKeyAccessProperties allowSharedKeyAccessForServices); + } + + /** + * The stage of the StorageAccount definition allowing to specify dataCollaborationPolicyProperties. + */ + interface WithDataCollaborationPolicyProperties { + /** + * Specifies the dataCollaborationPolicyProperties property: Data Collaboration policy for the storage + * account.. + * + * @param dataCollaborationPolicyProperties Data Collaboration policy for the storage account. + * @return the next definition stage. + */ + WithCreate withDataCollaborationPolicyProperties( + StorageDataCollaborationPolicyProperties dataCollaborationPolicyProperties); + } + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccountCreateParameters.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccountCreateParameters.java new file mode 100644 index 0000000000000..9dd7341d61671 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccountCreateParameters.java @@ -0,0 +1,1066 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.storage.fluent.models.StorageAccountPropertiesCreateParameters; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * The parameters used when creating a storage account. + */ +@Fluent +public final class StorageAccountCreateParameters implements JsonSerializable { + /* + * Required. Gets or sets the SKU name. + */ + private Sku sku; + + /* + * Required. Indicates the type of storage account. + */ + private Kind kind; + + /* + * Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo + * Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region of a resource cannot be changed once it is + * created, but if an identical geo region is specified on update, the request will succeed. + */ + private String location; + + /* + * Optional. Set the extended location of the resource. If not set, the storage account will be created in Azure + * main region. Otherwise it will be created in the specified extended location + */ + private ExtendedLocation extendedLocation; + + /* + * Optional. Gets or sets the pinned logical availability zone for the storage account. + */ + private List zones; + + /* + * Optional. Gets or sets the zonal placement details for the storage account. + */ + private Placement placement; + + /* + * Gets or sets a list of key value pairs that describe the resource. These tags can be used for viewing and + * grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag + * must have a key with a length no greater than 128 characters and a value with a length no greater than 256 + * characters. + */ + private Map tags; + + /* + * The identity of the resource. + */ + private Identity identity; + + /* + * The parameters used to create the storage account. + */ + private StorageAccountPropertiesCreateParameters innerProperties; + + /** + * Creates an instance of StorageAccountCreateParameters class. + */ + public StorageAccountCreateParameters() { + } + + /** + * Get the sku property: Required. Gets or sets the SKU name. + * + * @return the sku value. + */ + public Sku sku() { + return this.sku; + } + + /** + * Set the sku property: Required. Gets or sets the SKU name. + * + * @param sku the sku value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withSku(Sku sku) { + this.sku = sku; + return this; + } + + /** + * Get the kind property: Required. Indicates the type of storage account. + * + * @return the kind value. + */ + public Kind kind() { + return this.kind; + } + + /** + * Set the kind property: Required. Indicates the type of storage account. + * + * @param kind the kind value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withKind(Kind kind) { + this.kind = kind; + return this; + } + + /** + * Get the location property: Required. Gets or sets the location of the resource. This will be one of the supported + * and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region of a resource + * cannot be changed once it is created, but if an identical geo region is specified on update, the request will + * succeed. + * + * @return the location value. + */ + public String location() { + return this.location; + } + + /** + * Set the location property: Required. Gets or sets the location of the resource. This will be one of the supported + * and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region of a resource + * cannot be changed once it is created, but if an identical geo region is specified on update, the request will + * succeed. + * + * @param location the location value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withLocation(String location) { + this.location = location; + return this; + } + + /** + * Get the extendedLocation property: Optional. Set the extended location of the resource. If not set, the storage + * account will be created in Azure main region. Otherwise it will be created in the specified extended location. + * + * @return the extendedLocation value. + */ + public ExtendedLocation extendedLocation() { + return this.extendedLocation; + } + + /** + * Set the extendedLocation property: Optional. Set the extended location of the resource. If not set, the storage + * account will be created in Azure main region. Otherwise it will be created in the specified extended location. + * + * @param extendedLocation the extendedLocation value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withExtendedLocation(ExtendedLocation extendedLocation) { + this.extendedLocation = extendedLocation; + return this; + } + + /** + * Get the zones property: Optional. Gets or sets the pinned logical availability zone for the storage account. + * + * @return the zones value. + */ + public List zones() { + return this.zones; + } + + /** + * Set the zones property: Optional. Gets or sets the pinned logical availability zone for the storage account. + * + * @param zones the zones value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withZones(List zones) { + this.zones = zones; + return this; + } + + /** + * Get the placement property: Optional. Gets or sets the zonal placement details for the storage account. + * + * @return the placement value. + */ + public Placement placement() { + return this.placement; + } + + /** + * Set the placement property: Optional. Gets or sets the zonal placement details for the storage account. + * + * @param placement the placement value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withPlacement(Placement placement) { + this.placement = placement; + return this; + } + + /** + * Get the tags property: Gets or sets a list of key value pairs that describe the resource. These tags can be used + * for viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a + * resource. Each tag must have a key with a length no greater than 128 characters and a value with a length no + * greater than 256 characters. + * + * @return the tags value. + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags property: Gets or sets a list of key value pairs that describe the resource. These tags can be used + * for viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a + * resource. Each tag must have a key with a length no greater than 128 characters and a value with a length no + * greater than 256 characters. + * + * @param tags the tags value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * Get the identity property: The identity of the resource. + * + * @return the identity value. + */ + public Identity identity() { + return this.identity; + } + + /** + * Set the identity property: The identity of the resource. + * + * @param identity the identity value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withIdentity(Identity identity) { + this.identity = identity; + return this; + } + + /** + * Get the innerProperties property: The parameters used to create the storage account. + * + * @return the innerProperties value. + */ + private StorageAccountPropertiesCreateParameters innerProperties() { + return this.innerProperties; + } + + /** + * Get the allowedCopyScope property: Restrict copy to and from Storage Accounts within an AAD tenant or with + * Private Links to the same VNet. + * + * @return the allowedCopyScope value. + */ + public AllowedCopyScope allowedCopyScope() { + return this.innerProperties() == null ? null : this.innerProperties().allowedCopyScope(); + } + + /** + * Set the allowedCopyScope property: Restrict copy to and from Storage Accounts within an AAD tenant or with + * Private Links to the same VNet. + * + * @param allowedCopyScope the allowedCopyScope value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withAllowedCopyScope(AllowedCopyScope allowedCopyScope) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withAllowedCopyScope(allowedCopyScope); + return this; + } + + /** + * Get the publicNetworkAccess property: Allow, disallow, or let Network Security Perimeter configuration to + * evaluate public network access to Storage Account. Value is optional but if passed in, must be 'Enabled', + * 'Disabled' or 'SecuredByPerimeter'. + * + * @return the publicNetworkAccess value. + */ + public PublicNetworkAccess publicNetworkAccess() { + return this.innerProperties() == null ? null : this.innerProperties().publicNetworkAccess(); + } + + /** + * Set the publicNetworkAccess property: Allow, disallow, or let Network Security Perimeter configuration to + * evaluate public network access to Storage Account. Value is optional but if passed in, must be 'Enabled', + * 'Disabled' or 'SecuredByPerimeter'. + * + * @param publicNetworkAccess the publicNetworkAccess value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withPublicNetworkAccess(PublicNetworkAccess publicNetworkAccess) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withPublicNetworkAccess(publicNetworkAccess); + return this; + } + + /** + * Get the sasPolicy property: SasPolicy assigned to the storage account. + * + * @return the sasPolicy value. + */ + public SasPolicy sasPolicy() { + return this.innerProperties() == null ? null : this.innerProperties().sasPolicy(); + } + + /** + * Set the sasPolicy property: SasPolicy assigned to the storage account. + * + * @param sasPolicy the sasPolicy value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withSasPolicy(SasPolicy sasPolicy) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withSasPolicy(sasPolicy); + return this; + } + + /** + * Get the keyPolicy property: KeyPolicy assigned to the storage account. + * + * @return the keyPolicy value. + */ + public KeyPolicy keyPolicy() { + return this.innerProperties() == null ? null : this.innerProperties().keyPolicy(); + } + + /** + * Set the keyPolicy property: KeyPolicy assigned to the storage account. + * + * @param keyPolicy the keyPolicy value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withKeyPolicy(KeyPolicy keyPolicy) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withKeyPolicy(keyPolicy); + return this; + } + + /** + * Get the customDomain property: User domain assigned to the storage account. Name is the CNAME source. Only one + * custom domain is supported per storage account at this time. To clear the existing custom domain, use an empty + * string for the custom domain name property. + * + * @return the customDomain value. + */ + public CustomDomain customDomain() { + return this.innerProperties() == null ? null : this.innerProperties().customDomain(); + } + + /** + * Set the customDomain property: User domain assigned to the storage account. Name is the CNAME source. Only one + * custom domain is supported per storage account at this time. To clear the existing custom domain, use an empty + * string for the custom domain name property. + * + * @param customDomain the customDomain value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withCustomDomain(CustomDomain customDomain) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withCustomDomain(customDomain); + return this; + } + + /** + * Get the encryption property: Encryption settings to be used for server-side encryption for the storage account. + * + * @return the encryption value. + */ + public Encryption encryption() { + return this.innerProperties() == null ? null : this.innerProperties().encryption(); + } + + /** + * Set the encryption property: Encryption settings to be used for server-side encryption for the storage account. + * + * @param encryption the encryption value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withEncryption(Encryption encryption) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withEncryption(encryption); + return this; + } + + /** + * Get the networkRuleSet property: Network rule set. + * + * @return the networkRuleSet value. + */ + public NetworkRuleSet networkRuleSet() { + return this.innerProperties() == null ? null : this.innerProperties().networkRuleSet(); + } + + /** + * Set the networkRuleSet property: Network rule set. + * + * @param networkRuleSet the networkRuleSet value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withNetworkRuleSet(NetworkRuleSet networkRuleSet) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withNetworkRuleSet(networkRuleSet); + return this; + } + + /** + * Get the accessTier property: Required for storage accounts where kind = BlobStorage. The access tier is used for + * billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it + * cannot be changed for the premium block blobs storage account type. + * + * @return the accessTier value. + */ + public AccessTier accessTier() { + return this.innerProperties() == null ? null : this.innerProperties().accessTier(); + } + + /** + * Set the accessTier property: Required for storage accounts where kind = BlobStorage. The access tier is used for + * billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it + * cannot be changed for the premium block blobs storage account type. + * + * @param accessTier the accessTier value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withAccessTier(AccessTier accessTier) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withAccessTier(accessTier); + return this; + } + + /** + * Get the azureFilesIdentityBasedAuthentication property: Provides the identity based authentication settings for + * Azure Files. + * + * @return the azureFilesIdentityBasedAuthentication value. + */ + public AzureFilesIdentityBasedAuthentication azureFilesIdentityBasedAuthentication() { + return this.innerProperties() == null ? null : this.innerProperties().azureFilesIdentityBasedAuthentication(); + } + + /** + * Set the azureFilesIdentityBasedAuthentication property: Provides the identity based authentication settings for + * Azure Files. + * + * @param azureFilesIdentityBasedAuthentication the azureFilesIdentityBasedAuthentication value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withAzureFilesIdentityBasedAuthentication( + AzureFilesIdentityBasedAuthentication azureFilesIdentityBasedAuthentication) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withAzureFilesIdentityBasedAuthentication(azureFilesIdentityBasedAuthentication); + return this; + } + + /** + * Get the enableHttpsTrafficOnly property: Allows https traffic only to storage service if sets to true. The + * default value is true since API version 2019-04-01. + * + * @return the enableHttpsTrafficOnly value. + */ + public Boolean enableHttpsTrafficOnly() { + return this.innerProperties() == null ? null : this.innerProperties().enableHttpsTrafficOnly(); + } + + /** + * Set the enableHttpsTrafficOnly property: Allows https traffic only to storage service if sets to true. The + * default value is true since API version 2019-04-01. + * + * @param enableHttpsTrafficOnly the enableHttpsTrafficOnly value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withEnableHttpsTrafficOnly(Boolean enableHttpsTrafficOnly) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withEnableHttpsTrafficOnly(enableHttpsTrafficOnly); + return this; + } + + /** + * Get the isSftpEnabled property: Enables Secure File Transfer Protocol, if set to true. + * + * @return the isSftpEnabled value. + */ + public Boolean isSftpEnabled() { + return this.innerProperties() == null ? null : this.innerProperties().isSftpEnabled(); + } + + /** + * Set the isSftpEnabled property: Enables Secure File Transfer Protocol, if set to true. + * + * @param isSftpEnabled the isSftpEnabled value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withIsSftpEnabled(Boolean isSftpEnabled) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withIsSftpEnabled(isSftpEnabled); + return this; + } + + /** + * Get the isLocalUserEnabled property: Enables local users feature, if set to true. + * + * @return the isLocalUserEnabled value. + */ + public Boolean isLocalUserEnabled() { + return this.innerProperties() == null ? null : this.innerProperties().isLocalUserEnabled(); + } + + /** + * Set the isLocalUserEnabled property: Enables local users feature, if set to true. + * + * @param isLocalUserEnabled the isLocalUserEnabled value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withIsLocalUserEnabled(Boolean isLocalUserEnabled) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withIsLocalUserEnabled(isLocalUserEnabled); + return this; + } + + /** + * Get the enableExtendedGroups property: Enables extended group support with local users feature, if set to true. + * + * @return the enableExtendedGroups value. + */ + public Boolean enableExtendedGroups() { + return this.innerProperties() == null ? null : this.innerProperties().enableExtendedGroups(); + } + + /** + * Set the enableExtendedGroups property: Enables extended group support with local users feature, if set to true. + * + * @param enableExtendedGroups the enableExtendedGroups value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withEnableExtendedGroups(Boolean enableExtendedGroups) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withEnableExtendedGroups(enableExtendedGroups); + return this; + } + + /** + * Get the isHnsEnabled property: Account HierarchicalNamespace enabled if sets to true. + * + * @return the isHnsEnabled value. + */ + public Boolean isHnsEnabled() { + return this.innerProperties() == null ? null : this.innerProperties().isHnsEnabled(); + } + + /** + * Set the isHnsEnabled property: Account HierarchicalNamespace enabled if sets to true. + * + * @param isHnsEnabled the isHnsEnabled value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withIsHnsEnabled(Boolean isHnsEnabled) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withIsHnsEnabled(isHnsEnabled); + return this; + } + + /** + * Get the largeFileSharesState property: Allow large file shares if sets to Enabled. It cannot be disabled once it + * is enabled. + * + * @return the largeFileSharesState value. + */ + public LargeFileSharesState largeFileSharesState() { + return this.innerProperties() == null ? null : this.innerProperties().largeFileSharesState(); + } + + /** + * Set the largeFileSharesState property: Allow large file shares if sets to Enabled. It cannot be disabled once it + * is enabled. + * + * @param largeFileSharesState the largeFileSharesState value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withLargeFileSharesState(LargeFileSharesState largeFileSharesState) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withLargeFileSharesState(largeFileSharesState); + return this; + } + + /** + * Get the routingPreference property: Maintains information about the network routing choice opted by the user for + * data transfer. + * + * @return the routingPreference value. + */ + public RoutingPreference routingPreference() { + return this.innerProperties() == null ? null : this.innerProperties().routingPreference(); + } + + /** + * Set the routingPreference property: Maintains information about the network routing choice opted by the user for + * data transfer. + * + * @param routingPreference the routingPreference value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withRoutingPreference(RoutingPreference routingPreference) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withRoutingPreference(routingPreference); + return this; + } + + /** + * Get the dualStackEndpointPreference property: Maintains information about the Internet protocol opted by the + * user. + * + * @return the dualStackEndpointPreference value. + */ + public DualStackEndpointPreference dualStackEndpointPreference() { + return this.innerProperties() == null ? null : this.innerProperties().dualStackEndpointPreference(); + } + + /** + * Set the dualStackEndpointPreference property: Maintains information about the Internet protocol opted by the + * user. + * + * @param dualStackEndpointPreference the dualStackEndpointPreference value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters + withDualStackEndpointPreference(DualStackEndpointPreference dualStackEndpointPreference) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withDualStackEndpointPreference(dualStackEndpointPreference); + return this; + } + + /** + * Get the allowBlobPublicAccess property: Allow or disallow public access to all blobs or containers in the storage + * account. The default interpretation is false for this property. + * + * @return the allowBlobPublicAccess value. + */ + public Boolean allowBlobPublicAccess() { + return this.innerProperties() == null ? null : this.innerProperties().allowBlobPublicAccess(); + } + + /** + * Set the allowBlobPublicAccess property: Allow or disallow public access to all blobs or containers in the storage + * account. The default interpretation is false for this property. + * + * @param allowBlobPublicAccess the allowBlobPublicAccess value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withAllowBlobPublicAccess(Boolean allowBlobPublicAccess) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withAllowBlobPublicAccess(allowBlobPublicAccess); + return this; + } + + /** + * Get the minimumTlsVersion property: Set the minimum TLS version to be permitted on requests to storage. The + * default interpretation is TLS 1.0 for this property. Minimum TLS version 1.3 version is not supported. + * + * @return the minimumTlsVersion value. + */ + public MinimumTlsVersion minimumTlsVersion() { + return this.innerProperties() == null ? null : this.innerProperties().minimumTlsVersion(); + } + + /** + * Set the minimumTlsVersion property: Set the minimum TLS version to be permitted on requests to storage. The + * default interpretation is TLS 1.0 for this property. Minimum TLS version 1.3 version is not supported. + * + * @param minimumTlsVersion the minimumTlsVersion value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withMinimumTlsVersion(MinimumTlsVersion minimumTlsVersion) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withMinimumTlsVersion(minimumTlsVersion); + return this; + } + + /** + * Get the allowSharedKeyAccess property: Indicates whether the storage account permits requests to be authorized + * with the account access key via Shared Key. If false, then all requests, including shared access signatures, must + * be authorized with Azure Active Directory (Azure AD). The default value is null, which is equivalent to true. + * + * @return the allowSharedKeyAccess value. + */ + public Boolean allowSharedKeyAccess() { + return this.innerProperties() == null ? null : this.innerProperties().allowSharedKeyAccess(); + } + + /** + * Set the allowSharedKeyAccess property: Indicates whether the storage account permits requests to be authorized + * with the account access key via Shared Key. If false, then all requests, including shared access signatures, must + * be authorized with Azure Active Directory (Azure AD). The default value is null, which is equivalent to true. + * + * @param allowSharedKeyAccess the allowSharedKeyAccess value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withAllowSharedKeyAccess(Boolean allowSharedKeyAccess) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withAllowSharedKeyAccess(allowSharedKeyAccess); + return this; + } + + /** + * Get the enableNfsV3 property: NFS 3.0 protocol support enabled if set to true. + * + * @return the enableNfsV3 value. + */ + public Boolean enableNfsV3() { + return this.innerProperties() == null ? null : this.innerProperties().enableNfsV3(); + } + + /** + * Set the enableNfsV3 property: NFS 3.0 protocol support enabled if set to true. + * + * @param enableNfsV3 the enableNfsV3 value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withEnableNfsV3(Boolean enableNfsV3) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withEnableNfsV3(enableNfsV3); + return this; + } + + /** + * Get the allowCrossTenantReplication property: Allow or disallow cross AAD tenant object replication. Set this + * property to true for new or existing accounts only if object replication policies will involve storage accounts + * in different AAD tenants. The default interpretation is false for new accounts to follow best security practices + * by default. + * + * @return the allowCrossTenantReplication value. + */ + public Boolean allowCrossTenantReplication() { + return this.innerProperties() == null ? null : this.innerProperties().allowCrossTenantReplication(); + } + + /** + * Set the allowCrossTenantReplication property: Allow or disallow cross AAD tenant object replication. Set this + * property to true for new or existing accounts only if object replication policies will involve storage accounts + * in different AAD tenants. The default interpretation is false for new accounts to follow best security practices + * by default. + * + * @param allowCrossTenantReplication the allowCrossTenantReplication value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withAllowCrossTenantReplication(Boolean allowCrossTenantReplication) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withAllowCrossTenantReplication(allowCrossTenantReplication); + return this; + } + + /** + * Get the defaultToOAuthAuthentication property: A boolean flag which indicates whether the default authentication + * is OAuth or not. The default interpretation is false for this property. + * + * @return the defaultToOAuthAuthentication value. + */ + public Boolean defaultToOAuthAuthentication() { + return this.innerProperties() == null ? null : this.innerProperties().defaultToOAuthAuthentication(); + } + + /** + * Set the defaultToOAuthAuthentication property: A boolean flag which indicates whether the default authentication + * is OAuth or not. The default interpretation is false for this property. + * + * @param defaultToOAuthAuthentication the defaultToOAuthAuthentication value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withDefaultToOAuthAuthentication(Boolean defaultToOAuthAuthentication) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withDefaultToOAuthAuthentication(defaultToOAuthAuthentication); + return this; + } + + /** + * Get the immutableStorageWithVersioning property: The property is immutable and can only be set to true at the + * account creation time. When set to true, it enables object level immutability for all the new containers in the + * account by default. + * + * @return the immutableStorageWithVersioning value. + */ + public ImmutableStorageAccount immutableStorageWithVersioning() { + return this.innerProperties() == null ? null : this.innerProperties().immutableStorageWithVersioning(); + } + + /** + * Set the immutableStorageWithVersioning property: The property is immutable and can only be set to true at the + * account creation time. When set to true, it enables object level immutability for all the new containers in the + * account by default. + * + * @param immutableStorageWithVersioning the immutableStorageWithVersioning value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters + withImmutableStorageWithVersioning(ImmutableStorageAccount immutableStorageWithVersioning) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withImmutableStorageWithVersioning(immutableStorageWithVersioning); + return this; + } + + /** + * Get the dnsEndpointType property: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create + * a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint + * URL will have an alphanumeric DNS Zone identifier. + * + * @return the dnsEndpointType value. + */ + public DnsEndpointType dnsEndpointType() { + return this.innerProperties() == null ? null : this.innerProperties().dnsEndpointType(); + } + + /** + * Set the dnsEndpointType property: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create + * a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint + * URL will have an alphanumeric DNS Zone identifier. + * + * @param dnsEndpointType the dnsEndpointType value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withDnsEndpointType(DnsEndpointType dnsEndpointType) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withDnsEndpointType(dnsEndpointType); + return this; + } + + /** + * Get the geoPriorityReplicationStatus property: Status indicating whether Geo Priority Replication is enabled for + * the account. + * + * @return the geoPriorityReplicationStatus value. + */ + public GeoPriorityReplicationStatus geoPriorityReplicationStatus() { + return this.innerProperties() == null ? null : this.innerProperties().geoPriorityReplicationStatus(); + } + + /** + * Set the geoPriorityReplicationStatus property: Status indicating whether Geo Priority Replication is enabled for + * the account. + * + * @param geoPriorityReplicationStatus the geoPriorityReplicationStatus value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters + withGeoPriorityReplicationStatus(GeoPriorityReplicationStatus geoPriorityReplicationStatus) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withGeoPriorityReplicationStatus(geoPriorityReplicationStatus); + return this; + } + + /** + * Get the allowSharedKeyAccessForServices property: Indicate shared key access properties at service level. + * + * @return the allowSharedKeyAccessForServices value. + */ + public StorageAccountSharedKeyAccessProperties allowSharedKeyAccessForServices() { + return this.innerProperties() == null ? null : this.innerProperties().allowSharedKeyAccessForServices(); + } + + /** + * Set the allowSharedKeyAccessForServices property: Indicate shared key access properties at service level. + * + * @param allowSharedKeyAccessForServices the allowSharedKeyAccessForServices value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters + withAllowSharedKeyAccessForServices(StorageAccountSharedKeyAccessProperties allowSharedKeyAccessForServices) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withAllowSharedKeyAccessForServices(allowSharedKeyAccessForServices); + return this; + } + + /** + * Get the dataCollaborationPolicyProperties property: Data Collaboration policy for the storage account. + * + * @return the dataCollaborationPolicyProperties value. + */ + public StorageDataCollaborationPolicyProperties dataCollaborationPolicyProperties() { + return this.innerProperties() == null ? null : this.innerProperties().dataCollaborationPolicyProperties(); + } + + /** + * Set the dataCollaborationPolicyProperties property: Data Collaboration policy for the storage account. + * + * @param dataCollaborationPolicyProperties the dataCollaborationPolicyProperties value to set. + * @return the StorageAccountCreateParameters object itself. + */ + public StorageAccountCreateParameters withDataCollaborationPolicyProperties( + StorageDataCollaborationPolicyProperties dataCollaborationPolicyProperties) { + if (this.innerProperties() == null) { + this.innerProperties = new StorageAccountPropertiesCreateParameters(); + } + this.innerProperties().withDataCollaborationPolicyProperties(dataCollaborationPolicyProperties); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (sku() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property sku in model StorageAccountCreateParameters")); + } else { + sku().validate(); + } + if (kind() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property kind in model StorageAccountCreateParameters")); + } + if (location() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property location in model StorageAccountCreateParameters")); + } + if (extendedLocation() != null) { + extendedLocation().validate(); + } + if (placement() != null) { + placement().validate(); + } + if (identity() != null) { + identity().validate(); + } + if (innerProperties() != null) { + innerProperties().validate(); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(StorageAccountCreateParameters.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("sku", this.sku); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); + jsonWriter.writeStringField("location", this.location); + jsonWriter.writeJsonField("extendedLocation", this.extendedLocation); + jsonWriter.writeArrayField("zones", this.zones, (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("placement", this.placement); + jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("identity", this.identity); + jsonWriter.writeJsonField("properties", this.innerProperties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StorageAccountCreateParameters from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StorageAccountCreateParameters if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the StorageAccountCreateParameters. + */ + public static StorageAccountCreateParameters fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StorageAccountCreateParameters deserializedStorageAccountCreateParameters + = new StorageAccountCreateParameters(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("sku".equals(fieldName)) { + deserializedStorageAccountCreateParameters.sku = Sku.fromJson(reader); + } else if ("kind".equals(fieldName)) { + deserializedStorageAccountCreateParameters.kind = Kind.fromString(reader.getString()); + } else if ("location".equals(fieldName)) { + deserializedStorageAccountCreateParameters.location = reader.getString(); + } else if ("extendedLocation".equals(fieldName)) { + deserializedStorageAccountCreateParameters.extendedLocation = ExtendedLocation.fromJson(reader); + } else if ("zones".equals(fieldName)) { + List zones = reader.readArray(reader1 -> reader1.getString()); + deserializedStorageAccountCreateParameters.zones = zones; + } else if ("placement".equals(fieldName)) { + deserializedStorageAccountCreateParameters.placement = Placement.fromJson(reader); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedStorageAccountCreateParameters.tags = tags; + } else if ("identity".equals(fieldName)) { + deserializedStorageAccountCreateParameters.identity = Identity.fromJson(reader); + } else if ("properties".equals(fieldName)) { + deserializedStorageAccountCreateParameters.innerProperties + = StorageAccountPropertiesCreateParameters.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedStorageAccountCreateParameters; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccountInternetEndpoints.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccountInternetEndpoints.java new file mode 100644 index 0000000000000..1ba955fcf4a73 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccountInternetEndpoints.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The URIs that are used to perform a retrieval of a public blob, file, web or dfs object via a internet routing + * endpoint. + */ +@Immutable +public final class StorageAccountInternetEndpoints implements JsonSerializable { + /* + * Gets the blob endpoint. + */ + private String blob; + + /* + * Gets the file endpoint. + */ + private String file; + + /* + * Gets the web endpoint. + */ + private String web; + + /* + * Gets the dfs endpoint. + */ + private String dfs; + + /** + * Creates an instance of StorageAccountInternetEndpoints class. + */ + private StorageAccountInternetEndpoints() { + } + + /** + * Get the blob property: Gets the blob endpoint. + * + * @return the blob value. + */ + public String blob() { + return this.blob; + } + + /** + * Get the file property: Gets the file endpoint. + * + * @return the file value. + */ + public String file() { + return this.file; + } + + /** + * Get the web property: Gets the web endpoint. + * + * @return the web value. + */ + public String web() { + return this.web; + } + + /** + * Get the dfs property: Gets the dfs endpoint. + * + * @return the dfs value. + */ + public String dfs() { + return this.dfs; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StorageAccountInternetEndpoints from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StorageAccountInternetEndpoints if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the StorageAccountInternetEndpoints. + */ + public static StorageAccountInternetEndpoints fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StorageAccountInternetEndpoints deserializedStorageAccountInternetEndpoints + = new StorageAccountInternetEndpoints(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("blob".equals(fieldName)) { + deserializedStorageAccountInternetEndpoints.blob = reader.getString(); + } else if ("file".equals(fieldName)) { + deserializedStorageAccountInternetEndpoints.file = reader.getString(); + } else if ("web".equals(fieldName)) { + deserializedStorageAccountInternetEndpoints.web = reader.getString(); + } else if ("dfs".equals(fieldName)) { + deserializedStorageAccountInternetEndpoints.dfs = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedStorageAccountInternetEndpoints; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccountIpv6Endpoints.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccountIpv6Endpoints.java new file mode 100644 index 0000000000000..c561c1800dfa8 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccountIpv6Endpoints.java @@ -0,0 +1,203 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object via an IPv6 endpoint. + */ +@Immutable +public final class StorageAccountIpv6Endpoints implements JsonSerializable { + /* + * Gets the blob endpoint. + */ + private String blob; + + /* + * Gets the queue endpoint. + */ + private String queue; + + /* + * Gets the table endpoint. + */ + private String table; + + /* + * Gets the file endpoint. + */ + private String file; + + /* + * Gets the web endpoint. + */ + private String web; + + /* + * Gets the dfs endpoint. + */ + private String dfs; + + /* + * Gets the microsoft routing storage endpoints. + */ + private StorageAccountMicrosoftEndpoints microsoftEndpoints; + + /* + * Gets the internet routing storage endpoints + */ + private StorageAccountInternetEndpoints internetEndpoints; + + /** + * Creates an instance of StorageAccountIpv6Endpoints class. + */ + private StorageAccountIpv6Endpoints() { + } + + /** + * Get the blob property: Gets the blob endpoint. + * + * @return the blob value. + */ + public String blob() { + return this.blob; + } + + /** + * Get the queue property: Gets the queue endpoint. + * + * @return the queue value. + */ + public String queue() { + return this.queue; + } + + /** + * Get the table property: Gets the table endpoint. + * + * @return the table value. + */ + public String table() { + return this.table; + } + + /** + * Get the file property: Gets the file endpoint. + * + * @return the file value. + */ + public String file() { + return this.file; + } + + /** + * Get the web property: Gets the web endpoint. + * + * @return the web value. + */ + public String web() { + return this.web; + } + + /** + * Get the dfs property: Gets the dfs endpoint. + * + * @return the dfs value. + */ + public String dfs() { + return this.dfs; + } + + /** + * Get the microsoftEndpoints property: Gets the microsoft routing storage endpoints. + * + * @return the microsoftEndpoints value. + */ + public StorageAccountMicrosoftEndpoints microsoftEndpoints() { + return this.microsoftEndpoints; + } + + /** + * Get the internetEndpoints property: Gets the internet routing storage endpoints. + * + * @return the internetEndpoints value. + */ + public StorageAccountInternetEndpoints internetEndpoints() { + return this.internetEndpoints; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (microsoftEndpoints() != null) { + microsoftEndpoints().validate(); + } + if (internetEndpoints() != null) { + internetEndpoints().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("microsoftEndpoints", this.microsoftEndpoints); + jsonWriter.writeJsonField("internetEndpoints", this.internetEndpoints); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StorageAccountIpv6Endpoints from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StorageAccountIpv6Endpoints if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the StorageAccountIpv6Endpoints. + */ + public static StorageAccountIpv6Endpoints fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StorageAccountIpv6Endpoints deserializedStorageAccountIpv6Endpoints = new StorageAccountIpv6Endpoints(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("blob".equals(fieldName)) { + deserializedStorageAccountIpv6Endpoints.blob = reader.getString(); + } else if ("queue".equals(fieldName)) { + deserializedStorageAccountIpv6Endpoints.queue = reader.getString(); + } else if ("table".equals(fieldName)) { + deserializedStorageAccountIpv6Endpoints.table = reader.getString(); + } else if ("file".equals(fieldName)) { + deserializedStorageAccountIpv6Endpoints.file = reader.getString(); + } else if ("web".equals(fieldName)) { + deserializedStorageAccountIpv6Endpoints.web = reader.getString(); + } else if ("dfs".equals(fieldName)) { + deserializedStorageAccountIpv6Endpoints.dfs = reader.getString(); + } else if ("microsoftEndpoints".equals(fieldName)) { + deserializedStorageAccountIpv6Endpoints.microsoftEndpoints + = StorageAccountMicrosoftEndpoints.fromJson(reader); + } else if ("internetEndpoints".equals(fieldName)) { + deserializedStorageAccountIpv6Endpoints.internetEndpoints + = StorageAccountInternetEndpoints.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedStorageAccountIpv6Endpoints; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccountMicrosoftEndpoints.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccountMicrosoftEndpoints.java new file mode 100644 index 0000000000000..a67b3a98ccd1b --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccountMicrosoftEndpoints.java @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object via a microsoft + * routing endpoint. + */ +@Immutable +public final class StorageAccountMicrosoftEndpoints implements JsonSerializable { + /* + * Gets the blob endpoint. + */ + private String blob; + + /* + * Gets the queue endpoint. + */ + private String queue; + + /* + * Gets the table endpoint. + */ + private String table; + + /* + * Gets the file endpoint. + */ + private String file; + + /* + * Gets the web endpoint. + */ + private String web; + + /* + * Gets the dfs endpoint. + */ + private String dfs; + + /** + * Creates an instance of StorageAccountMicrosoftEndpoints class. + */ + private StorageAccountMicrosoftEndpoints() { + } + + /** + * Get the blob property: Gets the blob endpoint. + * + * @return the blob value. + */ + public String blob() { + return this.blob; + } + + /** + * Get the queue property: Gets the queue endpoint. + * + * @return the queue value. + */ + public String queue() { + return this.queue; + } + + /** + * Get the table property: Gets the table endpoint. + * + * @return the table value. + */ + public String table() { + return this.table; + } + + /** + * Get the file property: Gets the file endpoint. + * + * @return the file value. + */ + public String file() { + return this.file; + } + + /** + * Get the web property: Gets the web endpoint. + * + * @return the web value. + */ + public String web() { + return this.web; + } + + /** + * Get the dfs property: Gets the dfs endpoint. + * + * @return the dfs value. + */ + public String dfs() { + return this.dfs; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StorageAccountMicrosoftEndpoints from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StorageAccountMicrosoftEndpoints if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the StorageAccountMicrosoftEndpoints. + */ + public static StorageAccountMicrosoftEndpoints fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StorageAccountMicrosoftEndpoints deserializedStorageAccountMicrosoftEndpoints + = new StorageAccountMicrosoftEndpoints(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("blob".equals(fieldName)) { + deserializedStorageAccountMicrosoftEndpoints.blob = reader.getString(); + } else if ("queue".equals(fieldName)) { + deserializedStorageAccountMicrosoftEndpoints.queue = reader.getString(); + } else if ("table".equals(fieldName)) { + deserializedStorageAccountMicrosoftEndpoints.table = reader.getString(); + } else if ("file".equals(fieldName)) { + deserializedStorageAccountMicrosoftEndpoints.file = reader.getString(); + } else if ("web".equals(fieldName)) { + deserializedStorageAccountMicrosoftEndpoints.web = reader.getString(); + } else if ("dfs".equals(fieldName)) { + deserializedStorageAccountMicrosoftEndpoints.dfs = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedStorageAccountMicrosoftEndpoints; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccountSharedKeyAccessProperties.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccountSharedKeyAccessProperties.java new file mode 100644 index 0000000000000..dc95a31351c0f --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccountSharedKeyAccessProperties.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Defines shared key access properties for a storage account. + */ +@Fluent +public final class StorageAccountSharedKeyAccessProperties + implements JsonSerializable { + /* + * Shared key access settings for Blob service. + */ + private ServiceSharedKeyAccessProperties blob; + + /* + * Shared key access settings for File service. + */ + private ServiceSharedKeyAccessProperties file; + + /* + * Shared key access settings for Table service. + */ + private ServiceSharedKeyAccessProperties table; + + /* + * Shared key access settings for Queue service. + */ + private ServiceSharedKeyAccessProperties queue; + + /** + * Creates an instance of StorageAccountSharedKeyAccessProperties class. + */ + public StorageAccountSharedKeyAccessProperties() { + } + + /** + * Get the blob property: Shared key access settings for Blob service. + * + * @return the blob value. + */ + public ServiceSharedKeyAccessProperties blob() { + return this.blob; + } + + /** + * Set the blob property: Shared key access settings for Blob service. + * + * @param blob the blob value to set. + * @return the StorageAccountSharedKeyAccessProperties object itself. + */ + public StorageAccountSharedKeyAccessProperties withBlob(ServiceSharedKeyAccessProperties blob) { + this.blob = blob; + return this; + } + + /** + * Get the file property: Shared key access settings for File service. + * + * @return the file value. + */ + public ServiceSharedKeyAccessProperties file() { + return this.file; + } + + /** + * Set the file property: Shared key access settings for File service. + * + * @param file the file value to set. + * @return the StorageAccountSharedKeyAccessProperties object itself. + */ + public StorageAccountSharedKeyAccessProperties withFile(ServiceSharedKeyAccessProperties file) { + this.file = file; + return this; + } + + /** + * Get the table property: Shared key access settings for Table service. + * + * @return the table value. + */ + public ServiceSharedKeyAccessProperties table() { + return this.table; + } + + /** + * Set the table property: Shared key access settings for Table service. + * + * @param table the table value to set. + * @return the StorageAccountSharedKeyAccessProperties object itself. + */ + public StorageAccountSharedKeyAccessProperties withTable(ServiceSharedKeyAccessProperties table) { + this.table = table; + return this; + } + + /** + * Get the queue property: Shared key access settings for Queue service. + * + * @return the queue value. + */ + public ServiceSharedKeyAccessProperties queue() { + return this.queue; + } + + /** + * Set the queue property: Shared key access settings for Queue service. + * + * @param queue the queue value to set. + * @return the StorageAccountSharedKeyAccessProperties object itself. + */ + public StorageAccountSharedKeyAccessProperties withQueue(ServiceSharedKeyAccessProperties queue) { + this.queue = queue; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (blob() != null) { + blob().validate(); + } + if (file() != null) { + file().validate(); + } + if (table() != null) { + table().validate(); + } + if (queue() != null) { + queue().validate(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("blob", this.blob); + jsonWriter.writeJsonField("file", this.file); + jsonWriter.writeJsonField("table", this.table); + jsonWriter.writeJsonField("queue", this.queue); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StorageAccountSharedKeyAccessProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StorageAccountSharedKeyAccessProperties if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the StorageAccountSharedKeyAccessProperties. + */ + public static StorageAccountSharedKeyAccessProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StorageAccountSharedKeyAccessProperties deserializedStorageAccountSharedKeyAccessProperties + = new StorageAccountSharedKeyAccessProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("blob".equals(fieldName)) { + deserializedStorageAccountSharedKeyAccessProperties.blob + = ServiceSharedKeyAccessProperties.fromJson(reader); + } else if ("file".equals(fieldName)) { + deserializedStorageAccountSharedKeyAccessProperties.file + = ServiceSharedKeyAccessProperties.fromJson(reader); + } else if ("table".equals(fieldName)) { + deserializedStorageAccountSharedKeyAccessProperties.table + = ServiceSharedKeyAccessProperties.fromJson(reader); + } else if ("queue".equals(fieldName)) { + deserializedStorageAccountSharedKeyAccessProperties.queue + = ServiceSharedKeyAccessProperties.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedStorageAccountSharedKeyAccessProperties; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccountSkuConversionStatus.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccountSkuConversionStatus.java new file mode 100644 index 0000000000000..ab71ba7263c2a --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageAccountSkuConversionStatus.java @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * This defines the sku conversion status object for asynchronous sku conversions. + */ +@Fluent +public final class StorageAccountSkuConversionStatus implements JsonSerializable { + /* + * This property indicates the current sku conversion status. + */ + private SkuConversionStatus skuConversionStatus; + + /* + * This property represents the target sku name to which the account sku is being converted asynchronously. + */ + private SkuName targetSkuName; + + /* + * This property represents the sku conversion start time. + */ + private String startTime; + + /* + * This property represents the sku conversion end time. + */ + private String endTime; + + /** + * Creates an instance of StorageAccountSkuConversionStatus class. + */ + public StorageAccountSkuConversionStatus() { + } + + /** + * Get the skuConversionStatus property: This property indicates the current sku conversion status. + * + * @return the skuConversionStatus value. + */ + public SkuConversionStatus skuConversionStatus() { + return this.skuConversionStatus; + } + + /** + * Get the targetSkuName property: This property represents the target sku name to which the account sku is being + * converted asynchronously. + * + * @return the targetSkuName value. + */ + public SkuName targetSkuName() { + return this.targetSkuName; + } + + /** + * Set the targetSkuName property: This property represents the target sku name to which the account sku is being + * converted asynchronously. + * + * @param targetSkuName the targetSkuName value to set. + * @return the StorageAccountSkuConversionStatus object itself. + */ + public StorageAccountSkuConversionStatus withTargetSkuName(SkuName targetSkuName) { + this.targetSkuName = targetSkuName; + return this; + } + + /** + * Get the startTime property: This property represents the sku conversion start time. + * + * @return the startTime value. + */ + public String startTime() { + return this.startTime; + } + + /** + * Get the endTime property: This property represents the sku conversion end time. + * + * @return the endTime value. + */ + public String endTime() { + return this.endTime; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("targetSkuName", this.targetSkuName == null ? null : this.targetSkuName.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StorageAccountSkuConversionStatus from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StorageAccountSkuConversionStatus if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the StorageAccountSkuConversionStatus. + */ + public static StorageAccountSkuConversionStatus fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StorageAccountSkuConversionStatus deserializedStorageAccountSkuConversionStatus + = new StorageAccountSkuConversionStatus(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("skuConversionStatus".equals(fieldName)) { + deserializedStorageAccountSkuConversionStatus.skuConversionStatus + = SkuConversionStatus.fromString(reader.getString()); + } else if ("targetSkuName".equals(fieldName)) { + deserializedStorageAccountSkuConversionStatus.targetSkuName + = SkuName.fromString(reader.getString()); + } else if ("startTime".equals(fieldName)) { + deserializedStorageAccountSkuConversionStatus.startTime = reader.getString(); + } else if ("endTime".equals(fieldName)) { + deserializedStorageAccountSkuConversionStatus.endTime = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedStorageAccountSkuConversionStatus; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageDataCollaborationPolicyProperties.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageDataCollaborationPolicyProperties.java new file mode 100644 index 0000000000000..c8b1183174179 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/StorageDataCollaborationPolicyProperties.java @@ -0,0 +1,161 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Defines Data Collaboration Policy for a storage account. + */ +@Fluent +public final class StorageDataCollaborationPolicyProperties + implements JsonSerializable { + /* + * Indicates whether storage connectors are allowed to created or managed on the storage account. + */ + private Boolean allowStorageConnectors; + + /* + * Indicates whether data shares are allowed to be created or managed on the storage account. + */ + private Boolean allowStorageDataShares; + + /* + * Indicates whether cross-entra tenant data sharing is allowed on the storage account. + */ + private Boolean allowCrossTenantDataSharing; + + /** + * Creates an instance of StorageDataCollaborationPolicyProperties class. + */ + public StorageDataCollaborationPolicyProperties() { + } + + /** + * Get the allowStorageConnectors property: Indicates whether storage connectors are allowed to created or managed + * on the storage account. + * + * @return the allowStorageConnectors value. + */ + public Boolean allowStorageConnectors() { + return this.allowStorageConnectors; + } + + /** + * Set the allowStorageConnectors property: Indicates whether storage connectors are allowed to created or managed + * on the storage account. + * + * @param allowStorageConnectors the allowStorageConnectors value to set. + * @return the StorageDataCollaborationPolicyProperties object itself. + */ + public StorageDataCollaborationPolicyProperties withAllowStorageConnectors(Boolean allowStorageConnectors) { + this.allowStorageConnectors = allowStorageConnectors; + return this; + } + + /** + * Get the allowStorageDataShares property: Indicates whether data shares are allowed to be created or managed on + * the storage account. + * + * @return the allowStorageDataShares value. + */ + public Boolean allowStorageDataShares() { + return this.allowStorageDataShares; + } + + /** + * Set the allowStorageDataShares property: Indicates whether data shares are allowed to be created or managed on + * the storage account. + * + * @param allowStorageDataShares the allowStorageDataShares value to set. + * @return the StorageDataCollaborationPolicyProperties object itself. + */ + public StorageDataCollaborationPolicyProperties withAllowStorageDataShares(Boolean allowStorageDataShares) { + this.allowStorageDataShares = allowStorageDataShares; + return this; + } + + /** + * Get the allowCrossTenantDataSharing property: Indicates whether cross-entra tenant data sharing is allowed on the + * storage account. + * + * @return the allowCrossTenantDataSharing value. + */ + public Boolean allowCrossTenantDataSharing() { + return this.allowCrossTenantDataSharing; + } + + /** + * Set the allowCrossTenantDataSharing property: Indicates whether cross-entra tenant data sharing is allowed on the + * storage account. + * + * @param allowCrossTenantDataSharing the allowCrossTenantDataSharing value to set. + * @return the StorageDataCollaborationPolicyProperties object itself. + */ + public StorageDataCollaborationPolicyProperties + withAllowCrossTenantDataSharing(Boolean allowCrossTenantDataSharing) { + this.allowCrossTenantDataSharing = allowCrossTenantDataSharing; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("allowStorageConnectors", this.allowStorageConnectors); + jsonWriter.writeBooleanField("allowStorageDataShares", this.allowStorageDataShares); + jsonWriter.writeBooleanField("allowCrossTenantDataSharing", this.allowCrossTenantDataSharing); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StorageDataCollaborationPolicyProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StorageDataCollaborationPolicyProperties if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the StorageDataCollaborationPolicyProperties. + */ + public static StorageDataCollaborationPolicyProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StorageDataCollaborationPolicyProperties deserializedStorageDataCollaborationPolicyProperties + = new StorageDataCollaborationPolicyProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("allowStorageConnectors".equals(fieldName)) { + deserializedStorageDataCollaborationPolicyProperties.allowStorageConnectors + = reader.getNullable(JsonReader::getBoolean); + } else if ("allowStorageDataShares".equals(fieldName)) { + deserializedStorageDataCollaborationPolicyProperties.allowStorageDataShares + = reader.getNullable(JsonReader::getBoolean); + } else if ("allowCrossTenantDataSharing".equals(fieldName)) { + deserializedStorageDataCollaborationPolicyProperties.allowCrossTenantDataSharing + = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + + return deserializedStorageDataCollaborationPolicyProperties; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/UserAssignedIdentity.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/UserAssignedIdentity.java new file mode 100644 index 0000000000000..cb8d10cc2065a --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/UserAssignedIdentity.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * UserAssignedIdentity for the resource. + */ +@Immutable +public final class UserAssignedIdentity implements JsonSerializable { + /* + * The principal ID of the identity. + */ + private String principalId; + + /* + * The client ID of the identity. + */ + private String clientId; + + /** + * Creates an instance of UserAssignedIdentity class. + */ + public UserAssignedIdentity() { + } + + /** + * Get the principalId property: The principal ID of the identity. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the clientId property: The client ID of the identity. + * + * @return the clientId value. + */ + public String clientId() { + return this.clientId; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UserAssignedIdentity from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UserAssignedIdentity if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the UserAssignedIdentity. + */ + public static UserAssignedIdentity fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UserAssignedIdentity deserializedUserAssignedIdentity = new UserAssignedIdentity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("principalId".equals(fieldName)) { + deserializedUserAssignedIdentity.principalId = reader.getString(); + } else if ("clientId".equals(fieldName)) { + deserializedUserAssignedIdentity.clientId = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedUserAssignedIdentity; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/VirtualNetworkRule.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/VirtualNetworkRule.java new file mode 100644 index 0000000000000..cd825e87f49dd --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/VirtualNetworkRule.java @@ -0,0 +1,162 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Virtual Network rule. + */ +@Fluent +public final class VirtualNetworkRule implements JsonSerializable { + /* + * Resource ID of a subnet, for example: + * /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName} + * /subnets/{subnetName}. + */ + private String virtualNetworkResourceId; + + /* + * The action of virtual network rule. + */ + private Action action; + + /* + * Gets the state of virtual network rule. + */ + private State state; + + /** + * Creates an instance of VirtualNetworkRule class. + */ + public VirtualNetworkRule() { + } + + /** + * Get the virtualNetworkResourceId property: Resource ID of a subnet, for example: + * /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + * + * @return the virtualNetworkResourceId value. + */ + public String virtualNetworkResourceId() { + return this.virtualNetworkResourceId; + } + + /** + * Set the virtualNetworkResourceId property: Resource ID of a subnet, for example: + * /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + * + * @param virtualNetworkResourceId the virtualNetworkResourceId value to set. + * @return the VirtualNetworkRule object itself. + */ + public VirtualNetworkRule withVirtualNetworkResourceId(String virtualNetworkResourceId) { + this.virtualNetworkResourceId = virtualNetworkResourceId; + return this; + } + + /** + * Get the action property: The action of virtual network rule. + * + * @return the action value. + */ + public Action action() { + return this.action; + } + + /** + * Set the action property: The action of virtual network rule. + * + * @param action the action value to set. + * @return the VirtualNetworkRule object itself. + */ + public VirtualNetworkRule withAction(Action action) { + this.action = action; + return this; + } + + /** + * Get the state property: Gets the state of virtual network rule. + * + * @return the state value. + */ + public State state() { + return this.state; + } + + /** + * Set the state property: Gets the state of virtual network rule. + * + * @param state the state value to set. + * @return the VirtualNetworkRule object itself. + */ + public VirtualNetworkRule withState(State state) { + this.state = state; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (virtualNetworkResourceId() == null) { + throw LOGGER.atError() + .log(new IllegalArgumentException( + "Missing required property virtualNetworkResourceId in model VirtualNetworkRule")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(VirtualNetworkRule.class); + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.virtualNetworkResourceId); + jsonWriter.writeStringField("action", this.action == null ? null : this.action.toString()); + jsonWriter.writeStringField("state", this.state == null ? null : this.state.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VirtualNetworkRule from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VirtualNetworkRule if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the VirtualNetworkRule. + */ + public static VirtualNetworkRule fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + VirtualNetworkRule deserializedVirtualNetworkRule = new VirtualNetworkRule(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedVirtualNetworkRule.virtualNetworkResourceId = reader.getString(); + } else if ("action".equals(fieldName)) { + deserializedVirtualNetworkRule.action = Action.fromString(reader.getString()); + } else if ("state".equals(fieldName)) { + deserializedVirtualNetworkRule.state = State.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedVirtualNetworkRule; + }); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ZonePlacementPolicy.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ZonePlacementPolicy.java new file mode 100644 index 0000000000000..9978beaeaeaba --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/ZonePlacementPolicy.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.storage.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The availability zone pinning policy for the storage account. + */ +public final class ZonePlacementPolicy extends ExpandableStringEnum { + /** + * Static value Any for ZonePlacementPolicy. + */ + public static final ZonePlacementPolicy ANY = fromString("Any"); + + /** + * Static value None for ZonePlacementPolicy. + */ + public static final ZonePlacementPolicy NONE = fromString("None"); + + /** + * Creates a new instance of ZonePlacementPolicy value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ZonePlacementPolicy() { + } + + /** + * Creates or finds a ZonePlacementPolicy from its string representation. + * + * @param name a name to look for. + * @return the corresponding ZonePlacementPolicy. + */ + public static ZonePlacementPolicy fromString(String name) { + return fromString(name, ZonePlacementPolicy.class); + } + + /** + * Gets known ZonePlacementPolicy values. + * + * @return known ZonePlacementPolicy values. + */ + public static Collection values() { + return values(ZonePlacementPolicy.class); + } +} diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/package-info.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/package-info.java new file mode 100644 index 0000000000000..f1426232cb548 --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for Storage. + * The Azure Storage Management API. + */ +package com.azure.resourcemanager.storage.models; diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/package-info.java b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/package-info.java new file mode 100644 index 0000000000000..c6f89fc26374b --- /dev/null +++ b/sdk/core/azure-core-management/src/test/java/com/azure/resourcemanager/storage/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Storage. + * The Azure Storage Management API. + */ +package com.azure.resourcemanager.storage; diff --git a/sdk/core/azure-core/CHANGELOG.md b/sdk/core/azure-core/CHANGELOG.md index c147c389a65f5..499d1191c46b0 100644 --- a/sdk/core/azure-core/CHANGELOG.md +++ b/sdk/core/azure-core/CHANGELOG.md @@ -4,6 +4,8 @@ ### Features Added +- Added `HttpLoggingPolicy.BODY_LOGGING_DISABLED_CONTEXT` to suppress request and response body logging for sensitive + pipeline calls. - Added `HttpProtocolVersion` for configuring the maximum HTTP protocol version in HTTP client builders. - Added `HttpClientOptions.getMaximumHttpVersion` and `setMaximumHttpVersion` for transport-independent HTTP protocol configuration. An unset or cleared maximum preserves the selected transport's existing default. diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/HttpLoggingPolicy.java b/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/HttpLoggingPolicy.java index 6a4e3f172c514..1db47002d5c76 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/HttpLoggingPolicy.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/HttpLoggingPolicy.java @@ -111,6 +111,14 @@ public class HttpLoggingPolicy implements HttpPipelinePolicy { */ public static final String RETRY_COUNT_CONTEXT = "requestRetryCount"; + /** + * Key for {@link Context} to disable request and response body logging for an HTTP pipeline call. + *

+ * The body is not logged when this context value is {@code true}. Custom request and response loggers should also + * honor this value when handling sensitive bodies. + */ + public static final String BODY_LOGGING_DISABLED_CONTEXT = "azure-http-body-logging-disabled"; + private static final String REQUEST_LOG_MESSAGE = "HTTP request"; private static final String RESPONSE_LOG_MESSAGE = "HTTP response"; @@ -270,7 +278,9 @@ private void log(LogLevel logLevel, ClientLogger logger, HttpRequestLoggingConte String contentType = request.getHeaders().getValue(HttpHeaderName.CONTENT_TYPE); - if (httpLogDetailLevel.shouldLogBody() && shouldBodyBeLogged(contentType, contentLength)) { + if (httpLogDetailLevel.shouldLogBody() + && !isBodyLoggingDisabled(loggingOptions.getContext()) + && shouldBodyBeLogged(contentType, contentLength)) { // shouldBodyBeLogged ensures contentLength is not null and within limits. int contentLengthInt = contentLength.intValue(); @@ -336,7 +346,7 @@ public Mono logResponse(ClientLogger logger, HttpResponseLoggingCo Long contentLength = getAndLogContentLength(response.getHeaders(), logBuilder, logger); Mono responseMono = Mono.just(response); - if (httpLogDetailLevel.shouldLogBody()) { + if (httpLogDetailLevel.shouldLogBody() && !isBodyLoggingDisabled(loggingOptions.getContext())) { String contentTypeHeader = response.getHeaderValue(HttpHeaderName.CONTENT_TYPE); if (shouldBodyBeLogged(contentTypeHeader, contentLength)) { @@ -387,7 +397,7 @@ public HttpResponse logResponseSync(ClientLogger logger, HttpResponseLoggingCont Long contentLength = getAndLogContentLength(response.getHeaders(), logBuilder, logger); - if (httpLogDetailLevel.shouldLogBody()) { + if (httpLogDetailLevel.shouldLogBody() && !isBodyLoggingDisabled(loggingOptions.getContext())) { String contentTypeHeader = response.getHeaderValue(HttpHeaderName.CONTENT_TYPE); if (shouldBodyBeLogged(contentTypeHeader, contentLength)) { @@ -524,6 +534,10 @@ private static boolean shouldBodyBeLogged(String contentTypeHeader, Long content && contentLength < MAX_BODY_LOG_SIZE; } + private static boolean isBodyLoggingDisabled(Context context) { + return Boolean.TRUE.equals(context.getData(BODY_LOGGING_DISABLED_CONTEXT).orElse(false)); + } + /* * Gets the request retry count to include in logging. * diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/http/policy/HttpLoggingPolicyTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/http/policy/HttpLoggingPolicyTests.java index cdad461025c53..53a326c3c4c88 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/http/policy/HttpLoggingPolicyTests.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/http/policy/HttpLoggingPolicyTests.java @@ -26,9 +26,9 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.parallel.Execution; import org.junit.jupiter.api.parallel.ExecutionMode; -import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -272,6 +272,54 @@ public void validateLoggingDoesNotConsumeResponseSync(BinaryData responseBody, b assertTrue(logString.contains(new String(data, StandardCharsets.UTF_8))); } + @Test + public void bodyLoggingCanBeDisabledForAsyncCall() { + String requestBody = "sensitive-request"; + String responseBody = "sensitive-response"; + HttpHeaders responseHeaders = new HttpHeaders().set(HttpHeaderName.CONTENT_TYPE, ContentType.APPLICATION_JSON) + .set(HttpHeaderName.CONTENT_LENGTH, Integer.toString(responseBody.length())); + HttpPipeline pipeline = new HttpPipelineBuilder() + .policies(new HttpLoggingPolicy(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY))) + .httpClient(request -> Mono + .just(new MockHttpResponse(request, responseHeaders, BinaryData.fromString(responseBody)))) + .build(); + HttpRequest request = new HttpRequest(HttpMethod.POST, "https://test.com/sensitive") + .setHeader(HttpHeaderName.CONTENT_TYPE, ContentType.APPLICATION_JSON) + .setBody(BinaryData.fromString(requestBody)); + Context context = getCallerMethodContext("bodyLoggingCanBeDisabledForAsyncCall", LogLevel.INFORMATIONAL) + .addData(HttpLoggingPolicy.BODY_LOGGING_DISABLED_CONTEXT, true); + + StepVerifier.create(pipeline.send(request, context)).expectNextCount(1).verifyComplete(); + + String logString = convertOutputStreamToString(logCaptureStream); + assertTrue(!logString.contains(requestBody)); + assertTrue(!logString.contains(responseBody)); + } + + @Test + public void bodyLoggingCanBeDisabledForSyncCall() { + String requestBody = "sensitive-request"; + String responseBody = "sensitive-response"; + HttpHeaders responseHeaders = new HttpHeaders().set(HttpHeaderName.CONTENT_TYPE, ContentType.APPLICATION_JSON) + .set(HttpHeaderName.CONTENT_LENGTH, Integer.toString(responseBody.length())); + HttpPipeline pipeline = new HttpPipelineBuilder() + .policies(new HttpLoggingPolicy(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY))) + .httpClient(request -> Mono + .just(new MockHttpResponse(request, responseHeaders, BinaryData.fromString(responseBody)))) + .build(); + HttpRequest request = new HttpRequest(HttpMethod.POST, "https://test.com/sensitive") + .setHeader(HttpHeaderName.CONTENT_TYPE, ContentType.APPLICATION_JSON) + .setBody(BinaryData.fromString(requestBody)); + Context context = getCallerMethodContext("bodyLoggingCanBeDisabledForSyncCall", LogLevel.INFORMATIONAL) + .addData(HttpLoggingPolicy.BODY_LOGGING_DISABLED_CONTEXT, true); + + pipeline.sendSync(request, context).close(); + + String logString = convertOutputStreamToString(logCaptureStream); + assertTrue(!logString.contains(requestBody)); + assertTrue(!logString.contains(responseBody)); + } + @ParameterizedTest(name = "[{index}] {displayName}") @MethodSource("responseLoggingSupplier") public void responseLoggingUsesActualContentType(String contentType, int expectedBufferCount,