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

Update LUIS Authoring auto-gen'ed SDK files using latest specs. #2327

Merged
merged 3 commits into from
Aug 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/

package com.microsoft.azure.cognitiveservices.language.luis.authoring;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.microsoft.rest.ExpandableStringEnum;

import java.util.Collection;

/**
* Defines values for LUIS endpoint API.
*/
public final class EndpointAPI extends ExpandableStringEnum<EndpointAPI> {
/** Static value US_WEST for EndpointAPI. */
public static final EndpointAPI US_WEST = fromString("westus.api.cognitive.microsoft.com");

/** Static value US_WEST2 for EndpointAPI. */
public static final EndpointAPI US_WEST2 = fromString("westus2.api.cognitive.microsoft.com");

/** Static value US_EAST for EndpointAPI. */
public static final EndpointAPI US_EAST = fromString("eastus.api.cognitive.microsoft.com");

/** Static value US_EAST2 for EndpointAPI. */
public static final EndpointAPI US_EAST2 = fromString("eastus2.api.cognitive.microsoft.com");

/** Static value US_WEST_CENTRAL for EndpointAPI. */
public static final EndpointAPI US_WEST_CENTRAL = fromString("westcentralus.api.cognitive.microsoft.com");

/** Static value US_SOUTH_CENTRAL for EndpointAPI. */
public static final EndpointAPI US_SOUTH_CENTRAL = fromString("southcentralus.api.cognitive.microsoft.com");

/** Static value EUROPE_WEST for EndpointAPI. */
public static final EndpointAPI EUROPE_WEST = fromString("westeurope.api.cognitive.microsoft.com");

/** Static value EUROPE_NORTH for EndpointAPI. */
public static final EndpointAPI EUROPE_NORTH = fromString("northeurope.api.cognitive.microsoft.com");

/** Static value ASIA_SOUTHEAST for EndpointAPI. */
public static final EndpointAPI ASIA_SOUTHEAST = fromString("southeastasia.api.cognitive.microsoft.com");

/** Static value ASIA_EAST for EndpointAPI. */
public static final EndpointAPI ASIA_EAST = fromString("eastasia.api.cognitive.microsoft.com");

/** Static value AUSTRALIA_EAST for EndpointAPI. */
public static final EndpointAPI AUSTRALIA_EAST = fromString("australiaeast.api.cognitive.microsoft.com");

/** Static value BRAZIL_SOUTH for EndpointAPI. */
public static final EndpointAPI BRAZIL_SOUTH = fromString("brazilsouth.api.cognitive.microsoft.com");

/**
* Creates or finds a EndpointAPI from its string representation.
* @param name a name to look for
* @return the corresponding EndpointAPI
*/
@JsonCreator
public static EndpointAPI fromString(String name) {
return fromString(name, EndpointAPI.class);
}

/**
* @return known CatalogCollationType values
*/
public static Collection<EndpointAPI> values() {
return values(EndpointAPI.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ public interface LUISAuthoringClient {
*/
String userAgent();

/**
* Gets Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com)..
*
* @return the endpoint value.
*/
String endpoint();

/**
* Sets Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus.api.cognitive.microsoft.com)..
*
* @param endpoint the endpoint value.
* @return the service client itself
*/
LUISAuthoringClient withEndpoint(String endpoint);

/**
* Gets Gets or sets the preferred language for the response..
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import okhttp3.Response;

import java.io.IOException;
import java.net.URI;

/**
* Entry point to Azure Cognitive Services Language Understanding (LUIS) Authoring manager.
Expand All @@ -23,21 +24,23 @@ public class LUISAuthoringManager {
/**
* Initializes an instance of Language Understanding (LUIS) Authoring API client.
*
* @param subscriptionKey the Language Understanding (LUIS) Authoring API key
* @param endpointAPI the endpoint API
* @param luisAuthoringKey the Language Understanding (LUIS) Authoring API key (see https://www.luis.ai)
* @return the Language Understanding Authoring API client
*/
public static LUISAuthoringClient authenticate(String subscriptionKey) {
return authenticate("https://api.cognitive.microsoft.com/luis/api/v2.0/", subscriptionKey);
public static LUISAuthoringClient authenticate(EndpointAPI endpointAPI, String luisAuthoringKey) {
return authenticate(String.format("https://%s/luis/api/v2.0/", endpointAPI.toString()), luisAuthoringKey)
.withEndpoint(endpointAPI.toString());
}

/**
* Initializes an instance of Language Understanding (LUIS) Authoring API client.
*
* @param baseUrl the base URL of the service
* @param subscriptionKey the Language Understanding (LUIS) Authoring API key
* @param luisAuthoringKey the Language Understanding (LUIS) Authoring API key (see https://www.luis.ai)
* @return the Language Understanding (LUIS) Authoring API client
*/
public static LUISAuthoringClient authenticate(String baseUrl, final String subscriptionKey) {
public static LUISAuthoringClient authenticate(String baseUrl, final String luisAuthoringKey) {
ServiceClientCredentials serviceClientCredentials = new ServiceClientCredentials() {
@Override
public void applyCredentialsFilter(OkHttpClient.Builder builder) {
Expand All @@ -49,24 +52,34 @@ public Response intercept(Chain chain) throws IOException {
Request original = chain.request();
// Request customization: add request headers
Request.Builder requestBuilder = original.newBuilder()
.addHeader("Ocp-Apim-Subscription-Key", subscriptionKey);
.addHeader("Ocp-Apim-Subscription-Key", luisAuthoringKey);
request = requestBuilder.build();
return chain.proceed(request);
}
});
}
};
return authenticate(baseUrl, serviceClientCredentials);
String endpointAPI = null;
try {
URI uri = new URI(baseUrl);
endpointAPI = uri.getHost();
} catch (Exception e) {
endpointAPI = EndpointAPI.US_WEST.toString();
}
return authenticate(baseUrl, serviceClientCredentials)
.withEndpoint(endpointAPI);
}

/**
* Initializes an instance of Language Understanding (LUIS) Authoring API client.
*
* @param endpointAPI the endpoint API
* @param credentials the management credentials for Azure
* @return the Language Understanding (LUIS) Authoring API client
*/
public static LUISAuthoringClient authenticate(ServiceClientCredentials credentials) {
return authenticate("https://api.cognitive.microsoft.com/luis/api/v2.0/", credentials);
public static LUISAuthoringClient authenticate(EndpointAPI endpointAPI, ServiceClientCredentials credentials) {
return authenticate(String.format("https://%s/luis/api/v2.0/", endpointAPI), credentials)
.withEndpoint(endpointAPI.toString());
}

/**
Expand Down
Loading