/** * Gets a {@link URL} to call methods for a specific version of a {@link Service}. * * @param service {@link ServiceId} of the service * @return a URL to call methods of the service * @throws NotFoundException @throws NotFoundException if the app or service could not be found * @throws IOException if a network error occurred * @throws UnauthenticatedException if the request is not authorized successfully in the gateway server */ public URL getVersionedServiceURL(ServiceId service) throws NotFoundException, IOException, UnauthenticatedException, UnauthorizedException { // Make sure the service actually exists get(service); return config.resolveNamespacedURLV3(service.getNamespaceId(), String.format("apps/%s/versions/%s/services/%s/methods/", service.getApplication(), service.getVersion(), service.getEntityName())); }
/** * Checks whether the {@link Service} is active. * * @param service ID of the service * @throws IOException if a network error occurred * @throws UnauthenticatedException if the request is not authorized successfully in the gateway server * @throws NotFoundException if the app or service could not be found * @throws ServiceUnavailableException if the service is not available */ public void checkAvailability(ServiceId service) throws IOException, UnauthenticatedException, NotFoundException, ServiceUnavailableException, UnauthorizedException { URL url = config.resolveNamespacedURLV3(service.getNamespaceId(), String.format("apps/%s/versions/%s/services/%s/available", service.getApplication(), service.getVersion(), service.getProgram())); HttpResponse response = restClient.execute(HttpMethod.GET, url, config.getAccessToken(), HttpURLConnection.HTTP_NOT_FOUND, HttpURLConnection.HTTP_BAD_REQUEST, HttpURLConnection.HTTP_UNAVAILABLE); if (response.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { throw new NotFoundException(service); } if (response.getResponseCode() == HttpURLConnection.HTTP_UNAVAILABLE) { throw new ServiceUnavailableException(service.getProgram()); } }