From db4da6b0ad5a6ae878d3c61498dd5a349503cf15 Mon Sep 17 00:00:00 2001 From: Charandeep Parisineti Date: Sun, 5 Nov 2023 09:32:17 -0800 Subject: [PATCH 01/12] Fix externalmodes RouerValue Duration --- .../JobRouterAdministrationAsyncClient.java | 3 +- .../JobRouterAdministrationClient.java | 3 +- .../ClassificationPolicyAdapter.java | 10 +- .../converters/ExceptionPolicyAdapter.java | 68 ++++++++++- .../converters/LabelSelectorAdapter.java | 10 +- .../converters/RouterRuleAdapter.java | 54 +++++++++ .../models/ClassificationPolicyInternal.java | 8 +- ...tionalQueueSelectorAttachmentInternal.java | 6 +- ...ionalWorkerSelectorAttachmentInternal.java | 6 +- .../models/DirectMapRouterRuleInternal.java | 20 ++++ .../models/ExceptionPolicyInternal.java | 112 ++++++++++++++++++ .../models/ExceptionRuleInternal.java | 8 +- .../models/ExceptionTriggerInternal.java | 29 +++++ .../models/ExpressionRouterRuleInternal.java | 77 ++++++++++++ .../models/FunctionRouterRuleInternal.java | 76 ++++++++++++ .../QueueLengthExceptionTriggerInternal.java | 46 +++++++ .../models/RouterRuleInternal.java | 37 ++++++ ...EngineQueueSelectorAttachmentInternal.java | 6 +- ...ngineWorkerSelectorAttachmentInternal.java | 6 +- .../models/StaticRouterRuleInternal.java | 50 ++++++++ .../WaitTimeExceptionTriggerInternal.java | 46 +++++++ .../models/WebhookRouterRuleInternal.java | 112 ++++++++++++++++++ .../jobrouter/models/StaticRouterRule.java | 6 +- .../models/WaitTimeExceptionTrigger.java | 14 ++- .../src/main/java/module-info.java | 5 +- .../ExceptionPolicyExample.java | 3 +- 26 files changed, 777 insertions(+), 44 deletions(-) create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/RouterRuleAdapter.java create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/DirectMapRouterRuleInternal.java create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ExceptionPolicyInternal.java create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ExceptionTriggerInternal.java create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ExpressionRouterRuleInternal.java create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/FunctionRouterRuleInternal.java create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/QueueLengthExceptionTriggerInternal.java create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RouterRuleInternal.java create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/StaticRouterRuleInternal.java create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/WaitTimeExceptionTriggerInternal.java create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/WebhookRouterRuleInternal.java diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterAdministrationAsyncClient.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterAdministrationAsyncClient.java index 1ef2ce0646cfc..004461ab4c76d 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterAdministrationAsyncClient.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterAdministrationAsyncClient.java @@ -10,6 +10,7 @@ import com.azure.communication.jobrouter.implementation.converters.QueueAdapter; import com.azure.communication.jobrouter.implementation.models.ClassificationPolicyInternal; import com.azure.communication.jobrouter.implementation.models.DistributionPolicyInternal; +import com.azure.communication.jobrouter.implementation.models.ExceptionPolicyInternal; import com.azure.communication.jobrouter.implementation.models.RouterQueueInternal; import com.azure.communication.jobrouter.models.ClassificationPolicy; import com.azure.communication.jobrouter.models.CreateClassificationPolicyOptions; @@ -741,7 +742,7 @@ public Mono> updateExceptionPolicyWithResponse( @ServiceMethod(returns = ReturnType.SINGLE) public Mono> createExceptionPolicyWithResponse( CreateExceptionPolicyOptions createExceptionPolicyOptions, RequestOptions requestOptions) { - ExceptionPolicy exceptionPolicy = + ExceptionPolicyInternal exceptionPolicy = ExceptionPolicyAdapter.convertCreateOptionsToExceptionPolicy(createExceptionPolicyOptions); return upsertExceptionPolicyWithResponse( createExceptionPolicyOptions.getExceptionPolicyId(), diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterAdministrationClient.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterAdministrationClient.java index 99e86b47994bc..b0e7d522a0ae6 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterAdministrationClient.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterAdministrationClient.java @@ -10,6 +10,7 @@ import com.azure.communication.jobrouter.implementation.converters.QueueAdapter; import com.azure.communication.jobrouter.implementation.models.ClassificationPolicyInternal; import com.azure.communication.jobrouter.implementation.models.DistributionPolicyInternal; +import com.azure.communication.jobrouter.implementation.models.ExceptionPolicyInternal; import com.azure.communication.jobrouter.implementation.models.RouterQueueInternal; import com.azure.communication.jobrouter.models.ClassificationPolicy; import com.azure.communication.jobrouter.models.CreateClassificationPolicyOptions; @@ -742,7 +743,7 @@ public Response updateExceptionPolicyWithResponse( @ServiceMethod(returns = ReturnType.SINGLE) public Response createExceptionPolicyWithResponse( CreateExceptionPolicyOptions createExceptionPolicyOptions, RequestOptions requestOptions) { - ExceptionPolicy exceptionPolicy = + ExceptionPolicyInternal exceptionPolicy = ExceptionPolicyAdapter.convertCreateOptionsToExceptionPolicy(createExceptionPolicyOptions); return this.serviceClient.upsertExceptionPolicyWithResponse( createExceptionPolicyOptions.getExceptionPolicyId(), diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/ClassificationPolicyAdapter.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/ClassificationPolicyAdapter.java index 9ace1dbcf4d00..c1db8f9546460 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/ClassificationPolicyAdapter.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/ClassificationPolicyAdapter.java @@ -4,11 +4,14 @@ package com.azure.communication.jobrouter.implementation.converters; import com.azure.communication.jobrouter.implementation.models.ClassificationPolicyInternal; +import com.azure.communication.jobrouter.implementation.models.RouterRuleInternal; import com.azure.communication.jobrouter.models.ClassificationPolicy; import com.azure.communication.jobrouter.models.CreateClassificationPolicyOptions; import java.util.stream.Collectors; +import static com.azure.communication.jobrouter.implementation.converters.RouterRuleAdapter.getRouterRuleInternal; + /** * Converts request options for create and update Classification Policy to {@link ClassificationPolicy}. */ @@ -20,9 +23,11 @@ public class ClassificationPolicyAdapter { * @return classification policy. */ public static ClassificationPolicyInternal convertCreateOptionsToClassificationPolicyInternal(CreateClassificationPolicyOptions options) { + RouterRuleInternal prioritizationRuleInternal = getRouterRuleInternal(options.getPrioritizationRule()); + return new ClassificationPolicyInternal() .setName(options.getName()) - .setPrioritizationRule(options.getPrioritizationRule()) + .setPrioritizationRule(prioritizationRuleInternal) .setFallbackQueueId(options.getFallbackQueueId()) .setQueueSelectorAttachments(options.getQueueSelectors().stream() .map(LabelSelectorAdapter::convertQueueSelectorAttachmentToInternal).collect(Collectors.toList())) @@ -30,7 +35,6 @@ public static ClassificationPolicyInternal convertCreateOptionsToClassificationP .map(LabelSelectorAdapter::convertWorkerSelectorAttachmentToInternal).collect(Collectors.toList())); } - public static ClassificationPolicyInternal convertClassificationPolicyToClassificationPolicyInternal(ClassificationPolicy classificationPolicy) { return new ClassificationPolicyInternal() .setEtag(classificationPolicy.getEtag()) @@ -41,6 +45,6 @@ public static ClassificationPolicyInternal convertClassificationPolicyToClassifi .setQueueSelectorAttachments(classificationPolicy.getQueueSelectorAttachments().stream() .map(LabelSelectorAdapter::convertQueueSelectorAttachmentToInternal).collect(Collectors.toList())) .setFallbackQueueId(classificationPolicy.getFallbackQueueId()) - .setPrioritizationRule(classificationPolicy.getPrioritizationRule()); + .setPrioritizationRule(getRouterRuleInternal(classificationPolicy.getPrioritizationRule())); } } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/ExceptionPolicyAdapter.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/ExceptionPolicyAdapter.java index e3c0572f1009b..92aff7cd228e4 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/ExceptionPolicyAdapter.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/ExceptionPolicyAdapter.java @@ -3,8 +3,26 @@ package com.azure.communication.jobrouter.implementation.converters; +import com.azure.communication.jobrouter.implementation.models.CancelExceptionActionInternal; +import com.azure.communication.jobrouter.implementation.models.ExceptionActionInternal; +import com.azure.communication.jobrouter.implementation.models.ExceptionPolicyInternal; +import com.azure.communication.jobrouter.implementation.models.ExceptionRuleInternal; +import com.azure.communication.jobrouter.implementation.models.ExceptionTriggerInternal; +import com.azure.communication.jobrouter.implementation.models.ManualReclassifyExceptionActionInternal; +import com.azure.communication.jobrouter.implementation.models.QueueLengthExceptionTriggerInternal; +import com.azure.communication.jobrouter.implementation.models.WaitTimeExceptionTriggerInternal; +import com.azure.communication.jobrouter.models.CancelExceptionAction; import com.azure.communication.jobrouter.models.CreateExceptionPolicyOptions; +import com.azure.communication.jobrouter.models.ExceptionAction; import com.azure.communication.jobrouter.models.ExceptionPolicy; +import com.azure.communication.jobrouter.models.ExceptionRule; +import com.azure.communication.jobrouter.models.ExceptionTrigger; +import com.azure.communication.jobrouter.models.ManualReclassifyExceptionAction; +import com.azure.communication.jobrouter.models.QueueLengthExceptionTrigger; +import com.azure.communication.jobrouter.models.WaitTimeExceptionTrigger; + +import java.util.List; +import java.util.stream.Collectors; /** * Converts request options for create and update Exception Policy to {@link ExceptionPolicy}. @@ -15,9 +33,53 @@ public class ExceptionPolicyAdapter { * @param createExceptionPolicyOptions * @return exception policy. */ - public static ExceptionPolicy convertCreateOptionsToExceptionPolicy(CreateExceptionPolicyOptions createExceptionPolicyOptions) { - return new ExceptionPolicy() + public static ExceptionPolicyInternal convertCreateOptionsToExceptionPolicy(CreateExceptionPolicyOptions createExceptionPolicyOptions) { + return new ExceptionPolicyInternal() .setName(createExceptionPolicyOptions.getName()) - .setExceptionRules(createExceptionPolicyOptions.getExceptionRules()); + .setExceptionRules(createExceptionPolicyOptions.getExceptionRules() + .stream().map(rule -> convertExceptionRule(rule)) + .collect(Collectors.toList())); + } + + private static ExceptionTriggerInternal convertExceptionTrigger(ExceptionTrigger exceptionTrigger) { + ExceptionTriggerInternal exceptionTriggerInternal = null; + if (exceptionTrigger.getClass() == QueueLengthExceptionTrigger.class) { + QueueLengthExceptionTrigger queueLengthExceptionTrigger = (QueueLengthExceptionTrigger) exceptionTrigger; + exceptionTriggerInternal = new QueueLengthExceptionTriggerInternal(queueLengthExceptionTrigger.getThreshold()); + } else if (exceptionTrigger.getClass() == WaitTimeExceptionTrigger.class) { + WaitTimeExceptionTrigger waitTimeExceptionTrigger = (WaitTimeExceptionTrigger) exceptionTrigger; + exceptionTriggerInternal = new WaitTimeExceptionTriggerInternal(waitTimeExceptionTrigger.getThreshold().getSeconds()); + } + return exceptionTriggerInternal; + } + + private static ExceptionActionInternal convertExceptionAction(ExceptionAction exceptionAction) { + ExceptionActionInternal exceptionActionInternal = null; + if (exceptionAction.getClass() == CancelExceptionAction.class) { + CancelExceptionAction cancelExceptionAction = (CancelExceptionAction) exceptionAction; + exceptionActionInternal = new CancelExceptionActionInternal() + .setNote(cancelExceptionAction.getNote()) + .setDispositionCode(cancelExceptionAction.getDispositionCode()); + } else if (exceptionAction.getClass() == ManualReclassifyExceptionAction.class) { + ManualReclassifyExceptionAction manualReclassifyExceptionAction = (ManualReclassifyExceptionAction) exceptionAction; + exceptionActionInternal = new ManualReclassifyExceptionActionInternal() + .setPriority(manualReclassifyExceptionAction.getPriority()) + .setQueueId(manualReclassifyExceptionAction.getQueueId()) + .setWorkerSelectors(manualReclassifyExceptionAction.getWorkerSelectors() + .stream() + .map(ws -> LabelSelectorAdapter.convertWorkerSelectorToInternal(ws)) + .collect(Collectors.toList())); + } + return exceptionActionInternal; + } + + private static ExceptionRuleInternal convertExceptionRule(ExceptionRule exceptionRule) { + String id = exceptionRule.getId(); + ExceptionTriggerInternal exceptionTriggerInternal = convertExceptionTrigger(exceptionRule.getTrigger()); + List exceptionActionInternalList = exceptionRule.getActions() + .stream() + .map(action -> convertExceptionAction(action)) + .collect(Collectors.toList()); + return new ExceptionRuleInternal(id, exceptionTriggerInternal, exceptionActionInternalList); } } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/LabelSelectorAdapter.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/LabelSelectorAdapter.java index 0ed43d9dbde3c..40a8de4d7815f 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/LabelSelectorAdapter.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/LabelSelectorAdapter.java @@ -36,6 +36,8 @@ import java.util.stream.Collectors; +import static com.azure.communication.jobrouter.implementation.converters.RouterRuleAdapter.getRouterRuleInternal; + /** * Converts queue and worker selectors to * {@link com.azure.communication.jobrouter.implementation.models.RouterQueueSelectorInternal} and @@ -72,7 +74,7 @@ public static QueueSelectorAttachmentInternal convertQueueSelectorAttachmentToIn LabelSelectorAdapter.convertQueueSelectorToInternal(staticAttach.getQueueSelector())); } else if (attachment instanceof ConditionalQueueSelectorAttachment) { ConditionalQueueSelectorAttachment conditional = (ConditionalQueueSelectorAttachment) attachment; - return new ConditionalQueueSelectorAttachmentInternal(conditional.getCondition(), + return new ConditionalQueueSelectorAttachmentInternal(getRouterRuleInternal(conditional.getCondition()), conditional.getQueueSelectors().stream() .map(LabelSelectorAdapter::convertQueueSelectorToInternal).collect(Collectors.toList())); } else if (attachment instanceof PassThroughQueueSelectorAttachment) { @@ -81,7 +83,7 @@ public static QueueSelectorAttachmentInternal convertQueueSelectorAttachmentToIn passThrough.getLabelOperator()); } else if (attachment instanceof RuleEngineQueueSelectorAttachment) { RuleEngineQueueSelectorAttachment rule = (RuleEngineQueueSelectorAttachment) attachment; - return new RuleEngineQueueSelectorAttachmentInternal(rule.getRule()); + return new RuleEngineQueueSelectorAttachmentInternal(getRouterRuleInternal(rule.getRule())); } else if (attachment instanceof WeightedAllocationQueueSelectorAttachment) { WeightedAllocationQueueSelectorAttachment weighted = (WeightedAllocationQueueSelectorAttachment) attachment; return new WeightedAllocationQueueSelectorAttachmentInternal( @@ -104,7 +106,7 @@ public static WorkerSelectorAttachmentInternal convertWorkerSelectorAttachmentTo } else if (attachment instanceof ConditionalWorkerSelectorAttachment) { ConditionalWorkerSelectorAttachment conditional = (ConditionalWorkerSelectorAttachment) attachment; return new ConditionalWorkerSelectorAttachmentInternal( - conditional.getCondition(), + getRouterRuleInternal(conditional.getCondition()), conditional.getWorkerSelectors().stream() .map(LabelSelectorAdapter::convertWorkerSelectorToInternal).collect(Collectors.toList())); } else if (attachment instanceof PassThroughWorkerSelectorAttachment) { @@ -116,7 +118,7 @@ public static WorkerSelectorAttachmentInternal convertWorkerSelectorAttachmentTo .setExpiresAfterSeconds((double) passThrough.getExpiresAfter().getSeconds()); } else if (attachment instanceof RuleEngineWorkerSelectorAttachment) { RuleEngineWorkerSelectorAttachment rule = (RuleEngineWorkerSelectorAttachment) attachment; - return new RuleEngineWorkerSelectorAttachmentInternal(rule.getRule()); + return new RuleEngineWorkerSelectorAttachmentInternal(getRouterRuleInternal(rule.getRule())); } else if (attachment instanceof WeightedAllocationWorkerSelectorAttachment) { WeightedAllocationWorkerSelectorAttachment weighted = (WeightedAllocationWorkerSelectorAttachment) attachment; return new WeightedAllocationWorkerSelectorAttachmentInternal( diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/RouterRuleAdapter.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/RouterRuleAdapter.java new file mode 100644 index 0000000000000..23b5b3615af19 --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/RouterRuleAdapter.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.communication.jobrouter.implementation.converters; + +import com.azure.communication.jobrouter.implementation.models.DirectMapRouterRuleInternal; +import com.azure.communication.jobrouter.implementation.models.ExpressionRouterRuleInternal; +import com.azure.communication.jobrouter.implementation.models.FunctionRouterRuleInternal; +import com.azure.communication.jobrouter.implementation.models.RouterRuleInternal; +import com.azure.communication.jobrouter.implementation.models.StaticRouterRuleInternal; +import com.azure.communication.jobrouter.implementation.models.WebhookRouterRuleInternal; +import com.azure.communication.jobrouter.models.DirectMapRouterRule; +import com.azure.communication.jobrouter.models.ExpressionRouterRule; +import com.azure.communication.jobrouter.models.FunctionRouterRule; +import com.azure.communication.jobrouter.models.RouterRule; +import com.azure.communication.jobrouter.models.StaticRouterRule; +import com.azure.communication.jobrouter.models.WebhookRouterRule; + +/** + * RouterRuleAdapter. + */ +public class RouterRuleAdapter { + /** + * Converts routerRule from external to internal. + * @param routerRule external RouterRule. + * @return internal RouterRule. + */ + public static RouterRuleInternal getRouterRuleInternal(RouterRule routerRule) { + RouterRuleInternal prioritizationRuleInternal = null; + if (routerRule.getClass() == ExpressionRouterRule.class) { + ExpressionRouterRule expressionRouterRule = (ExpressionRouterRule) routerRule; + prioritizationRuleInternal = new ExpressionRouterRuleInternal(expressionRouterRule.getExpression()) + .setLanguage(expressionRouterRule.getLanguage()); + } else if (routerRule.getClass() == DirectMapRouterRule.class) { + DirectMapRouterRule directMapRouterRule = (DirectMapRouterRule) routerRule; + prioritizationRuleInternal = new DirectMapRouterRuleInternal(); + } else if (routerRule.getClass() == FunctionRouterRule.class) { + FunctionRouterRule functionRouterRule = (FunctionRouterRule) routerRule; + prioritizationRuleInternal = new FunctionRouterRuleInternal(functionRouterRule.getFunctionUri()) + .setCredential(functionRouterRule.getCredential()); + } else if (routerRule.getClass() == StaticRouterRule.class) { + StaticRouterRule staticRouterRule = (StaticRouterRule) routerRule; + prioritizationRuleInternal = new StaticRouterRuleInternal() + .setValue(RouterValueAdapter.getValue(staticRouterRule.getValue())); + } else if (routerRule.getClass() == WebhookRouterRule.class) { + WebhookRouterRule webhookRouterRule = (WebhookRouterRule) routerRule; + prioritizationRuleInternal = new WebhookRouterRuleInternal() + .setAuthorizationServerUri(webhookRouterRule.getAuthorizationServerUri()) + .setClientCredential(webhookRouterRule.getClientCredential()) + .setWebhookUri(webhookRouterRule.getWebhookUri()); + } + return prioritizationRuleInternal; + } +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ClassificationPolicyInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ClassificationPolicyInternal.java index 41d392b3c318f..6d23b514c2efb 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ClassificationPolicyInternal.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ClassificationPolicyInternal.java @@ -3,10 +3,10 @@ // Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.communication.jobrouter.implementation.models; -import com.azure.communication.jobrouter.models.RouterRule; import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; import com.fasterxml.jackson.annotation.JsonProperty; + import java.util.List; /** A container for the rules that govern how jobs are classified. */ @@ -53,7 +53,7 @@ public final class ClassificationPolicyInternal { */ @Generated @JsonProperty(value = "prioritizationRule") - private RouterRule prioritizationRule; + private RouterRuleInternal prioritizationRule; /* * The worker selector attachments used to attach worker selectors to a given job. @@ -181,7 +181,7 @@ public ClassificationPolicyInternal setQueueSelectorAttachments( * @return the prioritizationRule value. */ @Generated - public RouterRule getPrioritizationRule() { + public RouterRuleInternal getPrioritizationRule() { return this.prioritizationRule; } @@ -192,7 +192,7 @@ public RouterRule getPrioritizationRule() { * @return the ClassificationPolicyInternal object itself. */ @Generated - public ClassificationPolicyInternal setPrioritizationRule(RouterRule prioritizationRule) { + public ClassificationPolicyInternal setPrioritizationRule(RouterRuleInternal prioritizationRule) { this.prioritizationRule = prioritizationRule; return this; } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ConditionalQueueSelectorAttachmentInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ConditionalQueueSelectorAttachmentInternal.java index f832ea4f94034..6b60e94cc6e98 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ConditionalQueueSelectorAttachmentInternal.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ConditionalQueueSelectorAttachmentInternal.java @@ -23,7 +23,7 @@ public final class ConditionalQueueSelectorAttachmentInternal extends QueueSelec */ @Generated @JsonProperty(value = "condition") - private RouterRule condition; + private RouterRuleInternal condition; /* * The queue selectors to attach @@ -41,7 +41,7 @@ public final class ConditionalQueueSelectorAttachmentInternal extends QueueSelec @Generated @JsonCreator public ConditionalQueueSelectorAttachmentInternal( - @JsonProperty(value = "condition") RouterRule condition, + @JsonProperty(value = "condition") RouterRuleInternal condition, @JsonProperty(value = "queueSelectors") List queueSelectors) { this.condition = condition; this.queueSelectors = queueSelectors; @@ -53,7 +53,7 @@ public ConditionalQueueSelectorAttachmentInternal( * @return the condition value. */ @Generated - public RouterRule getCondition() { + public RouterRuleInternal getCondition() { return this.condition; } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ConditionalWorkerSelectorAttachmentInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ConditionalWorkerSelectorAttachmentInternal.java index 410d6f8ba5a70..aa0a823059c43 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ConditionalWorkerSelectorAttachmentInternal.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ConditionalWorkerSelectorAttachmentInternal.java @@ -23,7 +23,7 @@ public final class ConditionalWorkerSelectorAttachmentInternal extends WorkerSel */ @Generated @JsonProperty(value = "condition") - private RouterRule condition; + private RouterRuleInternal condition; /* * The worker selectors to attach @@ -41,7 +41,7 @@ public final class ConditionalWorkerSelectorAttachmentInternal extends WorkerSel @Generated @JsonCreator public ConditionalWorkerSelectorAttachmentInternal( - @JsonProperty(value = "condition") RouterRule condition, + @JsonProperty(value = "condition") RouterRuleInternal condition, @JsonProperty(value = "workerSelectors") List workerSelectors) { this.condition = condition; this.workerSelectors = workerSelectors; @@ -53,7 +53,7 @@ public ConditionalWorkerSelectorAttachmentInternal( * @return the condition value. */ @Generated - public RouterRule getCondition() { + public RouterRuleInternal getCondition() { return this.condition; } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/DirectMapRouterRuleInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/DirectMapRouterRuleInternal.java new file mode 100644 index 0000000000000..63dd20c01b046 --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/DirectMapRouterRuleInternal.java @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.communication.jobrouter.implementation.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** A rule that return the same labels as the input labels. */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind") +@JsonTypeName("direct-map-rule") +@Immutable +public final class DirectMapRouterRuleInternal extends RouterRuleInternal { + + /** Creates an instance of DirectMapRouterRule class. */ + @Generated + public DirectMapRouterRuleInternal() {} +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ExceptionPolicyInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ExceptionPolicyInternal.java new file mode 100644 index 0000000000000..8dc98f9a66521 --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ExceptionPolicyInternal.java @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.communication.jobrouter.implementation.models; + +import com.azure.communication.jobrouter.models.ExceptionRule; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +/** A policy that defines actions to execute when exception are triggered. */ +@Fluent +public final class ExceptionPolicyInternal { + + /* + * The Id of the exception policy + */ + @Generated + @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /* + * The name of the exception policy. + */ + @Generated + @JsonProperty(value = "name") + private String name; + + /* + * A collection of exception rules on the exception policy. + */ + @Generated + @JsonProperty(value = "exceptionRules") + private List exceptionRules; + + /** Creates an instance of ExceptionPolicy class. */ + @Generated + public ExceptionPolicyInternal() {} + + /** + * Get the id property: The Id of the exception policy. + * + * @return the id value. + */ + @Generated + public String getId() { + return this.id; + } + + /** + * Get the name property: The name of the exception policy. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * Set the name property: The name of the exception policy. + * + * @param name the name value to set. + * @return the ExceptionPolicy object itself. + */ + @Generated + public ExceptionPolicyInternal setName(String name) { + this.name = name; + return this; + } + + /** + * Get the exceptionRules property: A collection of exception rules on the exception policy. + * + * @return the exceptionRules value. + */ + @Generated + public List getExceptionRules() { + return this.exceptionRules; + } + + /* + * The entity tag for this resource. + */ + @Generated + @JsonProperty(value = "etag", access = JsonProperty.Access.WRITE_ONLY) + private String etag; + + /** + * Get the etag property: The entity tag for this resource. + * + * @return the etag value. + */ + @Generated + public String getEtag() { + return this.etag; + } + + /** + * Set the exceptionRules property: A collection of exception rules on the exception policy. + * + * @param exceptionRules the exceptionRules value to set. + * @return the ExceptionPolicy object itself. + */ + @Generated + public ExceptionPolicyInternal setExceptionRules(List exceptionRules) { + this.exceptionRules = exceptionRules; + return this; + } +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ExceptionRuleInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ExceptionRuleInternal.java index b08e56dd6d8a5..0358bf87bd052 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ExceptionRuleInternal.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ExceptionRuleInternal.java @@ -4,11 +4,11 @@ package com.azure.communication.jobrouter.implementation.models; -import com.azure.communication.jobrouter.models.ExceptionTrigger; import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; + import java.util.List; /** A rule that defines actions to execute upon a specific trigger. */ @@ -26,7 +26,7 @@ public final class ExceptionRuleInternal { */ @Generated @JsonProperty(value = "trigger") - private ExceptionTrigger trigger; + private ExceptionTriggerInternal trigger; /* * A collection of actions to perform once the exception is triggered. @@ -46,7 +46,7 @@ public final class ExceptionRuleInternal { @JsonCreator public ExceptionRuleInternal( @JsonProperty(value = "id") String id, - @JsonProperty(value = "trigger") ExceptionTrigger trigger, + @JsonProperty(value = "trigger") ExceptionTriggerInternal trigger, @JsonProperty(value = "actions") List actions) { this.id = id; this.trigger = trigger; @@ -69,7 +69,7 @@ public String getId() { * @return the trigger value. */ @Generated - public ExceptionTrigger getTrigger() { + public ExceptionTriggerInternal getTrigger() { return this.trigger; } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ExceptionTriggerInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ExceptionTriggerInternal.java new file mode 100644 index 0000000000000..7e03060fd050f --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ExceptionTriggerInternal.java @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.communication.jobrouter.implementation.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** The trigger for this exception rule. */ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.PROPERTY, + property = "kind", + defaultImpl = ExceptionTriggerInternal.class) +@JsonTypeName("ExceptionTrigger") +@JsonSubTypes({ + @JsonSubTypes.Type(name = "queue-length", value = QueueLengthExceptionTriggerInternal.class), + @JsonSubTypes.Type(name = "wait-time", value = WaitTimeExceptionTriggerInternal.class) +}) +@Immutable +public class ExceptionTriggerInternal { + + /** Creates an instance of ExceptionTrigger class. */ + @Generated + public ExceptionTriggerInternal() {} +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ExpressionRouterRuleInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ExpressionRouterRuleInternal.java new file mode 100644 index 0000000000000..3345b7833905d --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ExpressionRouterRuleInternal.java @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.communication.jobrouter.implementation.models; + +import com.azure.communication.jobrouter.models.ExpressionRouterRuleLanguage; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** A rule providing inline expression rules. */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind") +@JsonTypeName("expression-rule") +@Fluent +public final class ExpressionRouterRuleInternal extends RouterRuleInternal { + + /* + * The expression language to compile to and execute + */ + @Generated + @JsonProperty(value = "language") + private ExpressionRouterRuleLanguage language; + + /* + * The string containing the expression to evaluate. Should contain return statement with calculated values. + */ + @Generated + @JsonProperty(value = "expression") + private String expression; + + /** + * Creates an instance of ExpressionRouterRule class. + * + * @param expression the expression value to set. + */ + @Generated + @JsonCreator + public ExpressionRouterRuleInternal(@JsonProperty(value = "expression") String expression) { + this.expression = expression; + } + + /** + * Get the language property: The expression language to compile to and execute. + * + * @return the language value. + */ + @Generated + public ExpressionRouterRuleLanguage getLanguage() { + return this.language; + } + + /** + * Set the language property: The expression language to compile to and execute. + * + * @param language the language value to set. + * @return the ExpressionRouterRule object itself. + */ + @Generated + public ExpressionRouterRuleInternal setLanguage(ExpressionRouterRuleLanguage language) { + this.language = language; + return this; + } + + /** + * Get the expression property: The string containing the expression to evaluate. Should contain return statement + * with calculated values. + * + * @return the expression value. + */ + @Generated + public String getExpression() { + return this.expression; + } +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/FunctionRouterRuleInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/FunctionRouterRuleInternal.java new file mode 100644 index 0000000000000..07f7ea2c411e1 --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/FunctionRouterRuleInternal.java @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.communication.jobrouter.implementation.models; + +import com.azure.communication.jobrouter.models.FunctionRouterRuleCredential; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** A rule providing a binding to an HTTP Triggered Azure Function. */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind") +@JsonTypeName("azure-function-rule") +@Fluent +public final class FunctionRouterRuleInternal extends RouterRuleInternal { + + /* + * URL for Azure Function + */ + @Generated + @JsonProperty(value = "functionUri") + private String functionUri; + + /* + * Credentials used to access Azure function rule + */ + @Generated + @JsonProperty(value = "credential") + private FunctionRouterRuleCredential credential; + + /** + * Creates an instance of FunctionRouterRule class. + * + * @param functionUri the functionUri value to set. + */ + @Generated + @JsonCreator + public FunctionRouterRuleInternal(@JsonProperty(value = "functionUri") String functionUri) { + this.functionUri = functionUri; + } + + /** + * Get the functionUri property: URL for Azure Function. + * + * @return the functionUri value. + */ + @Generated + public String getFunctionUri() { + return this.functionUri; + } + + /** + * Get the credential property: Credentials used to access Azure function rule. + * + * @return the credential value. + */ + @Generated + public FunctionRouterRuleCredential getCredential() { + return this.credential; + } + + /** + * Set the credential property: Credentials used to access Azure function rule. + * + * @param credential the credential value to set. + * @return the FunctionRouterRule object itself. + */ + @Generated + public FunctionRouterRuleInternal setCredential(FunctionRouterRuleCredential credential) { + this.credential = credential; + return this; + } +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/QueueLengthExceptionTriggerInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/QueueLengthExceptionTriggerInternal.java new file mode 100644 index 0000000000000..9830f56d8b056 --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/QueueLengthExceptionTriggerInternal.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.communication.jobrouter.implementation.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** Trigger for an exception action on exceeding queue length. */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind") +@JsonTypeName("queue-length") +@Immutable +public final class QueueLengthExceptionTriggerInternal extends ExceptionTriggerInternal { + + /* + * Threshold of number of jobs ahead in the queue to for this trigger to fire. + */ + @Generated + @JsonProperty(value = "threshold") + private int threshold; + + /** + * Creates an instance of QueueLengthExceptionTrigger class. + * + * @param threshold the threshold value to set. + */ + @Generated + @JsonCreator + public QueueLengthExceptionTriggerInternal(@JsonProperty(value = "threshold") int threshold) { + this.threshold = threshold; + } + + /** + * Get the threshold property: Threshold of number of jobs ahead in the queue to for this trigger to fire. + * + * @return the threshold value. + */ + @Generated + public int getThreshold() { + return this.threshold; + } +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RouterRuleInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RouterRuleInternal.java new file mode 100644 index 0000000000000..12304d7eb3f0f --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RouterRuleInternal.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.communication.jobrouter.implementation.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * A rule of one of the following types: StaticRule: A rule providing static rules that always return the same result, + * regardless of input. DirectMapRule: A rule that return the same labels as the input labels. ExpressionRule: A rule + * providing inline expression rules. FunctionRule: A rule providing a binding to an HTTP Triggered Azure Function. + * WebhookRule: A rule providing a binding to a webserver following OAuth2.0 authentication protocol. + */ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.PROPERTY, + property = "kind", + defaultImpl = RouterRuleInternal.class) +@JsonTypeName("RouterRule") +@JsonSubTypes({ + @JsonSubTypes.Type(name = "direct-map-rule", value = DirectMapRouterRuleInternal.class), + @JsonSubTypes.Type(name = "expression-rule", value = ExpressionRouterRuleInternal.class), + @JsonSubTypes.Type(name = "azure-function-rule", value = FunctionRouterRuleInternal.class), + @JsonSubTypes.Type(name = "static-rule", value = StaticRouterRuleInternal.class), + @JsonSubTypes.Type(name = "webhook-rule", value = WebhookRouterRuleInternal.class) +}) +@Immutable +public class RouterRuleInternal { + + /** Creates an instance of RouterRule class. */ + @Generated + public RouterRuleInternal() {} +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RuleEngineQueueSelectorAttachmentInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RuleEngineQueueSelectorAttachmentInternal.java index d9d39e13fbd57..5029c773d5f9a 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RuleEngineQueueSelectorAttachmentInternal.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RuleEngineQueueSelectorAttachmentInternal.java @@ -22,7 +22,7 @@ public final class RuleEngineQueueSelectorAttachmentInternal extends QueueSelect */ @Generated @JsonProperty(value = "rule") - private RouterRule rule; + private RouterRuleInternal rule; /** * Creates an instance of RuleEngineQueueSelectorAttachmentInternal class. @@ -31,7 +31,7 @@ public final class RuleEngineQueueSelectorAttachmentInternal extends QueueSelect */ @Generated @JsonCreator - public RuleEngineQueueSelectorAttachmentInternal(@JsonProperty(value = "rule") RouterRule rule) { + public RuleEngineQueueSelectorAttachmentInternal(@JsonProperty(value = "rule") RouterRuleInternal rule) { this.rule = rule; } @@ -41,7 +41,7 @@ public RuleEngineQueueSelectorAttachmentInternal(@JsonProperty(value = "rule") R * @return the rule value. */ @Generated - public RouterRule getRule() { + public RouterRuleInternal getRule() { return this.rule; } } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RuleEngineWorkerSelectorAttachmentInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RuleEngineWorkerSelectorAttachmentInternal.java index 3cbf3e6897461..6f42388906b92 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RuleEngineWorkerSelectorAttachmentInternal.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RuleEngineWorkerSelectorAttachmentInternal.java @@ -22,7 +22,7 @@ public final class RuleEngineWorkerSelectorAttachmentInternal extends WorkerSele */ @Generated @JsonProperty(value = "rule") - private RouterRule rule; + private RouterRuleInternal rule; /** * Creates an instance of RuleEngineWorkerSelectorAttachmentInternal class. @@ -31,7 +31,7 @@ public final class RuleEngineWorkerSelectorAttachmentInternal extends WorkerSele */ @Generated @JsonCreator - public RuleEngineWorkerSelectorAttachmentInternal(@JsonProperty(value = "rule") RouterRule rule) { + public RuleEngineWorkerSelectorAttachmentInternal(@JsonProperty(value = "rule") RouterRuleInternal rule) { this.rule = rule; } @@ -41,7 +41,7 @@ public RuleEngineWorkerSelectorAttachmentInternal(@JsonProperty(value = "rule") * @return the rule value. */ @Generated - public RouterRule getRule() { + public RouterRuleInternal getRule() { return this.rule; } } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/StaticRouterRuleInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/StaticRouterRuleInternal.java new file mode 100644 index 0000000000000..afce594f79ec8 --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/StaticRouterRuleInternal.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.communication.jobrouter.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** A rule providing static rules that always return the same result, regardless of input. */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind") +@JsonTypeName("static-rule") +@Fluent +public final class StaticRouterRuleInternal extends RouterRuleInternal { + + /* + * The static value this rule always returns. + */ + @Generated + @JsonProperty(value = "value") + private Object value; + + /** Creates an instance of StaticRouterRule class. */ + @Generated + public StaticRouterRuleInternal() {} + + /** + * Get the value property: The static value this rule always returns. + * + * @return the value value. + */ + @Generated + public Object getValue() { + return this.value; + } + + /** + * Set the value property: The static value this rule always returns. + * + * @param value the value value to set. + * @return the StaticRouterRule object itself. + */ + @Generated + public StaticRouterRuleInternal setValue(Object value) { + this.value = value; + return this; + } +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/WaitTimeExceptionTriggerInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/WaitTimeExceptionTriggerInternal.java new file mode 100644 index 0000000000000..cb6db4443ccd0 --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/WaitTimeExceptionTriggerInternal.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.communication.jobrouter.implementation.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** Trigger for an exception action on exceeding wait time. */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind") +@JsonTypeName("wait-time") +@Immutable +public final class WaitTimeExceptionTriggerInternal extends ExceptionTriggerInternal { + + /* + * Threshold for wait time for this trigger. + */ + @Generated + @JsonProperty(value = "thresholdSeconds") + private double thresholdSeconds; + + /** + * Creates an instance of WaitTimeExceptionTrigger class. + * + * @param thresholdSeconds the thresholdSeconds value to set. + */ + @Generated + @JsonCreator + public WaitTimeExceptionTriggerInternal(@JsonProperty(value = "thresholdSeconds") double thresholdSeconds) { + this.thresholdSeconds = thresholdSeconds; + } + + /** + * Get the thresholdSeconds property: Threshold for wait time for this trigger. + * + * @return the thresholdSeconds value. + */ + @Generated + public double getThresholdSeconds() { + return this.thresholdSeconds; + } +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/WebhookRouterRuleInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/WebhookRouterRuleInternal.java new file mode 100644 index 0000000000000..b7d01c5e9d450 --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/WebhookRouterRuleInternal.java @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.communication.jobrouter.implementation.models; + +import com.azure.communication.jobrouter.models.OAuth2WebhookClientCredential; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** A rule providing a binding to an external web server. */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind") +@JsonTypeName("webhook-rule") +@Fluent +public final class WebhookRouterRuleInternal extends RouterRuleInternal { + + /* + * Uri for Authorization Server. + */ + @Generated + @JsonProperty(value = "authorizationServerUri") + private String authorizationServerUri; + + /* + * OAuth2.0 Credentials used to Contoso's Authorization server. Reference: + * https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/ + */ + @Generated + @JsonProperty(value = "clientCredential") + private OAuth2WebhookClientCredential clientCredential; + + /* + * Uri for Contoso's Web Server. + */ + @Generated + @JsonProperty(value = "webhookUri") + private String webhookUri; + + /** Creates an instance of WebhookRouterRule class. */ + @Generated + public WebhookRouterRuleInternal() {} + + /** + * Get the authorizationServerUri property: Uri for Authorization Server. + * + * @return the authorizationServerUri value. + */ + @Generated + public String getAuthorizationServerUri() { + return this.authorizationServerUri; + } + + /** + * Set the authorizationServerUri property: Uri for Authorization Server. + * + * @param authorizationServerUri the authorizationServerUri value to set. + * @return the WebhookRouterRule object itself. + */ + @Generated + public WebhookRouterRuleInternal setAuthorizationServerUri(String authorizationServerUri) { + this.authorizationServerUri = authorizationServerUri; + return this; + } + + /** + * Get the clientCredential property: OAuth2.0 Credentials used to Contoso's Authorization server. Reference: + * https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/. + * + * @return the clientCredential value. + */ + @Generated + public OAuth2WebhookClientCredential getClientCredential() { + return this.clientCredential; + } + + /** + * Get the webhookUri property: Uri for Contoso's Web Server. + * + * @return the webhookUri value. + */ + @Generated + public String getWebhookUri() { + return this.webhookUri; + } + + /** + * Set the webhookUri property: Uri for Contoso's Web Server. + * + * @param webhookUri the webhookUri value to set. + * @return the WebhookRouterRule object itself. + */ + @Generated + public WebhookRouterRuleInternal setWebhookUri(String webhookUri) { + this.webhookUri = webhookUri; + return this; + } + + /** + * Set the clientCredential property: OAuth2.0 Credentials used to Contoso's Authorization server. Reference: + * https://www.oauth.com/oauth2-servers/access-tokens/client-credentials/. + * + * @param clientCredential the clientCredential value to set. + * @return the WebhookRouterRule object itself. + */ + @Generated + public WebhookRouterRuleInternal setClientCredential(OAuth2WebhookClientCredential clientCredential) { + this.clientCredential = clientCredential; + return this; + } +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/StaticRouterRule.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/StaticRouterRule.java index 342bf6baab305..4d2fef986ac05 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/StaticRouterRule.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/StaticRouterRule.java @@ -20,7 +20,7 @@ public final class StaticRouterRule extends RouterRule { */ @Generated @JsonProperty(value = "value") - private Object value; + private RouterValue value; /** Creates an instance of StaticRouterRule class. */ @Generated @@ -32,7 +32,7 @@ public StaticRouterRule() {} * @return the value value. */ @Generated - public Object getValue() { + public RouterValue getValue() { return this.value; } @@ -43,7 +43,7 @@ public Object getValue() { * @return the StaticRouterRule object itself. */ @Generated - public StaticRouterRule setValue(Object value) { + public StaticRouterRule setValue(RouterValue value) { this.value = value; return this; } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/WaitTimeExceptionTrigger.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/WaitTimeExceptionTrigger.java index 936e7758523e9..edecf2455886c 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/WaitTimeExceptionTrigger.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/WaitTimeExceptionTrigger.java @@ -10,6 +10,8 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; +import java.time.Duration; + /** Trigger for an exception action on exceeding wait time. */ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind") @JsonTypeName("wait-time") @@ -21,17 +23,17 @@ public final class WaitTimeExceptionTrigger extends ExceptionTrigger { */ @Generated @JsonProperty(value = "thresholdSeconds") - private double thresholdSeconds; + private Duration threshold; /** * Creates an instance of WaitTimeExceptionTrigger class. * - * @param thresholdSeconds the thresholdSeconds value to set. + * @param threshold the thresholdSeconds value to set. */ @Generated @JsonCreator - public WaitTimeExceptionTrigger(@JsonProperty(value = "thresholdSeconds") double thresholdSeconds) { - this.thresholdSeconds = thresholdSeconds; + public WaitTimeExceptionTrigger(@JsonProperty(value = "thresholdSeconds") Duration threshold) { + this.threshold = threshold; } /** @@ -40,7 +42,7 @@ public WaitTimeExceptionTrigger(@JsonProperty(value = "thresholdSeconds") double * @return the thresholdSeconds value. */ @Generated - public double getThresholdSeconds() { - return this.thresholdSeconds; + public Duration getThreshold() { + return this.threshold; } } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/module-info.java b/sdk/communication/azure-communication-jobrouter/src/main/java/module-info.java index 8c83565e0356d..bcef7b0d9ec56 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/module-info.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/module-info.java @@ -12,7 +12,8 @@ opens com.azure.communication.jobrouter.models to com.azure.core, com.fasterxml.jackson.databind, - com.azure.communication.jobrouter.implementation.converters; - exports com.azure.communication.jobrouter.implementation.models; + com.azure.communication.jobrouter.implementation.converters, + com.azure.communication.jobrouter.implementation.models; + opens com.azure.communication.jobrouter.implementation.models to com.azure.communication.jobrouter.implementation.converters, com.azure.core, com.fasterxml.jackson.databind; } diff --git a/sdk/communication/azure-communication-jobrouter/src/samples/java/com.azure.communication.jobrouter/ExceptionPolicyExample.java b/sdk/communication/azure-communication-jobrouter/src/samples/java/com.azure.communication.jobrouter/ExceptionPolicyExample.java index 5165e9052ae5c..e0a2477cae908 100644 --- a/sdk/communication/azure-communication-jobrouter/src/samples/java/com.azure.communication.jobrouter/ExceptionPolicyExample.java +++ b/sdk/communication/azure-communication-jobrouter/src/samples/java/com.azure.communication.jobrouter/ExceptionPolicyExample.java @@ -23,6 +23,7 @@ import com.azure.core.http.rest.RequestOptions; import com.azure.core.util.BinaryData; +import java.time.Duration; import java.util.Arrays; public class ExceptionPolicyExample { @@ -66,7 +67,7 @@ private void createAndUpdateExceptionPolicy() { /** * Add additional exception rule to policy. */ - WaitTimeExceptionTrigger waitTimeExceptionTrigger = new WaitTimeExceptionTrigger(60); + WaitTimeExceptionTrigger waitTimeExceptionTrigger = new WaitTimeExceptionTrigger(Duration.ofSeconds(60)); ExceptionRule waitTimeExceptionRule = new ExceptionRule("wait-time-exception-rule", waitTimeExceptionTrigger, Arrays.asList(exceptionAction)); From 7afb054613e28bf4c690d7501047efb3987f776b Mon Sep 17 00:00:00 2001 From: Charandeep Parisineti Date: Sun, 5 Nov 2023 09:39:24 -0800 Subject: [PATCH 02/12] Remove @Generated --- .../azure/communication/jobrouter/models/StaticRouterRule.java | 3 --- .../jobrouter/models/WaitTimeExceptionTrigger.java | 3 --- 2 files changed, 6 deletions(-) diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/StaticRouterRule.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/StaticRouterRule.java index 4d2fef986ac05..85f4708ea934d 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/StaticRouterRule.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/StaticRouterRule.java @@ -18,7 +18,6 @@ public final class StaticRouterRule extends RouterRule { /* * The static value this rule always returns. */ - @Generated @JsonProperty(value = "value") private RouterValue value; @@ -31,7 +30,6 @@ public StaticRouterRule() {} * * @return the value value. */ - @Generated public RouterValue getValue() { return this.value; } @@ -42,7 +40,6 @@ public RouterValue getValue() { * @param value the value value to set. * @return the StaticRouterRule object itself. */ - @Generated public StaticRouterRule setValue(RouterValue value) { this.value = value; return this; diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/WaitTimeExceptionTrigger.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/WaitTimeExceptionTrigger.java index edecf2455886c..067d605881715 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/WaitTimeExceptionTrigger.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/WaitTimeExceptionTrigger.java @@ -21,7 +21,6 @@ public final class WaitTimeExceptionTrigger extends ExceptionTrigger { /* * Threshold for wait time for this trigger. */ - @Generated @JsonProperty(value = "thresholdSeconds") private Duration threshold; @@ -30,7 +29,6 @@ public final class WaitTimeExceptionTrigger extends ExceptionTrigger { * * @param threshold the thresholdSeconds value to set. */ - @Generated @JsonCreator public WaitTimeExceptionTrigger(@JsonProperty(value = "thresholdSeconds") Duration threshold) { this.threshold = threshold; @@ -41,7 +39,6 @@ public WaitTimeExceptionTrigger(@JsonProperty(value = "thresholdSeconds") Durati * * @return the thresholdSeconds value. */ - @Generated public Duration getThreshold() { return this.threshold; } From e7917765abf552d44c2a7bd08aedda9ac6574d95 Mon Sep 17 00:00:00 2001 From: Charandeep Parisineti Date: Sun, 5 Nov 2023 10:00:49 -0800 Subject: [PATCH 03/12] Remove @Generated annotations --- .../jobrouter/models/PassThroughWorkerSelectorAttachment.java | 2 -- .../communication/jobrouter/models/RouterQueueSelector.java | 3 --- .../communication/jobrouter/models/RouterWorkerSelector.java | 3 --- 3 files changed, 8 deletions(-) diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/PassThroughWorkerSelectorAttachment.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/PassThroughWorkerSelectorAttachment.java index 1f4ed348cb878..cdddeefc55c87 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/PassThroughWorkerSelectorAttachment.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/PassThroughWorkerSelectorAttachment.java @@ -78,7 +78,6 @@ public LabelOperator getLabelOperator() { * * @return the expiresAfter value. */ - @Generated public Duration getExpiresAfter() { return this.expiresAfter; } @@ -89,7 +88,6 @@ public Duration getExpiresAfter() { * @param expiresAfter the expiresAfter value to set. * @return the PassThroughWorkerSelectorAttachment object itself. */ - @Generated public PassThroughWorkerSelectorAttachment setExpiresAfter(Duration expiresAfter) { this.expiresAfter = expiresAfter; return this; diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterQueueSelector.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterQueueSelector.java index 739a6d75e0a44..a0c6fe71bb477 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterQueueSelector.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterQueueSelector.java @@ -30,7 +30,6 @@ public final class RouterQueueSelector { /* * The value to compare against the actual label value with the given operator */ - @Generated @JsonProperty(value = "value") private RouterValue value; @@ -75,7 +74,6 @@ public LabelOperator getLabelOperator() { * * @return the value value. */ - @Generated public RouterValue getValue() { return this.value; } @@ -86,7 +84,6 @@ public RouterValue getValue() { * @param value the value value to set. * @return the RouterQueueSelector object itself. */ - @Generated public RouterQueueSelector setValue(RouterValue value) { this.value = value; return this; diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterWorkerSelector.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterWorkerSelector.java index 9d68c1a102b18..f53281ca33f49 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterWorkerSelector.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterWorkerSelector.java @@ -114,7 +114,6 @@ public RouterValue getValue() { * @param value the value value to set. * @return the RouterWorkerSelector object itself. */ - @Generated public RouterWorkerSelector setValue(RouterValue value) { this.value = value; return this; @@ -125,7 +124,6 @@ public RouterWorkerSelector setValue(RouterValue value) { * * @return the expiresAfter value. */ - @Generated public Duration getExpiresAfter() { return this.expiresAfter; } @@ -136,7 +134,6 @@ public Duration getExpiresAfter() { * @param expiresAfter the expiresAfter value to set. * @return the RouterWorkerSelector object itself. */ - @Generated public RouterWorkerSelector setExpiresAfter(Duration expiresAfter) { this.expiresAfter = expiresAfter; return this; From 4773e1250d9d1fa8ca20d83ec73170c814e5082c Mon Sep 17 00:00:00 2001 From: Charandeep Parisineti Date: Sun, 5 Nov 2023 10:11:36 -0800 Subject: [PATCH 04/12] Remove @Generated --- .../jobrouter/models/ReclassifyExceptionAction.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/ReclassifyExceptionAction.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/ReclassifyExceptionAction.java index ff065a8611df0..40a890eece444 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/ReclassifyExceptionAction.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/ReclassifyExceptionAction.java @@ -28,7 +28,6 @@ public final class ReclassifyExceptionAction extends ExceptionAction { * (optional) Dictionary containing the labels to update (or add if not existing) * in key-value pairs */ - @Generated @JsonProperty(value = "labelsToUpsert") private Map labelsToUpsert; @@ -66,7 +65,6 @@ public ReclassifyExceptionAction setClassificationPolicyId(String classification * * @return the labelsToUpsert value. */ - @Generated public Map getLabelsToUpsert() { return this.labelsToUpsert; } @@ -78,7 +76,6 @@ public Map getLabelsToUpsert() { * @param labelsToUpsert the labelsToUpsert value to set. * @return the ReclassifyExceptionAction object itself. */ - @Generated public ReclassifyExceptionAction setLabelsToUpsert(Map labelsToUpsert) { this.labelsToUpsert = labelsToUpsert; return this; From a0f3dbc1e5ed83fca05c7333aee99b09fce55d0d Mon Sep 17 00:00:00 2001 From: Charandeep Parisineti Date: Sun, 5 Nov 2023 10:13:28 -0800 Subject: [PATCH 05/12] Fix build --- .../ClassificationPolicyLiveTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/ClassificationPolicyLiveTests.java b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/ClassificationPolicyLiveTests.java index 1f75970d6431b..2e06564f109cd 100644 --- a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/ClassificationPolicyLiveTests.java +++ b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/ClassificationPolicyLiveTests.java @@ -75,7 +75,7 @@ public void createClassificationPolicy(HttpClient httpClient) { CreateClassificationPolicyOptions createClassificationPolicyOptions = new CreateClassificationPolicyOptions( classificationPolicyId) .setName(classificationPolicyName) - .setPrioritizationRule(new StaticRouterRule().setValue(1)) + .setPrioritizationRule(new StaticRouterRule().setValue(new RouterValue(1))) .setWorkerSelectors(workerSelectors) .setQueueSelectors(queueSelectors) .setFallbackQueueId(jobQueue.getId()); From 72e991c9675db95e7fc5062a385a9249dd4e16a8 Mon Sep 17 00:00:00 2001 From: Charandeep Parisineti Date: Sun, 5 Nov 2023 10:26:49 -0800 Subject: [PATCH 06/12] Remove @Generated; Fix method to use BinaryData --- .../communication/jobrouter/JobRouterAdministrationClient.java | 3 ++- .../com/azure/communication/jobrouter/models/RouterJob.java | 2 -- .../RouterQueueLiveTests.java | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterAdministrationClient.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterAdministrationClient.java index b0e7d522a0ae6..a3290943c5a3e 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterAdministrationClient.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterAdministrationClient.java @@ -985,7 +985,8 @@ Response upsertQueueWithResponse(String queueId, BinaryData resource */ @ServiceMethod(returns = ReturnType.SINGLE) public Response updateQueueWithResponse( - String id, RouterQueue routerQueue, RequestOptions requestOptions) { + String id, BinaryData resource, RequestOptions requestOptions) { + RouterQueue routerQueue = BinaryData.fromObject(resource).toObject(RouterQueue.class); RouterQueueInternal routerQueueInternal = QueueAdapter.convertRouterQueueToRouterQueueInternal(routerQueue); return this.serviceClient.upsertQueueWithResponse( id, BinaryData.fromObject(routerQueueInternal), requestOptions); diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterJob.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterJob.java index 56ba5b249ba9b..2ed4a34f6f7c1 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterJob.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterJob.java @@ -384,7 +384,6 @@ public Map getAssignments() { * * @return the tags value. */ - @Generated public Map getTags() { return this.tags; } @@ -395,7 +394,6 @@ public Map getTags() { * @param tags the tags value to set. * @return the RouterJob object itself. */ - @Generated public RouterJob setTags(Map tags) { this.tags = tags; return this; diff --git a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterQueueLiveTests.java b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterQueueLiveTests.java index 465d035d5c5f9..47f1745f6321b 100644 --- a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterQueueLiveTests.java +++ b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterQueueLiveTests.java @@ -8,6 +8,7 @@ import com.azure.communication.jobrouter.models.RouterValue; import com.azure.core.http.HttpClient; import com.azure.core.http.rest.RequestOptions; +import com.azure.core.util.BinaryData; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @@ -62,7 +63,7 @@ public void updateQueue(HttpClient httpClient) { }; // Action - queue = routerAdminClient.updateQueueWithResponse(queueId, new RouterQueue().setLabels(updatedQueueLabels), new RequestOptions()) + queue = routerAdminClient.updateQueueWithResponse(queueId, BinaryData.fromObject(new RouterQueue().setLabels(updatedQueueLabels)), new RequestOptions()) .getValue().toObject(RouterQueue.class); // Verify From 853a3a051859d8a3206ce3ecc2f1020ce42802d3 Mon Sep 17 00:00:00 2001 From: Charandeep Parisineti Date: Sun, 5 Nov 2023 12:34:54 -0800 Subject: [PATCH 07/12] Add Proxies --- .../JobRouterAdministrationClient.java | 7 +- .../RouterQueueConstructorProxy.java | 60 +++++++++ .../RouterValueConstructorProxy.java | 59 +++++++++ .../implementation/converters/JobAdapter.java | 15 +-- .../converters/RouterValueAdapter.java | 39 +++--- .../jobrouter/models/RouterQueue.java | 36 ++++++ .../jobrouter/models/RouterValue.java | 117 ++++++++++-------- .../ClassificationPolicyLiveTests.java | 6 +- .../JobRouterTestBase.java | 4 +- .../RouterJobLiveTests.java | 4 +- .../RouterQueueLiveTests.java | 7 +- .../RouterWorkerLiveTests.java | 4 +- 12 files changed, 260 insertions(+), 98 deletions(-) create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/RouterQueueConstructorProxy.java create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/RouterValueConstructorProxy.java diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterAdministrationClient.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterAdministrationClient.java index a3290943c5a3e..4e049029e721b 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterAdministrationClient.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterAdministrationClient.java @@ -4,6 +4,7 @@ package com.azure.communication.jobrouter; import com.azure.communication.jobrouter.implementation.JobRouterAdministrationClientImpl; +import com.azure.communication.jobrouter.implementation.accesshelpers.RouterQueueConstructorProxy; import com.azure.communication.jobrouter.implementation.converters.ClassificationPolicyAdapter; import com.azure.communication.jobrouter.implementation.converters.DistributionPolicyAdapter; import com.azure.communication.jobrouter.implementation.converters.ExceptionPolicyAdapter; @@ -975,7 +976,7 @@ Response upsertQueueWithResponse(String queueId, BinaryData resource * } * * @param id The Id of this queue. - * @param routerQueue The routerQueue instance. + * @param resource RouterQueue resource. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. @@ -1022,7 +1023,9 @@ public Response createQueueWithResponse( @ServiceMethod(returns = ReturnType.SINGLE) public RouterQueue createQueue(CreateQueueOptions createQueueOptions) { RequestOptions requestOptions = new RequestOptions(); - return this.createQueueWithResponse(createQueueOptions, requestOptions).getValue().toObject(RouterQueue.class); + BinaryData resource = this.createQueueWithResponse(createQueueOptions, requestOptions).getValue(); + RouterQueueInternal internal = resource.toObject(RouterQueueInternal.class); + return RouterQueueConstructorProxy.create(internal); } /** diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/RouterQueueConstructorProxy.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/RouterQueueConstructorProxy.java new file mode 100644 index 0000000000000..a7b8c71e70d9c --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/RouterQueueConstructorProxy.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.communication.jobrouter.implementation.accesshelpers; + +import com.azure.communication.jobrouter.implementation.models.RouterQueueInternal; +import com.azure.communication.jobrouter.models.RouterQueue; + +/** + * Helper class to access private values of {@link RouterQueue} across package boundaries. + */ +public final class RouterQueueConstructorProxy { + + private static RouterQueueConstructorAccessor accessor; + + private RouterQueueConstructorProxy() { } + + /** + * Type defining the methods to set the non-public properties of a {@link RouterQueueConstructorAccessor} + * instance. + */ + public interface RouterQueueConstructorAccessor { + /** + * Creates a new instance of {@link RouterQueue} backed by an internal instance of + * {@link RouterQueue}. + * + * @param internal The internal response. + * @return A new instance of {@link RouterQueue}. + */ + RouterQueue create(RouterQueueInternal internal); + } + + /** + * The method called from {@link RouterQueue} to set it's accessor. + * + * @param accessor The accessor. + */ + public static void setAccessor(final RouterQueueConstructorAccessor accessor) { + RouterQueueConstructorProxy.accessor = accessor; + } + + /** + * Creates a new instance of {@link RouterQueue} backed by an internal instance of + * {@link RouterQueueInternal}. + * + * @param internal The internal response. + * @return A new instance of {@link RouterQueue}. + */ + public static RouterQueue create(RouterQueueInternal internal) { + // This looks odd but is necessary, it is possible to engage the access helper before anywhere else in the + // application accesses RouterJob which triggers the accessor to be configured. So, if the accessor + // is null this effectively pokes the class to set up the accessor. + if (accessor == null) { + new RouterQueue(); + } + + assert accessor != null; + return accessor.create(internal); + } +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/RouterValueConstructorProxy.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/RouterValueConstructorProxy.java new file mode 100644 index 0000000000000..a0182692239ae --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/RouterValueConstructorProxy.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.communication.jobrouter.implementation.accesshelpers; + +import com.azure.communication.jobrouter.models.RouterValue; + +/** + * Helper class to access private values of {@link RouterValue} across package boundaries. + */ +public final class RouterValueConstructorProxy { + + private static RouterValueConstructorAccessor accessor; + + private RouterValueConstructorProxy() { } + + /** + * Type defining the methods to set the non-public properties of a {@link RouterValueConstructorAccessor} + * instance. + */ + public interface RouterValueConstructorAccessor { + /** + * Creates a new instance of {@link RouterValue} backed by an internal instance of + * {@link RouterValue}. + * + * @param internal The internal response. + * @return A new instance of {@link RouterValue}. + */ + RouterValue create(Object internal); + } + + /** + * The method called from {@link RouterValue} to set it's accessor. + * + * @param accessor The accessor. + */ + public static void setAccessor(final RouterValueConstructorAccessor accessor) { + RouterValueConstructorProxy.accessor = accessor; + } + + /** + * Creates a new instance of {@link RouterValue} backed by an internal instance of + * {@link Object}. + * + * @param internal The internal response. + * @return A new instance of {@link RouterValue}. + */ + public static RouterValue create(Object internal) { + // This looks odd but is necessary, it is possible to engage the access helper before anywhere else in the + // application accesses LabelValue which triggers the accessor to be configured. So, if the accessor + // is null this effectively pokes the class to set up the accessor. + if (accessor == null) { + new RouterValue("", null, null, null); + } + + assert accessor != null; + return accessor.create(internal); + } +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/JobAdapter.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/JobAdapter.java index f870474980dc8..fda70668e437d 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/JobAdapter.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/JobAdapter.java @@ -14,6 +14,8 @@ import java.util.Map; import java.util.stream.Collectors; +import static com.azure.communication.jobrouter.implementation.converters.RouterValueAdapter.getValue; + /** * Converts request options for create and update Job to {@link RouterJob}. */ @@ -56,17 +58,4 @@ public static RouterJobInternal convertCreateJobOptionsToRouterJob(CreateJobOpti .setTags(tags) .setMatchingMode(createJobOptions.getMatchingMode()); } - - private static Object getValue(RouterValue routerValue) { - if (routerValue.getValueAsBoolean()) { - return routerValue.getValueAsBoolean(); - } else if (routerValue.getValueAsDouble() != null) { - return routerValue.getValueAsDouble(); - } else if (routerValue.getValueAsInteger() != null) { - return routerValue.getValueAsInteger(); - } else if (routerValue.getValueAsString() != null) { - return routerValue.getValueAsString(); - } - return null; - } } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/RouterValueAdapter.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/RouterValueAdapter.java index d4fb2c42d7aba..414bc3c8d80c5 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/RouterValueAdapter.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/RouterValueAdapter.java @@ -6,33 +6,32 @@ import com.azure.communication.jobrouter.models.RouterValue; import com.azure.core.util.logging.ClientLogger; +/** + * Wrapper class for labels. Supports String, int, double and boolean types. + * + * If multiple values are set only one value will be used with following precedence. + * + * 1. stringValue. + * 2. intValue. + * 3. doubleValue. + * 4. boolValue. + */ public class RouterValueAdapter { private static final ClientLogger LOGGER = new ClientLogger(RouterValueAdapter.class); public static Object getValue(RouterValue routerValue) { - try { - return routerValue.getValueAsInteger(); - } catch (IllegalStateException ex) { - LOGGER.info("value is not an Integer."); + if (routerValue.getStringValue() != null) { + return routerValue.getStringValue(); } - try { - return routerValue.getValueAsDouble(); - } catch (IllegalStateException ex) { - LOGGER.info("value is not a Double."); + if (routerValue.getIntValue() != null) { + return routerValue.getIntValue(); } - - try { - return routerValue.getValueAsBoolean(); - } catch (IllegalStateException ex) { - LOGGER.info("value is not a Boolean."); + if (routerValue.getDoubleValue() != null) { + return routerValue.getDoubleValue(); } - - try { - return routerValue.getValueAsString(); - } catch (IllegalStateException ex) { - LOGGER.info("value is not a String."); + if (routerValue.getBoolValue() != null) { + return routerValue.getBoolValue(); } - - throw new IllegalStateException("Object is not of types supported in RouterValue"); + return null; } } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterQueue.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterQueue.java index d02cc840b621f..27818cf4244b8 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterQueue.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterQueue.java @@ -3,10 +3,15 @@ // Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.communication.jobrouter.models; +import com.azure.communication.jobrouter.implementation.accesshelpers.RouterQueueConstructorProxy; +import com.azure.communication.jobrouter.implementation.accesshelpers.RouterValueConstructorProxy; +import com.azure.communication.jobrouter.implementation.models.RouterQueueInternal; import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.Map; +import java.util.stream.Collectors; /** A queue that can contain jobs to be routed. */ @Fluent @@ -49,10 +54,41 @@ public final class RouterQueue { @JsonProperty(value = "exceptionPolicyId") private String exceptionPolicyId; + static { + RouterQueueConstructorProxy.setAccessor(internal -> new RouterQueue(internal)); + } + + /** + * Package-private constructor of the class, used internally. + * + * @param internal The internal RouterQueue + */ + RouterQueue(RouterQueueInternal internal) { + id = internal.getId(); + + setName(internal.getName()); + setDistributionPolicyId(internal.getDistributionPolicyId()); + setExceptionPolicyId(internal.getExceptionPolicyId()); + setLabels(internal.getLabels().entrySet().stream() + .collect(Collectors.toMap(entry -> entry.getKey(), entry -> RouterValueConstructorProxy.create(entry.getValue())))); + } + + /** Creates an instance of RouterQueue class. */ @Generated public RouterQueue() {} + /** + * Jsoncreator. + * @param id id + * @param etag etag. + */ + @JsonCreator + public RouterQueue(String id, String etag) { + this.id = id; + this.etag = etag; + } + /** * Get the id property: The Id of this queue. * diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterValue.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterValue.java index 31450b21c053e..7299cd921c0dc 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterValue.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterValue.java @@ -3,96 +3,111 @@ package com.azure.communication.jobrouter.models; +import com.azure.communication.jobrouter.implementation.accesshelpers.RouterValueConstructorProxy; import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; /** - * Wrapper class for labels. Supports double, String and boolean types. + * Wrapper class for labels. Supports String, int, double and boolean types. + * + * If multiple values are set only one value will be used with following precedence. + * + * 1. stringValue. + * 2. intValue. + * 3. doubleValue. + * 4. boolValue. */ public final class RouterValue { private static final ClientLogger LOGGER = new ClientLogger(RouterValue.class); /** - * Value to pass to server. + * String Value to pass to server. */ - private final Object value; + @JsonProperty(value = "stringValue", access = JsonProperty.Access.WRITE_ONLY) + private String stringValue; /** - * Constructor for integer value. - * @param integerValue integer value of label. + * Integer Value to pass to server. */ - public RouterValue(Integer integerValue) { - this.value = integerValue; - } + @JsonProperty(value = "intValue", access = JsonProperty.Access.WRITE_ONLY) + private Integer intValue; /** - * Constructor for numerical value. - * @param numericValue numeric value of label. + * Double Value to pass to server. */ - public RouterValue(Double numericValue) { - this.value = numericValue; - } + @JsonProperty(value = "doubleValue", access = JsonProperty.Access.WRITE_ONLY) + private Double doubleValue; /** - * Constructor for string value. - * @param stringValue string value of label. + * Boolean Value to pass to server. */ - public RouterValue(String stringValue) { - this.value = stringValue; - } + @JsonProperty(value = "boolValue", access = JsonProperty.Access.WRITE_ONLY) + private Boolean boolValue; /** - * Constructor for boolean value. - * @param boolValue boolean value of label. + * Constructor + * */ - public RouterValue(Boolean boolValue) { - this.value = boolValue; + @JsonCreator + public RouterValue(@JsonProperty(value = "stringValue") String stringValue, + @JsonProperty(value = "intValue") Integer intValue, + @JsonProperty(value = "doubleValue") Double doubleValue, + @JsonProperty(value = "boolValue") Boolean boolValue) { + this.stringValue = stringValue; + this.intValue = intValue; + this.doubleValue = doubleValue; + this.boolValue = boolValue; + } + + static { + RouterValueConstructorProxy.setAccessor(internal -> new RouterValue(internal)); } RouterValue(Object objectValue) { - this.value = objectValue; + if (objectValue.getClass() == String.class) { + this.stringValue = (String) objectValue; + } + if (objectValue.getClass() == Integer.class) { + this.intValue = (int) objectValue; + } + if (objectValue.getClass() == Double.class) { + this.doubleValue = (double) objectValue; + } + if (objectValue.getClass() == Boolean.class) { + this.boolValue = (Boolean) objectValue; + } } /** - * Returns Integer value of object - * @return (Integer) value. + * Returns stringValue + * @return stringValue. */ - public Integer getValueAsInteger() { - if (value.getClass() == Integer.class) { - return (Integer) this.value; - } - throw LOGGER.logExceptionAsError(new IllegalStateException("value is not of type Integer.")); + public String getStringValue() { + return stringValue; } /** - * Returns Double value of object - * @return (Double) value. + * Returns intValue. + * @return intValue */ - public Double getValueAsDouble() { - if (value.getClass() == Double.class) { - return (Double) this.value; - } - throw LOGGER.logExceptionAsError(new IllegalStateException("value is not of type Double.")); + public Integer getIntValue() { + return intValue; } /** - * Returns String value of object - * @return (String) value. + * Returns doubleValue. + * @return doubleValue */ - public String getValueAsString() { - if (value.getClass() == String.class) { - return (String) this.value; - } - throw LOGGER.logExceptionAsError(new IllegalStateException("value is not of type String.")); + public Double getDoubleValue() { + return doubleValue; } /** - * Returns Boolean value of object - * @return (Boolean) value. + * Returns boolValue. + * @return boolValue. */ - public Boolean getValueAsBoolean() { - if (value.getClass() == Boolean.class) { - return (Boolean) this.value; - } - throw LOGGER.logExceptionAsError(new IllegalStateException("value is not of type Boolean.")); + public Boolean getBoolValue() { + return boolValue; } } diff --git a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/ClassificationPolicyLiveTests.java b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/ClassificationPolicyLiveTests.java index 2e06564f109cd..59a73c2a8629b 100644 --- a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/ClassificationPolicyLiveTests.java +++ b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/ClassificationPolicyLiveTests.java @@ -47,7 +47,7 @@ public void createClassificationPolicy(HttpClient httpClient) { */ StaticQueueSelectorAttachment staticQueueSelector = new StaticQueueSelectorAttachment( new RouterQueueSelector("queueId", LabelOperator.EQUAL) - .setValue(new RouterValue(queueId))); + .setValue(new RouterValue(queueId, null, null, null))); List queueSelectors = new ArrayList() { { @@ -61,7 +61,7 @@ public void createClassificationPolicy(HttpClient httpClient) { */ StaticWorkerSelectorAttachment staticWorkerSelector = new StaticWorkerSelectorAttachment( new RouterWorkerSelector("key", LabelOperator.EQUAL) - .setValue(new RouterValue("value"))); + .setValue(new RouterValue("value", null, null, null))); List workerSelectors = new ArrayList() { { @@ -75,7 +75,7 @@ public void createClassificationPolicy(HttpClient httpClient) { CreateClassificationPolicyOptions createClassificationPolicyOptions = new CreateClassificationPolicyOptions( classificationPolicyId) .setName(classificationPolicyName) - .setPrioritizationRule(new StaticRouterRule().setValue(new RouterValue(1))) + .setPrioritizationRule(new StaticRouterRule().setValue(new RouterValue(null, 1, null, null))) .setWorkerSelectors(workerSelectors) .setQueueSelectors(queueSelectors) .setFallbackQueueId(jobQueue.getId()); diff --git a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/JobRouterTestBase.java b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/JobRouterTestBase.java index a14e4b0078289..73498ff8dbfbc 100644 --- a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/JobRouterTestBase.java +++ b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/JobRouterTestBase.java @@ -114,7 +114,7 @@ protected RouterQueue createQueue(JobRouterAdministrationClient routerAdminClien String queueName = String.format("%s-Name", queueId); Map queueLabels = new HashMap() { { - put("Label_1", new RouterValue("Value_1")); + put("Label_1", new RouterValue("Value_1", null, null, null)); } }; @@ -148,7 +148,7 @@ protected RouterJob createJob(JobRouterClient jobRouterClient, String queueId) { new ArrayList() { { new RouterWorkerSelector("Some-skill", LabelOperator.GREATER_THAN) - .setValue(new RouterValue(10)); + .setValue(new RouterValue(null, 10, null, null)); } } ); diff --git a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterJobLiveTests.java b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterJobLiveTests.java index 0107c04d157b9..9454803ff103e 100644 --- a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterJobLiveTests.java +++ b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterJobLiveTests.java @@ -59,13 +59,13 @@ public void unassignJob(HttpClient httpClient) { */ Map labels = new HashMap() { { - put("Label", new RouterValue("Value")); + put("Label", new RouterValue("Value", null, null, null)); } }; Map tags = new HashMap() { { - put("Tag", new RouterValue("Value")); + put("Tag", new RouterValue("Value", null, null, null)); } }; diff --git a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterQueueLiveTests.java b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterQueueLiveTests.java index 47f1745f6321b..7f4943ed93ae4 100644 --- a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterQueueLiveTests.java +++ b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterQueueLiveTests.java @@ -58,16 +58,17 @@ public void updateQueue(HttpClient httpClient) { Map updatedQueueLabels = new HashMap() { { - put("Label_1", new RouterValue("UpdatedValue")); + put("Label_1", new RouterValue("UpdatedValue", null, null, null)); } }; // Action - queue = routerAdminClient.updateQueueWithResponse(queueId, BinaryData.fromObject(new RouterQueue().setLabels(updatedQueueLabels)), new RequestOptions()) + RouterQueue updatedRouterQueue = queue.setLabels(updatedQueueLabels); + queue = routerAdminClient.updateQueueWithResponse(queueId, BinaryData.fromObject(updatedRouterQueue), new RequestOptions()) .getValue().toObject(RouterQueue.class); // Verify - assertEquals(updatedQueueLabels.get("Label_1").getValueAsString(), queue.getLabels().get("Label_1").getValueAsString()); + assertEquals(updatedQueueLabels.get("Label_1").getStringValue(), queue.getLabels().get("Label_1").getStringValue()); // Cleanup routerAdminClient.deleteQueue(queueId); diff --git a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterWorkerLiveTests.java b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterWorkerLiveTests.java index 6ae200159a0c9..cc8e21c6e6fcf 100644 --- a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterWorkerLiveTests.java +++ b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterWorkerLiveTests.java @@ -47,13 +47,13 @@ public void createWorker(HttpClient httpClient) { Map labels = new HashMap() { { - put("Label", new RouterValue("Value")); + put("Label", new RouterValue("Value", null, null, null)); } }; Map tags = new HashMap() { { - put("Tag", new RouterValue("Value")); + put("Tag", new RouterValue("Value", null, null, null)); } }; From d0de6e0c4010ffb18d1f49f4c33438581bfeba4f Mon Sep 17 00:00:00 2001 From: Charandeep Parisineti Date: Sun, 5 Nov 2023 13:17:35 -0800 Subject: [PATCH 08/12] Add ConstructorProxy classes --- .../ClassificationPolicyConstructorProxy.java | 60 ++++++++ .../DistributionPolicyConstructorProxy.java | 60 ++++++++ .../ExceptionPolicyConstructorProxy.java | 60 ++++++++ .../RouterJobConstructorProxy.java | 60 ++++++++ .../RouterWorkerConstructorProxy.java | 60 ++++++++ .../converters/DistributionPolicyAdapter.java | 62 ++++++++- .../converters/ExceptionPolicyAdapter.java | 55 ++++++++ .../implementation/converters/JobAdapter.java | 1 + .../converters/LabelSelectorAdapter.java | 76 +++++++++++ .../converters/RouterRuleAdapter.java | 59 ++++++++ .../models/BestWorkerModeInternal.java | 113 +++++++++++++++ .../models/DistributionModeInternal.java | 129 ++++++++++++++++++ .../models/DistributionPolicyInternal.java | 6 +- .../models/LongestIdleModeInternal.java | 45 ++++++ .../models/RoundRobinModeInternal.java | 47 +++++++ .../models/ClassificationPolicy.java | 28 ++++ .../jobrouter/models/DistributionPolicy.java | 20 +++ .../jobrouter/models/ExceptionPolicy.java | 19 +++ .../jobrouter/models/RouterJob.java | 45 ++++++ .../jobrouter/models/RouterWorker.java | 32 +++++ 20 files changed, 1033 insertions(+), 4 deletions(-) create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/ClassificationPolicyConstructorProxy.java create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/DistributionPolicyConstructorProxy.java create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/ExceptionPolicyConstructorProxy.java create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/RouterJobConstructorProxy.java create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/RouterWorkerConstructorProxy.java create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/BestWorkerModeInternal.java create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/DistributionModeInternal.java create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/LongestIdleModeInternal.java create mode 100644 sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RoundRobinModeInternal.java diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/ClassificationPolicyConstructorProxy.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/ClassificationPolicyConstructorProxy.java new file mode 100644 index 0000000000000..1ee337a5f43fd --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/ClassificationPolicyConstructorProxy.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.communication.jobrouter.implementation.accesshelpers; + +import com.azure.communication.jobrouter.implementation.models.ClassificationPolicyInternal; +import com.azure.communication.jobrouter.models.ClassificationPolicy; + +/** + * Helper class to access private values of {@link ClassificationPolicy} across package boundaries. + */ +public final class ClassificationPolicyConstructorProxy { + + private static ClassificationPolicyConstructorAccessor accessor; + + private ClassificationPolicyConstructorProxy() { } + + /** + * Type defining the methods to set the non-public properties of a {@link ClassificationPolicyConstructorAccessor} + * instance. + */ + public interface ClassificationPolicyConstructorAccessor { + /** + * Creates a new instance of {@link ClassificationPolicy} backed by an internal instance of + * {@link ClassificationPolicy}. + * + * @param internal The internal response. + * @return A new instance of {@link ClassificationPolicy}. + */ + ClassificationPolicy create(ClassificationPolicyInternal internal); + } + + /** + * The method called from {@link ClassificationPolicy} to set it's accessor. + * + * @param accessor The accessor. + */ + public static void setAccessor(final ClassificationPolicyConstructorAccessor accessor) { + ClassificationPolicyConstructorProxy.accessor = accessor; + } + + /** + * Creates a new instance of {@link ClassificationPolicy} backed by an internal instance of + * {@link ClassificationPolicyInternal}. + * + * @param internal The internal response. + * @return A new instance of {@link ClassificationPolicy}. + */ + public static ClassificationPolicy create(ClassificationPolicyInternal internal) { + // This looks odd but is necessary, it is possible to engage the access helper before anywhere else in the + // application accesses RouterJob which triggers the accessor to be configured. So, if the accessor + // is null this effectively pokes the class to set up the accessor. + if (accessor == null) { + new ClassificationPolicy(); + } + + assert accessor != null; + return accessor.create(internal); + } +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/DistributionPolicyConstructorProxy.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/DistributionPolicyConstructorProxy.java new file mode 100644 index 0000000000000..f536d300b8d91 --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/DistributionPolicyConstructorProxy.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.communication.jobrouter.implementation.accesshelpers; + +import com.azure.communication.jobrouter.implementation.models.DistributionPolicyInternal; +import com.azure.communication.jobrouter.models.DistributionPolicy; + +/** + * Helper class to access private values of {@link DistributionPolicy} across package boundaries. + */ +public final class DistributionPolicyConstructorProxy { + + private static DistributionPolicyConstructorAccessor accessor; + + private DistributionPolicyConstructorProxy() { } + + /** + * Type defining the methods to set the non-public properties of a {@link DistributionPolicyConstructorAccessor} + * instance. + */ + public interface DistributionPolicyConstructorAccessor { + /** + * Creates a new instance of {@link DistributionPolicy} backed by an internal instance of + * {@link DistributionPolicy}. + * + * @param internal The internal response. + * @return A new instance of {@link DistributionPolicy}. + */ + DistributionPolicy create(DistributionPolicyInternal internal); + } + + /** + * The method called from {@link DistributionPolicy} to set it's accessor. + * + * @param accessor The accessor. + */ + public static void setAccessor(final DistributionPolicyConstructorAccessor accessor) { + DistributionPolicyConstructorProxy.accessor = accessor; + } + + /** + * Creates a new instance of {@link DistributionPolicy} backed by an internal instance of + * {@link DistributionPolicyInternal}. + * + * @param internal The internal response. + * @return A new instance of {@link DistributionPolicy}. + */ + public static DistributionPolicy create(DistributionPolicyInternal internal) { + // This looks odd but is necessary, it is possible to engage the access helper before anywhere else in the + // application accesses RouterJob which triggers the accessor to be configured. So, if the accessor + // is null this effectively pokes the class to set up the accessor. + if (accessor == null) { + new DistributionPolicy(); + } + + assert accessor != null; + return accessor.create(internal); + } +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/ExceptionPolicyConstructorProxy.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/ExceptionPolicyConstructorProxy.java new file mode 100644 index 0000000000000..3c2a737853e24 --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/ExceptionPolicyConstructorProxy.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.communication.jobrouter.implementation.accesshelpers; + +import com.azure.communication.jobrouter.implementation.models.ExceptionPolicyInternal; +import com.azure.communication.jobrouter.models.ExceptionPolicy; + +/** + * Helper class to access private values of {@link ExceptionPolicy} across package boundaries. + */ +public final class ExceptionPolicyConstructorProxy { + + private static ExceptionPolicyConstructorAccessor accessor; + + private ExceptionPolicyConstructorProxy() { } + + /** + * Type defining the methods to set the non-public properties of a {@link ExceptionPolicyConstructorAccessor} + * instance. + */ + public interface ExceptionPolicyConstructorAccessor { + /** + * Creates a new instance of {@link ExceptionPolicy} backed by an internal instance of + * {@link ExceptionPolicy}. + * + * @param internal The internal response. + * @return A new instance of {@link ExceptionPolicy}. + */ + ExceptionPolicy create(ExceptionPolicyInternal internal); + } + + /** + * The method called from {@link ExceptionPolicy} to set it's accessor. + * + * @param accessor The accessor. + */ + public static void setAccessor(final ExceptionPolicyConstructorAccessor accessor) { + ExceptionPolicyConstructorProxy.accessor = accessor; + } + + /** + * Creates a new instance of {@link ExceptionPolicy} backed by an internal instance of + * {@link ExceptionPolicyInternal}. + * + * @param internal The internal response. + * @return A new instance of {@link ExceptionPolicy}. + */ + public static ExceptionPolicy create(ExceptionPolicyInternal internal) { + // This looks odd but is necessary, it is possible to engage the access helper before anywhere else in the + // application accesses RouterJob which triggers the accessor to be configured. So, if the accessor + // is null this effectively pokes the class to set up the accessor. + if (accessor == null) { + new ExceptionPolicy(); + } + + assert accessor != null; + return accessor.create(internal); + } +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/RouterJobConstructorProxy.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/RouterJobConstructorProxy.java new file mode 100644 index 0000000000000..ba78f3b3a3735 --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/RouterJobConstructorProxy.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.communication.jobrouter.implementation.accesshelpers; + +import com.azure.communication.jobrouter.implementation.models.RouterJobInternal; +import com.azure.communication.jobrouter.models.RouterJob; + +/** + * Helper class to access private values of {@link RouterJob} across package boundaries. + */ +public final class RouterJobConstructorProxy { + + private static RouterJobConstructorAccessor accessor; + + private RouterJobConstructorProxy() { } + + /** + * Type defining the methods to set the non-public properties of a {@link RouterJobConstructorAccessor} + * instance. + */ + public interface RouterJobConstructorAccessor { + /** + * Creates a new instance of {@link RouterJob} backed by an internal instance of + * {@link RouterJob}. + * + * @param internal The internal response. + * @return A new instance of {@link RouterJob}. + */ + RouterJob create(RouterJobInternal internal); + } + + /** + * The method called from {@link RouterJob} to set it's accessor. + * + * @param accessor The accessor. + */ + public static void setAccessor(final RouterJobConstructorAccessor accessor) { + RouterJobConstructorProxy.accessor = accessor; + } + + /** + * Creates a new instance of {@link RouterJob} backed by an internal instance of + * {@link RouterJobInternal}. + * + * @param internal The internal response. + * @return A new instance of {@link RouterJob}. + */ + public static RouterJob create(RouterJobInternal internal) { + // This looks odd but is necessary, it is possible to engage the access helper before anywhere else in the + // application accesses RouterJob which triggers the accessor to be configured. So, if the accessor + // is null this effectively pokes the class to set up the accessor. + if (accessor == null) { + new RouterJob(); + } + + assert accessor != null; + return accessor.create(internal); + } +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/RouterWorkerConstructorProxy.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/RouterWorkerConstructorProxy.java new file mode 100644 index 0000000000000..438f02ff0f0a7 --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/accesshelpers/RouterWorkerConstructorProxy.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.communication.jobrouter.implementation.accesshelpers; + +import com.azure.communication.jobrouter.implementation.models.RouterWorkerInternal; +import com.azure.communication.jobrouter.models.RouterWorker; + +/** + * Helper class to access private values of {@link RouterWorker} across package boundaries. + */ +public final class RouterWorkerConstructorProxy { + + private static RouterWorkerConstructorAccessor accessor; + + private RouterWorkerConstructorProxy() { } + + /** + * Type defining the methods to set the non-public properties of a {@link RouterWorkerConstructorAccessor} + * instance. + */ + public interface RouterWorkerConstructorAccessor { + /** + * Creates a new instance of {@link RouterWorker} backed by an internal instance of + * {@link RouterWorker}. + * + * @param internal The internal response. + * @return A new instance of {@link RouterWorker}. + */ + RouterWorker create(RouterWorkerInternal internal); + } + + /** + * The method called from {@link RouterWorker} to set it's accessor. + * + * @param accessor The accessor. + */ + public static void setAccessor(final RouterWorkerConstructorAccessor accessor) { + RouterWorkerConstructorProxy.accessor = accessor; + } + + /** + * Creates a new instance of {@link RouterWorker} backed by an internal instance of + * {@link RouterWorkerInternal}. + * + * @param internal The internal response. + * @return A new instance of {@link RouterWorker}. + */ + public static RouterWorker create(RouterWorkerInternal internal) { + // This looks odd but is necessary, it is possible to engage the access helper before anywhere else in the + // application accesses RouterJob which triggers the accessor to be configured. So, if the accessor + // is null this effectively pokes the class to set up the accessor. + if (accessor == null) { + new RouterWorker(); + } + + assert accessor != null; + return accessor.create(internal); + } +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/DistributionPolicyAdapter.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/DistributionPolicyAdapter.java index 240e7791593e3..eb697258961dd 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/DistributionPolicyAdapter.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/DistributionPolicyAdapter.java @@ -3,9 +3,17 @@ package com.azure.communication.jobrouter.implementation.converters; +import com.azure.communication.jobrouter.implementation.models.BestWorkerModeInternal; +import com.azure.communication.jobrouter.implementation.models.DistributionModeInternal; import com.azure.communication.jobrouter.implementation.models.DistributionPolicyInternal; +import com.azure.communication.jobrouter.implementation.models.LongestIdleModeInternal; +import com.azure.communication.jobrouter.implementation.models.RoundRobinModeInternal; +import com.azure.communication.jobrouter.models.BestWorkerMode; import com.azure.communication.jobrouter.models.CreateDistributionPolicyOptions; +import com.azure.communication.jobrouter.models.DistributionMode; import com.azure.communication.jobrouter.models.DistributionPolicy; +import com.azure.communication.jobrouter.models.LongestIdleMode; +import com.azure.communication.jobrouter.models.RoundRobinMode; /** * Converts request options for create and update Classification Policy to {@link DistributionPolicy}. @@ -18,8 +26,60 @@ public class DistributionPolicyAdapter { */ public static DistributionPolicyInternal convertCreateOptionsToDistributionPolicy(CreateDistributionPolicyOptions createDistributionPolicyOptions) { return new DistributionPolicyInternal() - .setMode(createDistributionPolicyOptions.getMode()) + .setMode(convertDistributionModeToInternal(createDistributionPolicyOptions.getMode())) .setOfferExpiresAfterSeconds((double) createDistributionPolicyOptions.getOfferExpiresAfter().getSeconds()) .setName(createDistributionPolicyOptions.getName()); } + + public static DistributionModeInternal convertDistributionModeToInternal(DistributionMode mode) { + if (mode instanceof BestWorkerMode) { + BestWorkerMode bestWorker = (BestWorkerMode) mode; + return new BestWorkerModeInternal() + .setMinConcurrentOffers(bestWorker.getMinConcurrentOffers()) + .setMaxConcurrentOffers(bestWorker.getMaxConcurrentOffers()) + .setBypassSelectors(bestWorker.isBypassSelectors()) + .setScoringRule(RouterRuleAdapter.convertRouterRuleToInternal(bestWorker.getScoringRule())) + .setScoringRuleOptions(bestWorker.getScoringRuleOptions()); + } else if (mode instanceof RoundRobinMode) { + RoundRobinMode roundRobin = (RoundRobinMode) mode; + return new RoundRobinModeInternal() + .setMinConcurrentOffers(roundRobin.getMinConcurrentOffers()) + .setMaxConcurrentOffers(roundRobin.getMaxConcurrentOffers()) + .setBypassSelectors(roundRobin.isBypassSelectors()); + } else if (mode instanceof LongestIdleMode) { + LongestIdleMode longestIdle = (LongestIdleMode) mode; + return new LongestIdleModeInternal() + .setMinConcurrentOffers(longestIdle.getMinConcurrentOffers()) + .setMaxConcurrentOffers(longestIdle.getMaxConcurrentOffers()) + .setBypassSelectors(longestIdle.isBypassSelectors()); + } + + return null; + } + + public static DistributionMode convertDistributionModeToPublic(DistributionModeInternal mode) { + if (mode instanceof BestWorkerModeInternal) { + BestWorkerModeInternal bestWorker = (BestWorkerModeInternal) mode; + return new BestWorkerMode() + .setMinConcurrentOffers(bestWorker.getMinConcurrentOffers()) + .setMaxConcurrentOffers(bestWorker.getMaxConcurrentOffers()) + .setBypassSelectors(bestWorker.isBypassSelectors()) + .setScoringRule(RouterRuleAdapter.convertRouterRuleToPublic(bestWorker.getScoringRule())) + .setScoringRuleOptions(bestWorker.getScoringRuleOptions()); + } else if (mode instanceof RoundRobinModeInternal) { + RoundRobinModeInternal roundRobin = (RoundRobinModeInternal) mode; + return new RoundRobinMode() + .setMinConcurrentOffers(roundRobin.getMinConcurrentOffers()) + .setMaxConcurrentOffers(roundRobin.getMaxConcurrentOffers()) + .setBypassSelectors(roundRobin.isBypassSelectors()); + } else if (mode instanceof LongestIdleModeInternal) { + LongestIdleModeInternal longestIdle = (LongestIdleModeInternal) mode; + return new LongestIdleMode() + .setMinConcurrentOffers(longestIdle.getMinConcurrentOffers()) + .setMaxConcurrentOffers(longestIdle.getMaxConcurrentOffers()) + .setBypassSelectors(longestIdle.isBypassSelectors()); + } + + return null; + } } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/ExceptionPolicyAdapter.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/ExceptionPolicyAdapter.java index 92aff7cd228e4..141c85c8b7cf4 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/ExceptionPolicyAdapter.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/ExceptionPolicyAdapter.java @@ -3,6 +3,7 @@ package com.azure.communication.jobrouter.implementation.converters; +import com.azure.communication.jobrouter.implementation.accesshelpers.RouterValueConstructorProxy; import com.azure.communication.jobrouter.implementation.models.CancelExceptionActionInternal; import com.azure.communication.jobrouter.implementation.models.ExceptionActionInternal; import com.azure.communication.jobrouter.implementation.models.ExceptionPolicyInternal; @@ -10,6 +11,7 @@ import com.azure.communication.jobrouter.implementation.models.ExceptionTriggerInternal; import com.azure.communication.jobrouter.implementation.models.ManualReclassifyExceptionActionInternal; import com.azure.communication.jobrouter.implementation.models.QueueLengthExceptionTriggerInternal; +import com.azure.communication.jobrouter.implementation.models.ReclassifyExceptionActionInternal; import com.azure.communication.jobrouter.implementation.models.WaitTimeExceptionTriggerInternal; import com.azure.communication.jobrouter.models.CancelExceptionAction; import com.azure.communication.jobrouter.models.CreateExceptionPolicyOptions; @@ -19,9 +21,14 @@ import com.azure.communication.jobrouter.models.ExceptionTrigger; import com.azure.communication.jobrouter.models.ManualReclassifyExceptionAction; import com.azure.communication.jobrouter.models.QueueLengthExceptionTrigger; +import com.azure.communication.jobrouter.models.ReclassifyExceptionAction; import com.azure.communication.jobrouter.models.WaitTimeExceptionTrigger; +import java.time.Duration; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -82,4 +89,52 @@ private static ExceptionRuleInternal convertExceptionRule(ExceptionRule exceptio .collect(Collectors.toList()); return new ExceptionRuleInternal(id, exceptionTriggerInternal, exceptionActionInternalList); } + + public static ExceptionTrigger convertExceptionTriggerToPublic(ExceptionTriggerInternal trigger) { + if (trigger instanceof QueueLengthExceptionTriggerInternal) { + QueueLengthExceptionTriggerInternal queueLength = (QueueLengthExceptionTriggerInternal) trigger; + return new QueueLengthExceptionTrigger(queueLength.getThreshold()); + } else if (trigger instanceof WaitTimeExceptionTriggerInternal) { + WaitTimeExceptionTriggerInternal waitTime = (WaitTimeExceptionTriggerInternal) trigger; + return new WaitTimeExceptionTrigger(Duration.ofSeconds((long) waitTime.getThresholdSeconds())); + } + + return null; + } + + public static ExceptionAction convertExceptionActionToPublic(ExceptionActionInternal action) { + if (action instanceof CancelExceptionActionInternal) { + CancelExceptionActionInternal cancel = (CancelExceptionActionInternal) action; + return new CancelExceptionAction() + .setNote(cancel.getNote()) + .setDispositionCode(cancel.getDispositionCode()); + } else if (action instanceof ManualReclassifyExceptionActionInternal) { + ManualReclassifyExceptionActionInternal manualReclassify = (ManualReclassifyExceptionActionInternal) action; + return new ManualReclassifyExceptionAction() + .setPriority(manualReclassify.getPriority()) + .setQueueId(manualReclassify.getQueueId()) + .setWorkerSelectors(manualReclassify.getWorkerSelectors().stream() + .map(LabelSelectorAdapter::convertWorkerSelectorToPublic).collect(Collectors.toList())); + } else if (action instanceof ReclassifyExceptionActionInternal) { + ReclassifyExceptionActionInternal reclassify = (ReclassifyExceptionActionInternal) action; + return new ReclassifyExceptionAction() + .setClassificationPolicyId(reclassify.getClassificationPolicyId()) + .setLabelsToUpsert(reclassify.getLabelsToUpsert().entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getKey, entry -> RouterValueConstructorProxy.create(entry.getValue())))); + } + + return null; + } + + public static List convertExceptionRulesToPublic(List rules) { + return rules != null ? rules.stream() + .map(rule -> { + ExceptionTrigger trigger = convertExceptionTriggerToPublic(rule.getTrigger()); + List actions = rule.getActions().stream() + .map(action -> convertExceptionActionToPublic(action)) + .collect(Collectors.toList()); + return new ExceptionRule(rule.getId(), trigger, actions); + }) + .collect(Collectors.toList()) : new ArrayList(); + } } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/JobAdapter.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/JobAdapter.java index fda70668e437d..228cb32500f47 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/JobAdapter.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/JobAdapter.java @@ -6,6 +6,7 @@ import com.azure.communication.jobrouter.implementation.models.RouterJobInternal; import com.azure.communication.jobrouter.implementation.models.RouterWorkerSelectorInternal; import com.azure.communication.jobrouter.models.CreateJobOptions; +import com.azure.communication.jobrouter.models.RouterJobAssignment; import com.azure.communication.jobrouter.models.RouterValue; import com.azure.communication.jobrouter.models.RouterJob; import com.azure.communication.jobrouter.models.RouterJobNote; diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/LabelSelectorAdapter.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/LabelSelectorAdapter.java index 40a8de4d7815f..8cb6209baea00 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/LabelSelectorAdapter.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/LabelSelectorAdapter.java @@ -3,6 +3,7 @@ package com.azure.communication.jobrouter.implementation.converters; +import com.azure.communication.jobrouter.implementation.accesshelpers.RouterValueConstructorProxy; import com.azure.communication.jobrouter.implementation.models.ConditionalQueueSelectorAttachmentInternal; import com.azure.communication.jobrouter.implementation.models.ConditionalWorkerSelectorAttachmentInternal; import com.azure.communication.jobrouter.implementation.models.PassThroughQueueSelectorAttachmentInternal; @@ -21,9 +22,11 @@ import com.azure.communication.jobrouter.implementation.models.WorkerWeightedAllocationInternal; import com.azure.communication.jobrouter.models.ConditionalQueueSelectorAttachment; import com.azure.communication.jobrouter.models.ConditionalWorkerSelectorAttachment; +import com.azure.communication.jobrouter.models.LabelOperator; import com.azure.communication.jobrouter.models.PassThroughQueueSelectorAttachment; import com.azure.communication.jobrouter.models.PassThroughWorkerSelectorAttachment; import com.azure.communication.jobrouter.models.QueueSelectorAttachment; +import com.azure.communication.jobrouter.models.QueueWeightedAllocation; import com.azure.communication.jobrouter.models.RouterQueueSelector; import com.azure.communication.jobrouter.models.RouterWorkerSelector; import com.azure.communication.jobrouter.models.RuleEngineQueueSelectorAttachment; @@ -33,7 +36,9 @@ import com.azure.communication.jobrouter.models.WeightedAllocationQueueSelectorAttachment; import com.azure.communication.jobrouter.models.WeightedAllocationWorkerSelectorAttachment; import com.azure.communication.jobrouter.models.WorkerSelectorAttachment; +import com.azure.communication.jobrouter.models.WorkerWeightedAllocation; +import java.time.Duration; import java.util.stream.Collectors; import static com.azure.communication.jobrouter.implementation.converters.RouterRuleAdapter.getRouterRuleInternal; @@ -133,4 +138,75 @@ public static WorkerSelectorAttachmentInternal convertWorkerSelectorAttachmentTo return null; } + + public static RouterWorkerSelector convertWorkerSelectorToPublic(RouterWorkerSelectorInternal ws) { + RouterWorkerSelector workerSelector = new RouterWorkerSelector(ws.getKey(), + LabelOperator.fromString(ws.getLabelOperator().toString())) + .setValue(RouterValueConstructorProxy.create(ws)) + .setExpedite(ws.isExpedite()) + .setExpiresAfter(Duration.ofSeconds(ws.getExpiresAfterSeconds().longValue())); + + return workerSelector; + } + + public static RouterQueueSelector convertQueueSelectorToPublic(RouterQueueSelectorInternal qs) { + return new RouterQueueSelector(qs.getKey(), LabelOperator.fromString(qs.getLabelOperator().toString())) + .setValue(RouterValueConstructorProxy.create(qs.getValue())); + } + + public static QueueSelectorAttachment convertQueueSelectorAttachmentToPublic(QueueSelectorAttachmentInternal attachment) { + if (attachment instanceof StaticQueueSelectorAttachmentInternal) { + StaticQueueSelectorAttachmentInternal staticAttach = (StaticQueueSelectorAttachmentInternal) attachment; + return new StaticQueueSelectorAttachment(LabelSelectorAdapter.convertQueueSelectorToPublic(staticAttach.getQueueSelector())); + } else if (attachment instanceof ConditionalQueueSelectorAttachmentInternal) { + ConditionalQueueSelectorAttachmentInternal conditional = (ConditionalQueueSelectorAttachmentInternal) attachment; + return new ConditionalQueueSelectorAttachment(RouterRuleAdapter.convertRouterRuleToPublic(conditional.getCondition()), + conditional.getQueueSelectors().stream() + .map(LabelSelectorAdapter::convertQueueSelectorToPublic).collect(Collectors.toList())); + } else if (attachment instanceof PassThroughQueueSelectorAttachmentInternal) { + PassThroughQueueSelectorAttachmentInternal passThrough = (PassThroughQueueSelectorAttachmentInternal) attachment; + return new PassThroughQueueSelectorAttachment(passThrough.getKey(), + LabelOperator.fromString(passThrough.getLabelOperator().toString())); + } else if (attachment instanceof RuleEngineQueueSelectorAttachmentInternal) { + RuleEngineQueueSelectorAttachmentInternal rule = (RuleEngineQueueSelectorAttachmentInternal) attachment; + return new RuleEngineQueueSelectorAttachment(RouterRuleAdapter.convertRouterRuleToPublic(rule.getRule())); + } else if (attachment instanceof WeightedAllocationQueueSelectorAttachmentInternal) { + WeightedAllocationQueueSelectorAttachmentInternal weighted = (WeightedAllocationQueueSelectorAttachmentInternal) attachment; + return new WeightedAllocationQueueSelectorAttachment(weighted.getAllocations().stream() + .map(a -> new QueueWeightedAllocation(a.getWeight(), a.getQueueSelectors().stream() + .map(qs -> LabelSelectorAdapter.convertQueueSelectorToPublic(qs)) + .collect(Collectors.toList()))) + .collect(Collectors.toList())); + } + + return null; + } + + public static WorkerSelectorAttachment convertWorkerSelectorAttachmentToPublic(WorkerSelectorAttachmentInternal attachment) { + if (attachment instanceof StaticWorkerSelectorAttachmentInternal) { + StaticWorkerSelectorAttachmentInternal staticAttach = (StaticWorkerSelectorAttachmentInternal) attachment; + return new StaticWorkerSelectorAttachment(LabelSelectorAdapter.convertWorkerSelectorToPublic(staticAttach.getWorkerSelector())); + } else if (attachment instanceof ConditionalWorkerSelectorAttachmentInternal) { + ConditionalWorkerSelectorAttachmentInternal conditional = (ConditionalWorkerSelectorAttachmentInternal) attachment; + return new ConditionalWorkerSelectorAttachment(RouterRuleAdapter.convertRouterRuleToPublic(conditional.getCondition()), + conditional.getWorkerSelectors().stream() + .map(LabelSelectorAdapter::convertWorkerSelectorToPublic).collect(Collectors.toList())); + } else if (attachment instanceof PassThroughWorkerSelectorAttachmentInternal) { + PassThroughWorkerSelectorAttachmentInternal passThrough = (PassThroughWorkerSelectorAttachmentInternal) attachment; + return new PassThroughWorkerSelectorAttachment(passThrough.getKey(), LabelOperator.fromString(passThrough.getLabelOperator().toString())) + .setExpiresAfter(Duration.ofSeconds(passThrough.getExpiresAfterSeconds().longValue())); + } else if (attachment instanceof RuleEngineWorkerSelectorAttachmentInternal) { + RuleEngineWorkerSelectorAttachmentInternal rule = (RuleEngineWorkerSelectorAttachmentInternal) attachment; + return new RuleEngineWorkerSelectorAttachment(RouterRuleAdapter.convertRouterRuleToPublic(rule.getRule())); + } else if (attachment instanceof WeightedAllocationWorkerSelectorAttachmentInternal) { + WeightedAllocationWorkerSelectorAttachmentInternal weighted = (WeightedAllocationWorkerSelectorAttachmentInternal) attachment; + return new WeightedAllocationWorkerSelectorAttachment(weighted.getAllocations().stream() + .map(a -> new WorkerWeightedAllocation(a.getWeight(), a.getWorkerSelectors().stream() + .map(qs -> LabelSelectorAdapter.convertWorkerSelectorToPublic(qs)) + .collect(Collectors.toList()))) + .collect(Collectors.toList())); + } + + return null; + } } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/RouterRuleAdapter.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/RouterRuleAdapter.java index 23b5b3615af19..446e4585f7d7b 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/RouterRuleAdapter.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/RouterRuleAdapter.java @@ -3,6 +3,7 @@ package com.azure.communication.jobrouter.implementation.converters; +import com.azure.communication.jobrouter.implementation.accesshelpers.RouterValueConstructorProxy; import com.azure.communication.jobrouter.implementation.models.DirectMapRouterRuleInternal; import com.azure.communication.jobrouter.implementation.models.ExpressionRouterRuleInternal; import com.azure.communication.jobrouter.implementation.models.FunctionRouterRuleInternal; @@ -11,7 +12,10 @@ import com.azure.communication.jobrouter.implementation.models.WebhookRouterRuleInternal; import com.azure.communication.jobrouter.models.DirectMapRouterRule; import com.azure.communication.jobrouter.models.ExpressionRouterRule; +import com.azure.communication.jobrouter.models.ExpressionRouterRuleLanguage; import com.azure.communication.jobrouter.models.FunctionRouterRule; +import com.azure.communication.jobrouter.models.FunctionRouterRuleCredential; +import com.azure.communication.jobrouter.models.OAuth2WebhookClientCredential; import com.azure.communication.jobrouter.models.RouterRule; import com.azure.communication.jobrouter.models.StaticRouterRule; import com.azure.communication.jobrouter.models.WebhookRouterRule; @@ -51,4 +55,59 @@ public static RouterRuleInternal getRouterRuleInternal(RouterRule routerRule) { } return prioritizationRuleInternal; } + + public static RouterRule convertRouterRuleToPublic(RouterRuleInternal rule) { + if (rule instanceof DirectMapRouterRuleInternal) { + return new DirectMapRouterRule(); + } else if (rule instanceof ExpressionRouterRuleInternal) { + return new ExpressionRouterRule(((ExpressionRouterRuleInternal) rule).getExpression()); + } else if (rule instanceof FunctionRouterRuleInternal) { + FunctionRouterRuleInternal functionRouterRule = (FunctionRouterRuleInternal) rule; + return new FunctionRouterRule(functionRouterRule.getFunctionUri()) + .setCredential(new FunctionRouterRuleCredential() + .setFunctionKey(functionRouterRule.getCredential().getFunctionKey()) + .setAppKey(functionRouterRule.getCredential().getAppKey()) + .setClientId(functionRouterRule.getCredential().getClientId())); + } else if (rule instanceof StaticRouterRuleInternal) { + return new StaticRouterRule() + .setValue(RouterValueConstructorProxy.create(((StaticRouterRuleInternal) rule).getValue())); + } else if (rule instanceof WebhookRouterRuleInternal) { + WebhookRouterRuleInternal webhookRouterRule = (WebhookRouterRuleInternal) rule; + return new WebhookRouterRule() + .setWebhookUri(webhookRouterRule.getWebhookUri()) + .setClientCredential(new OAuth2WebhookClientCredential() + .setClientId(webhookRouterRule.getClientCredential().getClientId()) + .setClientSecret(webhookRouterRule.getClientCredential().getClientSecret())) + .setAuthorizationServerUri(webhookRouterRule.getAuthorizationServerUri()); + } + + return null; + } + + public static RouterRuleInternal convertRouterRuleToInternal(RouterRule rule) { + if (rule instanceof DirectMapRouterRule) { + return new DirectMapRouterRuleInternal(); + } else if (rule instanceof ExpressionRouterRule) { + return new ExpressionRouterRuleInternal(((ExpressionRouterRule) rule).getExpression()) + .setLanguage(ExpressionRouterRuleLanguage.POWER_FX); + } else if (rule instanceof FunctionRouterRule) { + FunctionRouterRule functionRouterRule = (FunctionRouterRule) rule; + return new FunctionRouterRuleInternal(functionRouterRule.getFunctionUri()) + .setCredential(new FunctionRouterRuleCredential() + .setFunctionKey(functionRouterRule.getCredential().getFunctionKey()) + .setAppKey(functionRouterRule.getCredential().getAppKey()) + .setClientId(functionRouterRule.getCredential().getClientId())); + } else if (rule instanceof StaticRouterRule) { + return new StaticRouterRuleInternal().setValue(RouterValueAdapter.getValue(((StaticRouterRule) rule).getValue())); + } else if (rule instanceof WebhookRouterRule) { + WebhookRouterRule webhookRouterRule = (WebhookRouterRule) rule; + return new WebhookRouterRuleInternal().setWebhookUri(webhookRouterRule.getWebhookUri()) + .setClientCredential(new OAuth2WebhookClientCredential() + .setClientId(webhookRouterRule.getClientCredential().getClientId()) + .setClientSecret(webhookRouterRule.getClientCredential().getClientSecret())) + .setAuthorizationServerUri(webhookRouterRule.getAuthorizationServerUri()); + } + + return null; + } } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/BestWorkerModeInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/BestWorkerModeInternal.java new file mode 100644 index 0000000000000..551af62ce51ad --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/BestWorkerModeInternal.java @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.communication.jobrouter.implementation.models; + +import com.azure.communication.jobrouter.models.ScoringRuleOptions; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** Jobs are distributed to the worker with the strongest abilities available. */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind") +@JsonTypeName("best-worker") +@Fluent +public final class BestWorkerModeInternal extends DistributionModeInternal { + + /* + * Define a scoring rule to use, when calculating a score to determine the best worker. If not set, will use a + * default scoring formula that uses the number of job labels that the worker labels match, as well as the number + * of label selectors the worker labels match and/or exceed using a logistic function + * (https://en.wikipedia.org/wiki/Logistic_function). + */ + @Generated + @JsonProperty(value = "scoringRule") + private RouterRuleInternal scoringRule; + + /* + * Options to configure 'scoringRule'. If not set, default values are used. + */ + @Generated + @JsonProperty(value = "scoringRuleOptions") + private ScoringRuleOptions scoringRuleOptions; + + /** Creates an instance of BestWorkerMode class. */ + @Generated + public BestWorkerModeInternal() {} + + /** + * Get the scoringRule property: Define a scoring rule to use, when calculating a score to determine the best + * worker. If not set, will use a default scoring formula that uses the number of job labels that the worker labels + * match, as well as the number of label selectors the worker labels match and/or exceed using a logistic function + * (https://en.wikipedia.org/wiki/Logistic_function). + * + * @return the scoringRule value. + */ + @Generated + public RouterRuleInternal getScoringRule() { + return this.scoringRule; + } + + /** + * Set the scoringRule property: Define a scoring rule to use, when calculating a score to determine the best + * worker. If not set, will use a default scoring formula that uses the number of job labels that the worker labels + * match, as well as the number of label selectors the worker labels match and/or exceed using a logistic function + * (https://en.wikipedia.org/wiki/Logistic_function). + * + * @param scoringRule the scoringRule value to set. + * @return the BestWorkerMode object itself. + */ + @Generated + public BestWorkerModeInternal setScoringRule(RouterRuleInternal scoringRule) { + this.scoringRule = scoringRule; + return this; + } + + /** + * Get the scoringRuleOptions property: Options to configure 'scoringRule'. If not set, default values are used. + * + * @return the scoringRuleOptions value. + */ + @Generated + public ScoringRuleOptions getScoringRuleOptions() { + return this.scoringRuleOptions; + } + + /** + * Set the scoringRuleOptions property: Options to configure 'scoringRule'. If not set, default values are used. + * + * @param scoringRuleOptions the scoringRuleOptions value to set. + * @return the BestWorkerMode object itself. + */ + @Generated + public BestWorkerModeInternal setScoringRuleOptions(ScoringRuleOptions scoringRuleOptions) { + this.scoringRuleOptions = scoringRuleOptions; + return this; + } + + /** {@inheritDoc} */ + @Generated + @Override + public BestWorkerModeInternal setMinConcurrentOffers(Integer minConcurrentOffers) { + super.setMinConcurrentOffers(minConcurrentOffers); + return this; + } + + /** {@inheritDoc} */ + @Generated + @Override + public BestWorkerModeInternal setMaxConcurrentOffers(Integer maxConcurrentOffers) { + super.setMaxConcurrentOffers(maxConcurrentOffers); + return this; + } + + /** {@inheritDoc} */ + @Generated + @Override + public BestWorkerModeInternal setBypassSelectors(Boolean bypassSelectors) { + super.setBypassSelectors(bypassSelectors); + return this; + } +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/DistributionModeInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/DistributionModeInternal.java new file mode 100644 index 0000000000000..7ce735dd83d35 --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/DistributionModeInternal.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.communication.jobrouter.implementation.models; + +import com.azure.communication.jobrouter.models.BestWorkerMode; +import com.azure.communication.jobrouter.models.LongestIdleMode; +import com.azure.communication.jobrouter.models.RoundRobinMode; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** Abstract base class for defining a distribution mode. */ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.PROPERTY, + property = "kind", + defaultImpl = DistributionModeInternal.class) +@JsonTypeName("DistributionMode") +@JsonSubTypes({ + @JsonSubTypes.Type(name = "best-worker", value = BestWorkerModeInternal.class), + @JsonSubTypes.Type(name = "longest-idle", value = LongestIdleModeInternal.class), + @JsonSubTypes.Type(name = "round-robin", value = RoundRobinModeInternal.class) +}) +@Fluent +public class DistributionModeInternal { + + /* + * Governs the minimum desired number of active concurrent offers a job can have. + */ + @Generated + @JsonProperty(value = "minConcurrentOffers") + private Integer minConcurrentOffers; + + /* + * Governs the maximum number of active concurrent offers a job can have. + */ + @Generated + @JsonProperty(value = "maxConcurrentOffers") + private Integer maxConcurrentOffers; + + /* + * If set to true, then router will match workers to jobs even if they don't match label selectors. Warning: You + * may get workers that are not qualified for the job they are matched with if you set this variable to true. This + * flag is intended more for temporary usage. By default, set to false. + */ + @Generated + @JsonProperty(value = "bypassSelectors") + private Boolean bypassSelectors; + + /** Creates an instance of DistributionMode class. */ + @Generated + public DistributionModeInternal() {} + + /** + * Get the minConcurrentOffers property: Governs the minimum desired number of active concurrent offers a job can + * have. + * + * @return the minConcurrentOffers value. + */ + @Generated + public Integer getMinConcurrentOffers() { + return this.minConcurrentOffers; + } + + /** + * Set the minConcurrentOffers property: Governs the minimum desired number of active concurrent offers a job can + * have. + * + * @param minConcurrentOffers the minConcurrentOffers value to set. + * @return the DistributionMode object itself. + */ + @Generated + public DistributionModeInternal setMinConcurrentOffers(Integer minConcurrentOffers) { + this.minConcurrentOffers = minConcurrentOffers; + return this; + } + + /** + * Get the maxConcurrentOffers property: Governs the maximum number of active concurrent offers a job can have. + * + * @return the maxConcurrentOffers value. + */ + @Generated + public Integer getMaxConcurrentOffers() { + return this.maxConcurrentOffers; + } + + /** + * Set the maxConcurrentOffers property: Governs the maximum number of active concurrent offers a job can have. + * + * @param maxConcurrentOffers the maxConcurrentOffers value to set. + * @return the DistributionMode object itself. + */ + @Generated + public DistributionModeInternal setMaxConcurrentOffers(Integer maxConcurrentOffers) { + this.maxConcurrentOffers = maxConcurrentOffers; + return this; + } + + /** + * Get the bypassSelectors property: If set to true, then router will match workers to jobs even if they don't match + * label selectors. Warning: You may get workers that are not qualified for the job they are matched with if you set + * this variable to true. This flag is intended more for temporary usage. By default, set to false. + * + * @return the bypassSelectors value. + */ + @Generated + public Boolean isBypassSelectors() { + return this.bypassSelectors; + } + + /** + * Set the bypassSelectors property: If set to true, then router will match workers to jobs even if they don't match + * label selectors. Warning: You may get workers that are not qualified for the job they are matched with if you set + * this variable to true. This flag is intended more for temporary usage. By default, set to false. + * + * @param bypassSelectors the bypassSelectors value to set. + * @return the DistributionMode object itself. + */ + @Generated + public DistributionModeInternal setBypassSelectors(Boolean bypassSelectors) { + this.bypassSelectors = bypassSelectors; + return this; + } +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/DistributionPolicyInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/DistributionPolicyInternal.java index edc26c3cb8a7a..ff5a2abcc526f 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/DistributionPolicyInternal.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/DistributionPolicyInternal.java @@ -45,7 +45,7 @@ public final class DistributionPolicyInternal { */ @Generated @JsonProperty(value = "mode") - private DistributionMode mode; + private DistributionModeInternal mode; /** Creates an instance of DistributionPolicyInternal class. */ @Generated @@ -123,7 +123,7 @@ public DistributionPolicyInternal setOfferExpiresAfterSeconds(Double offerExpire * @return the mode value. */ @Generated - public DistributionMode getMode() { + public DistributionModeInternal getMode() { return this.mode; } @@ -134,7 +134,7 @@ public DistributionMode getMode() { * @return the DistributionPolicyInternal object itself. */ @Generated - public DistributionPolicyInternal setMode(DistributionMode mode) { + public DistributionPolicyInternal setMode(DistributionModeInternal mode) { this.mode = mode; return this; } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/LongestIdleModeInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/LongestIdleModeInternal.java new file mode 100644 index 0000000000000..2ae26a0321449 --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/LongestIdleModeInternal.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.communication.jobrouter.implementation.models; + +import com.azure.communication.jobrouter.models.DistributionMode; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** Jobs are directed to the worker who has been idle longest. */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind") +@JsonTypeName("longest-idle") +@Fluent +public final class LongestIdleModeInternal extends DistributionModeInternal { + + /** Creates an instance of LongestIdleMode class. */ + @Generated + public LongestIdleModeInternal() {} + + /** {@inheritDoc} */ + @Generated + @Override + public LongestIdleModeInternal setMinConcurrentOffers(Integer minConcurrentOffers) { + super.setMinConcurrentOffers(minConcurrentOffers); + return this; + } + + /** {@inheritDoc} */ + @Generated + @Override + public LongestIdleModeInternal setMaxConcurrentOffers(Integer maxConcurrentOffers) { + super.setMaxConcurrentOffers(maxConcurrentOffers); + return this; + } + + /** {@inheritDoc} */ + @Generated + @Override + public LongestIdleModeInternal setBypassSelectors(Boolean bypassSelectors) { + super.setBypassSelectors(bypassSelectors); + return this; + } +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RoundRobinModeInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RoundRobinModeInternal.java new file mode 100644 index 0000000000000..a5f2702b7b42f --- /dev/null +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RoundRobinModeInternal.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. +package com.azure.communication.jobrouter.implementation.models; + +import com.azure.communication.jobrouter.models.DistributionMode; +import com.azure.core.annotation.Fluent; +import com.azure.core.annotation.Generated; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * Jobs are distributed in order to workers, starting with the worker that is after the last worker to receive a job. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind") +@JsonTypeName("round-robin") +@Fluent +public final class RoundRobinModeInternal extends DistributionModeInternal { + + /** Creates an instance of RoundRobinMode class. */ + @Generated + public RoundRobinModeInternal() {} + + /** {@inheritDoc} */ + @Generated + @Override + public RoundRobinModeInternal setMinConcurrentOffers(Integer minConcurrentOffers) { + super.setMinConcurrentOffers(minConcurrentOffers); + return this; + } + + /** {@inheritDoc} */ + @Generated + @Override + public RoundRobinModeInternal setMaxConcurrentOffers(Integer maxConcurrentOffers) { + super.setMaxConcurrentOffers(maxConcurrentOffers); + return this; + } + + /** {@inheritDoc} */ + @Generated + @Override + public RoundRobinModeInternal setBypassSelectors(Boolean bypassSelectors) { + super.setBypassSelectors(bypassSelectors); + return this; + } +} diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/ClassificationPolicy.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/ClassificationPolicy.java index fe4ee945613b1..7a928b873ffad 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/ClassificationPolicy.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/ClassificationPolicy.java @@ -3,10 +3,15 @@ // Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.communication.jobrouter.models; +import com.azure.communication.jobrouter.implementation.accesshelpers.ClassificationPolicyConstructorProxy; +import com.azure.communication.jobrouter.implementation.converters.LabelSelectorAdapter; +import com.azure.communication.jobrouter.implementation.converters.RouterRuleAdapter; +import com.azure.communication.jobrouter.implementation.models.ClassificationPolicyInternal; import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; +import java.util.stream.Collectors; /** A container for the rules that govern how jobs are classified. */ @Fluent @@ -56,6 +61,29 @@ public final class ClassificationPolicy { @Generated public ClassificationPolicy() {} + /** + * Package-private constructor of the class, used internally. + * + * @param internal The internal ClassificationPolicy + */ + ClassificationPolicy(ClassificationPolicyInternal internal) { + id = internal.getId(); + + setName(internal.getName()); + setPrioritizationRule(RouterRuleAdapter.convertRouterRuleToPublic(internal.getPrioritizationRule())); + setFallbackQueueId(internal.getFallbackQueueId()); + setQueueSelectorAttachments(internal.getQueueSelectorAttachments().stream() + .map(LabelSelectorAdapter::convertQueueSelectorAttachmentToPublic) + .collect(Collectors.toList())); + setWorkerSelectorAttachments(internal.getWorkerSelectorAttachments().stream() + .map(LabelSelectorAdapter::convertWorkerSelectorAttachmentToPublic) + .collect(Collectors.toList())); + } + + static { + ClassificationPolicyConstructorProxy.setAccessor(ClassificationPolicy::new); + } + /** * Get the id property: Unique identifier of this policy. * diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/DistributionPolicy.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/DistributionPolicy.java index a353b942182a7..6af241feae0a2 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/DistributionPolicy.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/DistributionPolicy.java @@ -3,6 +3,9 @@ // Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.communication.jobrouter.models; +import com.azure.communication.jobrouter.implementation.accesshelpers.DistributionPolicyConstructorProxy; +import com.azure.communication.jobrouter.implementation.converters.DistributionPolicyAdapter; +import com.azure.communication.jobrouter.implementation.models.DistributionPolicyInternal; import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; import com.fasterxml.jackson.annotation.JsonProperty; @@ -44,6 +47,23 @@ public final class DistributionPolicy { @Generated public DistributionPolicy() {} + /** + * Package-private constructor of the class, used internally. + * + * @param internal The internal DistributionPolicy + */ + DistributionPolicy(DistributionPolicyInternal internal) { + id = internal.getId(); + + setName(internal.getName()); + setMode(DistributionPolicyAdapter.convertDistributionModeToPublic(internal.getMode())); + setOfferExpiresAfter(Duration.ofSeconds(internal.getOfferExpiresAfterSeconds().longValue())); + } + + static { + DistributionPolicyConstructorProxy.setAccessor(internal -> new DistributionPolicy(internal)); + } + /** * Get the id property: The unique identifier of the policy. * diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/ExceptionPolicy.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/ExceptionPolicy.java index 63c521f739ed1..f7b0ef1014bb1 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/ExceptionPolicy.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/ExceptionPolicy.java @@ -3,6 +3,9 @@ // Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.communication.jobrouter.models; +import com.azure.communication.jobrouter.implementation.accesshelpers.ExceptionPolicyConstructorProxy; +import com.azure.communication.jobrouter.implementation.converters.ExceptionPolicyAdapter; +import com.azure.communication.jobrouter.implementation.models.ExceptionPolicyInternal; import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; import com.fasterxml.jackson.annotation.JsonProperty; @@ -108,4 +111,20 @@ public ExceptionPolicy setExceptionRules(List exceptionRules) { this.exceptionRules = exceptionRules; return this; } + + /** + * Package-private constructor of the class, used internally. + * + * @param internal The internal ExceptionPolicy + */ + ExceptionPolicy(ExceptionPolicyInternal internal) { + id = internal.getId(); + + setName(internal.getName()); + setExceptionRules(ExceptionPolicyAdapter.convertExceptionRulesToPublic(internal.getExceptionRules())); + } + + static { + ExceptionPolicyConstructorProxy.setAccessor(internal -> new ExceptionPolicy(internal)); + } } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterJob.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterJob.java index 2ed4a34f6f7c1..94e4ef72e286f 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterJob.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterJob.java @@ -3,12 +3,18 @@ // Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.communication.jobrouter.models; +import com.azure.communication.jobrouter.implementation.accesshelpers.RouterJobConstructorProxy; +import com.azure.communication.jobrouter.implementation.accesshelpers.RouterValueConstructorProxy; +import com.azure.communication.jobrouter.implementation.converters.JobAdapter; +import com.azure.communication.jobrouter.implementation.converters.LabelSelectorAdapter; +import com.azure.communication.jobrouter.implementation.models.RouterJobInternal; import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; import com.fasterxml.jackson.annotation.JsonProperty; import java.time.OffsetDateTime; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** A unit of work to be routed. */ @Fluent @@ -150,6 +156,45 @@ public final class RouterJob { @Generated public RouterJob() {} + /** + * Package-private constructor of the class, used internally. + * + * @param internal The internal RouterJob + */ + RouterJob(RouterJobInternal internal) { + id = internal.getId(); + requestedWorkerSelectors = internal.getRequestedWorkerSelectors().stream() + .map(ws -> LabelSelectorAdapter.convertWorkerSelectorToPublic(ws)) + .collect(Collectors.toList()); + attachedWorkerSelectors = internal.getAttachedWorkerSelectors().stream() + .map(ws -> LabelSelectorAdapter.convertWorkerSelectorToPublic(ws)) + .collect(Collectors.toList()); + assignments = internal.getAssignments().entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue())); + status = RouterJobStatus.fromString(internal.getStatus().toString()); + enqueuedAt = internal.getEnqueuedAt(); + scheduledAt = internal.getScheduledAt(); + + setChannelId(internal.getChannelId()); + setChannelReference(internal.getChannelReference()); + setQueueId(internal.getQueueId()); + setLabels(internal.getLabels().entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getKey, entry -> RouterValueConstructorProxy.create(entry.getValue())))); + setNotes(internal.getNotes()); + setPriority(internal.getPriority()); + setClassificationPolicyId(internal.getClassificationPolicyId()); + setDispositionCode(internal.getDispositionCode()); + setClassificationPolicyId(internal.getClassificationPolicyId()); + setTags(internal.getTags().entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getKey, entry -> RouterValueConstructorProxy.create(entry.getValue())))); + setMatchingMode(internal.getMatchingMode()); + } + + static { + RouterJobConstructorProxy.setAccessor(internal -> new RouterJob(internal)); + } + + /** * Get the id property: The id of the job. * diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterWorker.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterWorker.java index 5dd6aeac993f3..343d8ffad85b4 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterWorker.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterWorker.java @@ -3,11 +3,16 @@ // Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.communication.jobrouter.models; +import com.azure.communication.jobrouter.implementation.accesshelpers.RouterValueConstructorProxy; +import com.azure.communication.jobrouter.implementation.accesshelpers.RouterWorkerConstructorProxy; +import com.azure.communication.jobrouter.implementation.converters.WorkerAdapter; +import com.azure.communication.jobrouter.implementation.models.RouterWorkerInternal; import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** An entity for jobs to be routed to. */ @Fluent @@ -73,6 +78,33 @@ public final class RouterWorker { @Generated public RouterWorker() {} + /** + * Package-private constructor of the class, used internally. + * + * @param internal The internal RouterWorker + */ + RouterWorker(RouterWorkerInternal internal) { + id = internal.getId(); + state = RouterWorkerState.fromString(internal.getState().toString()); + offers = internal.getOffers(); + assignedJobs = internal.getAssignedJobs(); + loadRatio = internal.getLoadRatio(); + + setLabels(internal.getLabels().entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getKey, entry -> RouterValueConstructorProxy.create(entry.getValue())))); + setTags(internal.getTags().entrySet().stream() + .collect(Collectors.toMap(Map.Entry::getKey, entry -> RouterValueConstructorProxy.create(entry.getValue())))); + setQueues(internal.getQueues()); + setAvailableForOffers(internal.isAvailableForOffers()); + setChannels(internal.getChannels()); + setCapacity(internal.getCapacity()); + } + + static { + RouterWorkerConstructorProxy.setAccessor(internal -> new RouterWorker(internal)); + } + + /** * Get the id property: Id of the worker. * From e89c19b000ea5fc96ae9792baa9027e08a483518 Mon Sep 17 00:00:00 2001 From: Charandeep Parisineti Date: Sun, 5 Nov 2023 13:39:45 -0800 Subject: [PATCH 09/12] Fix tests --- .../azure-communication-jobrouter/assets.json | 2 +- .../jobrouter/JobRouterAdministrationClient.java | 11 ++++++++--- .../communication/jobrouter/JobRouterClient.java | 6 ++++-- .../converters/LabelSelectorAdapter.java | 3 ++- .../communication/jobrouter/models/RouterQueue.java | 11 ----------- .../communication/jobrouter/models/RouterValue.java | 8 ++++---- .../RouterQueueLiveTests.java | 1 + 7 files changed, 20 insertions(+), 22 deletions(-) diff --git a/sdk/communication/azure-communication-jobrouter/assets.json b/sdk/communication/azure-communication-jobrouter/assets.json index acd05be199050..d3ed2fc039706 100644 --- a/sdk/communication/azure-communication-jobrouter/assets.json +++ b/sdk/communication/azure-communication-jobrouter/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "java", "TagPrefix": "java/communication/azure-communication-jobrouter", - "Tag": "java/communication/azure-communication-jobrouter_ff2a44a5d4" + "Tag": "java/communication/azure-communication-jobrouter_7760fda1a6" } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterAdministrationClient.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterAdministrationClient.java index 4e049029e721b..db80ae29c85ab 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterAdministrationClient.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterAdministrationClient.java @@ -4,6 +4,7 @@ package com.azure.communication.jobrouter; import com.azure.communication.jobrouter.implementation.JobRouterAdministrationClientImpl; +import com.azure.communication.jobrouter.implementation.accesshelpers.ClassificationPolicyConstructorProxy; import com.azure.communication.jobrouter.implementation.accesshelpers.RouterQueueConstructorProxy; import com.azure.communication.jobrouter.implementation.converters.ClassificationPolicyAdapter; import com.azure.communication.jobrouter.implementation.converters.DistributionPolicyAdapter; @@ -32,6 +33,7 @@ import com.azure.core.http.rest.PagedIterable; import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; import com.azure.core.util.BinaryData; /** Initializes a new instance of the synchronous JobRouterAdministrationClient type. */ @@ -481,9 +483,10 @@ public Response createClassificationPolicyWithResponse( public ClassificationPolicy createClassificationPolicy( CreateClassificationPolicyOptions createClassificationPolicyOptions) { RequestOptions requestOptions = new RequestOptions(); - return this.createClassificationPolicyWithResponse(createClassificationPolicyOptions, requestOptions) + ClassificationPolicyInternal internal = this.createClassificationPolicyWithResponse(createClassificationPolicyOptions, requestOptions) .getValue() - .toObject(ClassificationPolicy.class); + .toObject(ClassificationPolicyInternal.class); + return ClassificationPolicyConstructorProxy.create(internal); } /** @@ -989,8 +992,10 @@ public Response updateQueueWithResponse( String id, BinaryData resource, RequestOptions requestOptions) { RouterQueue routerQueue = BinaryData.fromObject(resource).toObject(RouterQueue.class); RouterQueueInternal routerQueueInternal = QueueAdapter.convertRouterQueueToRouterQueueInternal(routerQueue); - return this.serviceClient.upsertQueueWithResponse( + Response response = this.serviceClient.upsertQueueWithResponse( id, BinaryData.fromObject(routerQueueInternal), requestOptions); + RouterQueueInternal internal = response.getValue().toObject(RouterQueueInternal.class); + return new SimpleResponse(response.getRequest(), response.getStatusCode(), response.getHeaders(), BinaryData.fromObject(RouterQueueConstructorProxy.create(internal))); } /** diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterClient.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterClient.java index 6acab743de603..f680655d7b955 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterClient.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/JobRouterClient.java @@ -4,6 +4,7 @@ package com.azure.communication.jobrouter; import com.azure.communication.jobrouter.implementation.JobRouterClientImpl; +import com.azure.communication.jobrouter.implementation.accesshelpers.RouterWorkerConstructorProxy; import com.azure.communication.jobrouter.implementation.converters.JobAdapter; import com.azure.communication.jobrouter.implementation.converters.WorkerAdapter; import com.azure.communication.jobrouter.implementation.models.RouterJobInternal; @@ -1059,9 +1060,10 @@ public Response createWorkerWithResponse( @ServiceMethod(returns = ReturnType.SINGLE) public RouterWorker createWorker(CreateWorkerOptions createWorkerOptions) { RequestOptions requestOptions = new RequestOptions(); - return this.createWorkerWithResponse(createWorkerOptions, requestOptions) + RouterWorkerInternal internal = this.createWorkerWithResponse(createWorkerOptions, requestOptions) .getValue() - .toObject(RouterWorker.class); + .toObject(RouterWorkerInternal.class); + return RouterWorkerConstructorProxy.create(internal); } /** diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/LabelSelectorAdapter.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/LabelSelectorAdapter.java index 8cb6209baea00..bcd48d69d477a 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/LabelSelectorAdapter.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/LabelSelectorAdapter.java @@ -144,7 +144,8 @@ public static RouterWorkerSelector convertWorkerSelectorToPublic(RouterWorkerSel LabelOperator.fromString(ws.getLabelOperator().toString())) .setValue(RouterValueConstructorProxy.create(ws)) .setExpedite(ws.isExpedite()) - .setExpiresAfter(Duration.ofSeconds(ws.getExpiresAfterSeconds().longValue())); + .setExpiresAfter(ws.getExpiresAfterSeconds() != null ? + Duration.ofSeconds(ws.getExpiresAfterSeconds().longValue()) : null); return workerSelector; } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterQueue.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterQueue.java index 27818cf4244b8..4940faa56ec9b 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterQueue.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterQueue.java @@ -78,17 +78,6 @@ public final class RouterQueue { @Generated public RouterQueue() {} - /** - * Jsoncreator. - * @param id id - * @param etag etag. - */ - @JsonCreator - public RouterQueue(String id, String etag) { - this.id = id; - this.etag = etag; - } - /** * Get the id property: The Id of this queue. * diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterValue.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterValue.java index 7299cd921c0dc..1a9f79bbacf59 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterValue.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterValue.java @@ -24,25 +24,25 @@ public final class RouterValue { /** * String Value to pass to server. */ - @JsonProperty(value = "stringValue", access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "stringValue", access = JsonProperty.Access.READ_WRITE) private String stringValue; /** * Integer Value to pass to server. */ - @JsonProperty(value = "intValue", access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "intValue", access = JsonProperty.Access.READ_WRITE) private Integer intValue; /** * Double Value to pass to server. */ - @JsonProperty(value = "doubleValue", access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "doubleValue", access = JsonProperty.Access.READ_WRITE) private Double doubleValue; /** * Boolean Value to pass to server. */ - @JsonProperty(value = "boolValue", access = JsonProperty.Access.WRITE_ONLY) + @JsonProperty(value = "boolValue", access = JsonProperty.Access.READ_WRITE) private Boolean boolValue; /** diff --git a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterQueueLiveTests.java b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterQueueLiveTests.java index 7f4943ed93ae4..fc710793092e4 100644 --- a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterQueueLiveTests.java +++ b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterQueueLiveTests.java @@ -64,6 +64,7 @@ public void updateQueue(HttpClient httpClient) { // Action RouterQueue updatedRouterQueue = queue.setLabels(updatedQueueLabels); + BinaryData resource = BinaryData.fromObject(updatedRouterQueue); queue = routerAdminClient.updateQueueWithResponse(queueId, BinaryData.fromObject(updatedRouterQueue), new RequestOptions()) .getValue().toObject(RouterQueue.class); From 343fe5e220fb2b35970819d47fef583e49b11cb7 Mon Sep 17 00:00:00 2001 From: Charandeep Parisineti Date: Sun, 5 Nov 2023 14:04:34 -0800 Subject: [PATCH 10/12] Fix build --- .../azure/communication/jobrouter/models/RouterJob.java | 2 +- .../communication/jobrouter/models/RouterValue.java | 9 ++++++++- .../communication/jobrouter/models/RouterWorker.java | 2 +- .../jobrouter/models/WaitTimeExceptionTrigger.java | 1 - 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterJob.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterJob.java index 94e4ef72e286f..a81e2b63829ed 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterJob.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterJob.java @@ -5,12 +5,12 @@ import com.azure.communication.jobrouter.implementation.accesshelpers.RouterJobConstructorProxy; import com.azure.communication.jobrouter.implementation.accesshelpers.RouterValueConstructorProxy; -import com.azure.communication.jobrouter.implementation.converters.JobAdapter; import com.azure.communication.jobrouter.implementation.converters.LabelSelectorAdapter; import com.azure.communication.jobrouter.implementation.models.RouterJobInternal; import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; import com.fasterxml.jackson.annotation.JsonProperty; + import java.time.OffsetDateTime; import java.util.List; import java.util.Map; diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterValue.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterValue.java index 1a9f79bbacf59..c2c7e2205e9c4 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterValue.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterValue.java @@ -47,7 +47,10 @@ public final class RouterValue { /** * Constructor - * + * @param stringValue stringValue. + * @param intValue intValue. + * @param doubleValue doubleValue. + * @param boolValue boolValue. */ @JsonCreator public RouterValue(@JsonProperty(value = "stringValue") String stringValue, @@ -64,6 +67,10 @@ public RouterValue(@JsonProperty(value = "stringValue") String stringValue, RouterValueConstructorProxy.setAccessor(internal -> new RouterValue(internal)); } + /** + * Package-protected constructor. + * @param objectValue + */ RouterValue(Object objectValue) { if (objectValue.getClass() == String.class) { this.stringValue = (String) objectValue; diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterWorker.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterWorker.java index 343d8ffad85b4..5c77730a22055 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterWorker.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterWorker.java @@ -5,11 +5,11 @@ import com.azure.communication.jobrouter.implementation.accesshelpers.RouterValueConstructorProxy; import com.azure.communication.jobrouter.implementation.accesshelpers.RouterWorkerConstructorProxy; -import com.azure.communication.jobrouter.implementation.converters.WorkerAdapter; import com.azure.communication.jobrouter.implementation.models.RouterWorkerInternal; import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; import com.fasterxml.jackson.annotation.JsonProperty; + import java.util.List; import java.util.Map; import java.util.stream.Collectors; diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/WaitTimeExceptionTrigger.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/WaitTimeExceptionTrigger.java index 067d605881715..b91afe3449fbc 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/WaitTimeExceptionTrigger.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/WaitTimeExceptionTrigger.java @@ -3,7 +3,6 @@ // Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.communication.jobrouter.models; -import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; From be1e842f9e2fed7df16aaae99f1d8e6057ef1815 Mon Sep 17 00:00:00 2001 From: Charandeep Parisineti Date: Sun, 5 Nov 2023 17:10:37 -0800 Subject: [PATCH 11/12] Remove unused import --- .../jobrouter/implementation/models/LongestIdleModeInternal.java | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/LongestIdleModeInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/LongestIdleModeInternal.java index 2ae26a0321449..496e5af1b33db 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/LongestIdleModeInternal.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/LongestIdleModeInternal.java @@ -3,7 +3,6 @@ // Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.communication.jobrouter.implementation.models; -import com.azure.communication.jobrouter.models.DistributionMode; import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; import com.fasterxml.jackson.annotation.JsonTypeInfo; From 5a16768d4cdfa4eff930953ac359f072695da709 Mon Sep 17 00:00:00 2001 From: Charandeep Parisineti Date: Mon, 6 Nov 2023 07:39:15 -0800 Subject: [PATCH 12/12] Fix linting errors --- .../implementation/converters/ExceptionPolicyAdapter.java | 1 - .../jobrouter/implementation/converters/JobAdapter.java | 3 +-- .../implementation/converters/LabelSelectorAdapter.java | 4 ++-- .../models/ConditionalQueueSelectorAttachmentInternal.java | 2 +- .../models/ConditionalWorkerSelectorAttachmentInternal.java | 2 +- .../implementation/models/DistributionModeInternal.java | 3 --- .../implementation/models/DistributionPolicyInternal.java | 1 - .../implementation/models/ExceptionPolicyInternal.java | 1 - .../implementation/models/RoundRobinModeInternal.java | 1 - .../models/RuleEngineQueueSelectorAttachmentInternal.java | 1 - .../models/RuleEngineWorkerSelectorAttachmentInternal.java | 1 - .../com/azure/communication/jobrouter/models/RouterQueue.java | 2 +- .../com/azure/communication/jobrouter/models/RouterValue.java | 4 ++-- 13 files changed, 8 insertions(+), 18 deletions(-) diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/ExceptionPolicyAdapter.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/ExceptionPolicyAdapter.java index 141c85c8b7cf4..4f3cf8550107a 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/ExceptionPolicyAdapter.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/ExceptionPolicyAdapter.java @@ -26,7 +26,6 @@ import java.time.Duration; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/JobAdapter.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/JobAdapter.java index 228cb32500f47..793e962facd55 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/JobAdapter.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/JobAdapter.java @@ -6,10 +6,9 @@ import com.azure.communication.jobrouter.implementation.models.RouterJobInternal; import com.azure.communication.jobrouter.implementation.models.RouterWorkerSelectorInternal; import com.azure.communication.jobrouter.models.CreateJobOptions; -import com.azure.communication.jobrouter.models.RouterJobAssignment; -import com.azure.communication.jobrouter.models.RouterValue; import com.azure.communication.jobrouter.models.RouterJob; import com.azure.communication.jobrouter.models.RouterJobNote; +import com.azure.communication.jobrouter.models.RouterValue; import java.util.List; import java.util.Map; diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/LabelSelectorAdapter.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/LabelSelectorAdapter.java index bcd48d69d477a..95f36e51ef741 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/LabelSelectorAdapter.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/converters/LabelSelectorAdapter.java @@ -144,8 +144,8 @@ public static RouterWorkerSelector convertWorkerSelectorToPublic(RouterWorkerSel LabelOperator.fromString(ws.getLabelOperator().toString())) .setValue(RouterValueConstructorProxy.create(ws)) .setExpedite(ws.isExpedite()) - .setExpiresAfter(ws.getExpiresAfterSeconds() != null ? - Duration.ofSeconds(ws.getExpiresAfterSeconds().longValue()) : null); + .setExpiresAfter(ws.getExpiresAfterSeconds() != null + ? Duration.ofSeconds(ws.getExpiresAfterSeconds().longValue()) : null); return workerSelector; } diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ConditionalQueueSelectorAttachmentInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ConditionalQueueSelectorAttachmentInternal.java index 6b60e94cc6e98..483cbc82b7332 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ConditionalQueueSelectorAttachmentInternal.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ConditionalQueueSelectorAttachmentInternal.java @@ -3,13 +3,13 @@ // Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.communication.jobrouter.implementation.models; -import com.azure.communication.jobrouter.models.RouterRule; import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; + import java.util.List; /** Describes a set of queue selectors that will be attached if the given condition resolves to true. */ diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ConditionalWorkerSelectorAttachmentInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ConditionalWorkerSelectorAttachmentInternal.java index aa0a823059c43..0d13e77b839fb 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ConditionalWorkerSelectorAttachmentInternal.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ConditionalWorkerSelectorAttachmentInternal.java @@ -3,13 +3,13 @@ // Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.communication.jobrouter.implementation.models; -import com.azure.communication.jobrouter.models.RouterRule; import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; + import java.util.List; /** Describes a set of worker selectors that will be attached if the given condition resolves to true. */ diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/DistributionModeInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/DistributionModeInternal.java index 7ce735dd83d35..3bbe26d918285 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/DistributionModeInternal.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/DistributionModeInternal.java @@ -3,9 +3,6 @@ // Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.communication.jobrouter.implementation.models; -import com.azure.communication.jobrouter.models.BestWorkerMode; -import com.azure.communication.jobrouter.models.LongestIdleMode; -import com.azure.communication.jobrouter.models.RoundRobinMode; import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/DistributionPolicyInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/DistributionPolicyInternal.java index ff5a2abcc526f..0d53cb9d2fa95 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/DistributionPolicyInternal.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/DistributionPolicyInternal.java @@ -3,7 +3,6 @@ // Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.communication.jobrouter.implementation.models; -import com.azure.communication.jobrouter.models.DistributionMode; import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ExceptionPolicyInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ExceptionPolicyInternal.java index 8dc98f9a66521..1a08f142860e6 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ExceptionPolicyInternal.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/ExceptionPolicyInternal.java @@ -3,7 +3,6 @@ // Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.communication.jobrouter.implementation.models; -import com.azure.communication.jobrouter.models.ExceptionRule; import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RoundRobinModeInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RoundRobinModeInternal.java index a5f2702b7b42f..53ce4dbaca5f8 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RoundRobinModeInternal.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RoundRobinModeInternal.java @@ -3,7 +3,6 @@ // Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.communication.jobrouter.implementation.models; -import com.azure.communication.jobrouter.models.DistributionMode; import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; import com.fasterxml.jackson.annotation.JsonTypeInfo; diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RuleEngineQueueSelectorAttachmentInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RuleEngineQueueSelectorAttachmentInternal.java index 5029c773d5f9a..372bf0762550f 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RuleEngineQueueSelectorAttachmentInternal.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RuleEngineQueueSelectorAttachmentInternal.java @@ -3,7 +3,6 @@ // Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.communication.jobrouter.implementation.models; -import com.azure.communication.jobrouter.models.RouterRule; import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; import com.fasterxml.jackson.annotation.JsonCreator; diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RuleEngineWorkerSelectorAttachmentInternal.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RuleEngineWorkerSelectorAttachmentInternal.java index 6f42388906b92..649b1c0911324 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RuleEngineWorkerSelectorAttachmentInternal.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/implementation/models/RuleEngineWorkerSelectorAttachmentInternal.java @@ -3,7 +3,6 @@ // Code generated by Microsoft (R) AutoRest Code Generator. package com.azure.communication.jobrouter.implementation.models; -import com.azure.communication.jobrouter.models.RouterRule; import com.azure.core.annotation.Generated; import com.azure.core.annotation.Immutable; import com.fasterxml.jackson.annotation.JsonCreator; diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterQueue.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterQueue.java index 4940faa56ec9b..d1e7b7a08c87f 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterQueue.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterQueue.java @@ -8,8 +8,8 @@ import com.azure.communication.jobrouter.implementation.models.RouterQueueInternal; import com.azure.core.annotation.Fluent; import com.azure.core.annotation.Generated; -import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; + import java.util.Map; import java.util.stream.Collectors; diff --git a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterValue.java b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterValue.java index c2c7e2205e9c4..2ae51ba81a40f 100644 --- a/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterValue.java +++ b/sdk/communication/azure-communication-jobrouter/src/main/java/com/azure/communication/jobrouter/models/RouterValue.java @@ -69,7 +69,7 @@ public RouterValue(@JsonProperty(value = "stringValue") String stringValue, /** * Package-protected constructor. - * @param objectValue + * @param objectValue objectValue. */ RouterValue(Object objectValue) { if (objectValue.getClass() == String.class) { @@ -83,7 +83,7 @@ public RouterValue(@JsonProperty(value = "stringValue") String stringValue, } if (objectValue.getClass() == Boolean.class) { this.boolValue = (Boolean) objectValue; - } + } } /**