Load REST commands by calling describe command
@param restClient
@return JsonObject that contains all the descriptions of all REST commands
320761
private JsonObject loadRESTCommandsFromServer(RESTClient restClient) {
        RESTResponse response = null;
        try {
            response = restClient.sendRequest(HttpMethod.GET, _DESCRIBE_URI, ContentType.APPLICATION_JSON, null);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        if (!response.getCode().isError()) {
            JsonReader jsonReader = Json.createReader(new StringReader(response.getBody()));            
            JsonObject result = jsonReader.readObject().getJsonObject("commands");
            jsonReader.close();
            return result;
        }
        else {
            throw new RuntimeException("Describe command error: " + response.getBody());
        }
    }
639653
func (c *AutoscalingV1Client) RESTClient() rest.Interface {
	if c == nil {
		return nil
	}
	return c.restClient
}
476086
private Map<String, Object> jsonRepresentation() {
        final Map<String, Object> json = new HashMap<>(getProperties());
        json.put(META_PROP_TYPE, TYPE_BLOB);
        if (blobDigest != null) {
            json.put(PROP_DIGEST, blobDigest);
        }
        else {
            json.put(META_PROP_DATA, getContent());
        }
        return json;
    }
518047
public CommandOutput<?, ?> getResponse(List<Command> cmds) throws RestApiProcessingException {
    String url = cmds.get(0).getParams().get(0);

    log.info("URL: " + url);
    String jsonStr = null;
    HttpRequestBase httpRequest = new HttpGet(url);
    addHeaders(httpRequest);
    HttpEntity httpEntity = null;
    HttpResponse httpResponse = null;
    try {
      httpResponse = this.httpClient.execute(httpRequest);
      StatusLine status = httpResponse.getStatusLine();
      httpEntity = httpResponse.getEntity();

      if (httpEntity != null) {
        jsonStr = EntityUtils.toString(httpEntity);
      }

      if (status.getStatusCode() >= 400) {
        log.info("Unable to get response using: " + url);
        JsonElement jsonRet = GSON.fromJson(jsonStr, JsonArray.class);
        throw new RestApiProcessingException(getFirstErrorMessage("Failed to retrieve response from", jsonRet));
      }
    } catch (Exception e) {
      throw new RestApiProcessingException("Failed to process rest api request; error - " + e.getMessage(), e);
    } finally {
      try {
        if (httpEntity != null) {
          EntityUtils.consume(httpEntity);
        }
        // httpResponse.close();
      } catch (Exception e) {
        throw new RestApiProcessingException("Failed to consume httpEntity; error - " + e.getMessage(), e);
      }
    }
    CommandOutput<RestApiCommand, String> output = new RestApiCommandOutput();
    output.put((RestApiCommand) cmds.get(0), jsonStr);
    return output;
  }
22555
private TypeSpec generateBuilder( RestService restService ) {

        TypeSpec.Builder typeBuilder = TypeSpec.classBuilder( restService.getBuilderSimpleClassName() )
                .addModifiers( Modifier.PUBLIC, Modifier.FINAL )
                .addJavadoc( "Generated REST service builder for {@link $L}.\n", restService.getTypeElement().getQualifiedName() )
                .addMethod( MethodSpec.constructorBuilder().addModifiers( Modifier.PRIVATE ).build() );

        Map<TypeMirror, MethodSpec> mapperGetters = buildMappers( typeBuilder, restService );

        for ( RestServiceMethod method : restService.getMethods() ) {
            buildMethod( typeBuilder, mapperGetters, method );
        }

        return typeBuilder.build();
    }
1205187
public ClientInterface getRestClient(){
		if(restClient == null) {
			synchronized (this) {
				if(restClient == null) {
					restClient = ElasticSearchHelper.getRestClientUtil();
				}
			}
		}
		return restClient;
	}
507621
@Override
    public ResourceSet<Command> read(final TwilioRestClient client) {
        return new ResourceSet<>(this, client, firstPage(client));
    }
658539
private static RestClient buildRestClient(List<InetSocketTransportAddress> hosts, int threadCount, boolean sslEnabled,
      String keyStoreType, String keyStoreFilePassword, String identityFilepath, String trustStoreType,
      String trustStoreFilePassword, String cacertsFilepath) throws Exception {


    HttpHost[] httpHosts = new HttpHost[hosts.size()];
    String scheme = sslEnabled?"https":"http";
    for (int h = 0; h < httpHosts.length; h++) {
      InetSocketTransportAddress host = hosts.get(h);
      httpHosts[h] = new HttpHost(host.getAddress(), host.getPort(), scheme);
    }

    RestClientBuilder builder = RestClient.builder(httpHosts);

    if (sslEnabled) {
      log.info("ssl configuration: trustStoreType = {}, cacertsFilePath = {}", trustStoreType, cacertsFilepath);
      KeyStore truststore = KeyStore.getInstance(trustStoreType);
      FileInputStream trustInputStream = new FileInputStream(cacertsFilepath);
      try {
        truststore.load(trustInputStream, trustStoreFilePassword.toCharArray());
      }
      finally {
        trustInputStream.close();
      }
      SSLContextBuilder sslBuilder = SSLContexts.custom().loadTrustMaterial(truststore, null);

      log.info("ssl key configuration: keyStoreType = {}, keyFilePath = {}", keyStoreType, identityFilepath);

      KeyStore keystore = KeyStore.getInstance(keyStoreType);
      FileInputStream keyInputStream = new FileInputStream(identityFilepath);
      try {
        keystore.load(keyInputStream, keyStoreFilePassword.toCharArray());
      }
      finally {
        keyInputStream.close();
      }
      sslBuilder.loadKeyMaterial(keystore, keyStoreFilePassword.toCharArray());

      final SSLContext sslContext = sslBuilder.build();
      builder = builder.setHttpClientConfigCallback(httpAsyncClientBuilder -> httpAsyncClientBuilder
          // Set ssl context
          .setSSLContext(sslContext).setSSLHostnameVerifier(new NoopHostnameVerifier())
          // Configure number of threads for clients
          .setDefaultIOReactorConfig(IOReactorConfig.custom().setIoThreadCount(threadCount).build()));
    } else {
      builder = builder.setHttpClientConfigCallback(httpAsyncClientBuilder -> httpAsyncClientBuilder
          // Configure number of threads for clients
          .setDefaultIOReactorConfig(IOReactorConfig.custom().setIoThreadCount(threadCount).build()));
    }

    // Configure timeouts
    builder.setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder
        .setConnectionRequestTimeout(0)); // Important, otherwise the client has spurious timeouts

    return builder.build();
  }
1035478
private static void loadRepositoryDescription() {
        LOGGER.log(Level.INFO, "Loading repository description....");

        final InputStream inputStream = AbstractRepository.class.getResourceAsStream("/repository.json");

        if (null == inputStream) {
            LOGGER.log(Level.INFO, "Not found repository description [repository.json] file under classpath");
            return;
        }

        LOGGER.log(Level.INFO, "Parsing repository description....");

        try {
            final String description = IOUtils.toString(inputStream, "UTF-8");

            LOGGER.log(Level.DEBUG, "{0}{1}", new Object[]{Strings.LINE_SEPARATOR, description});

            repositoriesDescription = new JSONObject(description);

            // Repository name prefix
            final String tableNamePrefix = StringUtils.isNotBlank(Latkes.getLocalProperty("jdbc.tablePrefix"))
                    ? Latkes.getLocalProperty("jdbc.tablePrefix") + "_"
                    : "";

            final JSONArray repositories = repositoriesDescription.optJSONArray("repositories");

            for (int i = 0; i < repositories.length(); i++) {
                final JSONObject repository = repositories.optJSONObject(i);

                repository.put("name", tableNamePrefix + repository.optString("name"));
            }
        } catch (final Exception e) {
            LOGGER.log(Level.ERROR, "Parses repository description failed", e);
        } finally {
            try {
                inputStream.close();
            } catch (final IOException e) {
                LOGGER.log(Level.ERROR, e.getMessage(), e);
                throw new RuntimeException(e);
            }
        }
    }
807959
private Client getClient(){
        final ClientConfig cfg = new DefaultClientConfig();
        cfg.getClasses().add(com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider.class);
        cfg.getProperties().put(ClientConfig.PROPERTY_CONNECT_TIMEOUT, timeout);

        return Client.create(cfg);
    }
68930
func (c *OauthClient) RESTClient() rest.Interface {
	if c == nil {
		return nil
	}
	return c.restClient
}
798008
func (c *ApiregistrationClient) RESTClient() rest.Interface {
	if c == nil {
		return nil
	}
	return c.restClient
}
822510
public JSONResource json(URI anUri, AbstractContent requestContent) throws IOException {
		return doPOSTOrPUT(anUri, requestContent, createJSONResource());
	}
1282832
@Override
    public RestRepositories getRepositories(Request request) {
        RestRepositories repositories = new RestRepositories();
        for (String repositoryName : getRepositoryManager().getJcrRepositoryNames()) {
            addRepository(request, repositories, repositoryName);
        }
        return repositories;
    }
976001
private String getCDCQueryJson(CDCQuery cdcQuery) throws SerializationException {
		ObjectMapper mapper = getObjectMapper();
		String json = null;
		try {
			json = mapper.writeValueAsString(cdcQuery);
		} catch (Exception e) {
			throw new SerializationException(e);
		}

		return json;
	}
90774
@Override
    @Path("/{roleName}")
    @ApiOperation(value="Retrieve a role or all roles",
        notes="If roleName is not present, returns all roles.",
        response=Role.class, responseContainer="List")
    public JSONObject get(String path, Map<String,String> headers) throws ServiceException, JSONException {
        UserServices userServices = ServiceLocator.getUserServices();
        Map<String,String> parameters = getParameters(headers);
        try {
            String roleName = parameters.get("name");
            if (roleName == null) // use request path
                roleName = getSegment(path, 1);
            if (roleName != null) {
                Role role = userServices.getRole(roleName);
                if (role == null)
                    throw new ServiceException(HTTP_404_NOT_FOUND, "Role not found: " + roleName);
                return role.getJson();
            }
            else {
                return userServices.getRoles().getJson();
            }
        }
        catch (DataAccessException ex) {
            throw new ServiceException(ex.getMessage(), ex);
        }
    }
1157077
async def load(self, request, resource=None, **kwargs):
        """"""
        schema = self.get_schema(request, resource=resource, **kwargs)
        data = await self.parse(request)
        resource, errors = schema.load(
            data, partial=resource is not None, many=isinstance(data, list))
        if errors:
            raise RESTBadRequest(reason='Bad request', json={'errors': errors})
        return resource