Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix externalmodels #37512

Merged
merged 12 commits into from
Nov 6, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -741,7 +742,7 @@ public Mono<Response<BinaryData>> updateExceptionPolicyWithResponse(
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<BinaryData>> createExceptionPolicyWithResponse(
CreateExceptionPolicyOptions createExceptionPolicyOptions, RequestOptions requestOptions) {
ExceptionPolicy exceptionPolicy =
ExceptionPolicyInternal exceptionPolicy =
ExceptionPolicyAdapter.convertCreateOptionsToExceptionPolicy(createExceptionPolicyOptions);
return upsertExceptionPolicyWithResponse(
createExceptionPolicyOptions.getExceptionPolicyId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
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;
import com.azure.communication.jobrouter.implementation.converters.ExceptionPolicyAdapter;
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;
Expand All @@ -30,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. */
Expand Down Expand Up @@ -479,9 +483,10 @@ public Response<BinaryData> 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);
}

/**
Expand Down Expand Up @@ -742,7 +747,7 @@ public Response<BinaryData> updateExceptionPolicyWithResponse(
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<BinaryData> createExceptionPolicyWithResponse(
CreateExceptionPolicyOptions createExceptionPolicyOptions, RequestOptions requestOptions) {
ExceptionPolicy exceptionPolicy =
ExceptionPolicyInternal exceptionPolicy =
ExceptionPolicyAdapter.convertCreateOptionsToExceptionPolicy(createExceptionPolicyOptions);
return this.serviceClient.upsertExceptionPolicyWithResponse(
createExceptionPolicyOptions.getExceptionPolicyId(),
Expand Down Expand Up @@ -974,7 +979,7 @@ Response<BinaryData> upsertQueueWithResponse(String queueId, BinaryData resource
* }</pre>
*
* @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.
Expand All @@ -984,10 +989,13 @@ Response<BinaryData> upsertQueueWithResponse(String queueId, BinaryData resource
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<BinaryData> 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(
Response<BinaryData> response = this.serviceClient.upsertQueueWithResponse(
id, BinaryData.fromObject(routerQueueInternal), requestOptions);
RouterQueueInternal internal = response.getValue().toObject(RouterQueueInternal.class);
return new SimpleResponse<BinaryData>(response.getRequest(), response.getStatusCode(), response.getHeaders(), BinaryData.fromObject(RouterQueueConstructorProxy.create(internal)));
}

/**
Expand Down Expand Up @@ -1020,7 +1028,9 @@ public Response<BinaryData> 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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1059,9 +1060,10 @@ public Response<BinaryData> 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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Loading
Loading