/sdk/cognitiveservices/ms-azure-cs-customvision-prediction/src/main/java/com/microsoft/azure/cognitiveservices/vision/customvision/prediction/CustomVisionPredictionManager.java

http://github.com/WindowsAzure/azure-sdk-for-java · Java · 77 lines · 27 code · 7 blank · 43 comment · 0 complexity · 805c5da8a33a36eee70a6870d115915c MD5 · raw file

  1. /**
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for
  4. * license information.
  5. */
  6. package com.microsoft.azure.cognitiveservices.vision.customvision.prediction;
  7. import com.microsoft.azure.cognitiveservices.vision.customvision.prediction.implementation.CustomVisionPredictionClientImpl;
  8. import com.microsoft.rest.RestClient;
  9. import com.microsoft.rest.credentials.ServiceClientCredentials;
  10. import okhttp3.OkHttpClient;
  11. /**
  12. * Entry point to Azure Cognitive Services Custom Vision Prediction manager.
  13. */
  14. public class CustomVisionPredictionManager {
  15. /**
  16. * Initializes an instance of Custom Vision Prediction API client.
  17. *
  18. * @param apiKey the Custom Vision Prediction API key
  19. * @return the Computer Vision API client
  20. */
  21. public static CustomVisionPredictionClient authenticate(String apiKey) {
  22. return authenticate("https://southcentralus.api.cognitive.microsoft.com/customvision/v2.0/Prediction/", apiKey);
  23. }
  24. /**
  25. * Initializes an instance of Custom Vision Prediction API client.
  26. *
  27. * @param baseUrl the base URL of the service
  28. * @param apiKey the Custom Vision Prediction API key
  29. * @return the Custom Vision Prediction API client
  30. */
  31. public static CustomVisionPredictionClient authenticate(String baseUrl, final String apiKey) {
  32. ServiceClientCredentials serviceClientCredentials = new ServiceClientCredentials() {
  33. @Override
  34. public void applyCredentialsFilter(OkHttpClient.Builder builder) {
  35. }
  36. };
  37. return authenticate(baseUrl, serviceClientCredentials, apiKey);
  38. }
  39. /**
  40. * Initializes an instance of Custom Vision Prediction API client.
  41. *
  42. * @param credentials the management credentials for Azure
  43. * @param apiKey the Custom Vision Prediction API key
  44. * @return the Computer Vision API client
  45. */
  46. public static CustomVisionPredictionClient authenticate(ServiceClientCredentials credentials, final String apiKey) {
  47. return authenticate("https://southcentralus.api.cognitive.microsoft.com/customvision/v2.0/Prediction/", credentials, apiKey);
  48. }
  49. /**
  50. * Initializes an instance of Custom Vision Prediction API client.
  51. *
  52. * @param baseUrl the base URL of the service
  53. * @param credentials the management credentials for Azure
  54. * @param apiKey the Custom Vision Prediction API key
  55. * @return the Custom Vision Prediction API client
  56. */
  57. public static CustomVisionPredictionClient authenticate(String baseUrl, ServiceClientCredentials credentials, final String apiKey) {
  58. return new CustomVisionPredictionClientImpl(baseUrl, credentials).withApiKey(apiKey);
  59. }
  60. /**
  61. * Initializes an instance of Custom Vision Prediction API client.
  62. *
  63. * @param restClient the REST client to connect to Azure.
  64. * @param apiKey the Custom Vision Prediction API key
  65. * @return the Custom Vision Prediction API client
  66. */
  67. public static CustomVisionPredictionClient authenticate(RestClient restClient, final String apiKey) {
  68. return new CustomVisionPredictionClientImpl(restClient).withApiKey(apiKey);
  69. }
  70. }