Initializes an instance of Custom Vision Training API client.

@param restClient the REST client to connect to Azure.
@param apiKey the Custom Vision Training API key
@return the Custom Vision Training API client
968936
public static TrainingApi authenticate(RestClient restClient, final String apiKey) {
        return new TrainingApiImpl(restClient).withApiKey(apiKey);
    }
1373988
@Override
    public void loadProperties(String restClientName){
        enableDynamicProperties = true;
        setClientName(restClientName);
        loadDefaultValues();
        Configuration props = ConfigurationManager.getConfigInstance().subset(restClientName);
        for (Iterator<String> keys = props.getKeys(); keys.hasNext(); ){
            String key = keys.next();
            String prop = key;
            try {
                if (prop.startsWith(getNameSpace())){
                    prop = prop.substring(getNameSpace().length() + 1);
                }
                setPropertyInternal(prop, getStringValue(props, key));
            } catch (Exception ex) {
                throw new RuntimeException(String.format("Property %s is invalid", prop));
            }
        }
    }
1012109
public static base_responses add(nitro_service client, sslcertkey resources[]) throws Exception {
		base_responses result = null;
		if (resources != null && resources.length > 0) {
			sslcertkey addresources[] = new sslcertkey[resources.length];
			for (int i=0;i<resources.length;i++){
				addresources[i] = new sslcertkey();
				addresources[i].certkey = resources[i].certkey;
				addresources[i].cert = resources[i].cert;
				addresources[i].key = resources[i].key;
				addresources[i].password = resources[i].password;
				addresources[i].fipskey = resources[i].fipskey;
				addresources[i].inform = resources[i].inform;
				addresources[i].passplain = resources[i].passplain;
				addresources[i].expirymonitor = resources[i].expirymonitor;
				addresources[i].notificationperiod = resources[i].notificationperiod;
				addresources[i].bundle = resources[i].bundle;
			}
			result = add_bulk_request(client, addresources);
		}
		return result;
	}
841520
public ReplicationClientFactory usingApiKey(String apiKey) {
        if (Objects.equal(_apiKey, apiKey)) {
            return this;
        }
        return new ReplicationClientFactory(_jerseyClient, apiKey);
    }
435794
public <T extends AbstractGoogleJsonClient.Builder> T fromApiKey(T builder, String apiKey) {
    Preconditions.checkNotNull(builder);
    Preconditions.checkNotNull(apiKey);
    return prepareBuilder(builder, null, new CommonGoogleClientRequestInitializer(apiKey));
  }
1334373
@Override
    public ResourceSet<CredentialList> read(final TwilioRestClient client) {
        return new ResourceSet<>(this, client, firstPage(client));
    }
1269608
def _init_az_api(self):
        
        with self.__lock:
            if self._resource_client is None:
                log.debug("Making Azure `ServicePrincipalcredentials` object"
                          " with tenant=%r, client_id=%r, secret=%r ...",
                          self.tenant_id, self.client_id,
                          ('<redacted>' if self.secret else None))
                credentials = ServicePrincipalCredentials(
                    tenant=self.tenant_id,
                    client_id=self.client_id,
                    secret=self.secret,
                )
                log.debug("Initializing Azure `ComputeManagementclient` ...")
                self._compute_client = ComputeManagementClient(credentials, self.subscription_id)
                log.debug("Initializing Azure `NetworkManagementclient` ...")
                self._network_client = NetworkManagementClient(credentials, self.subscription_id)
                log.debug("Initializing Azure `ResourceManagementclient` ...")
                self._resource_client = ResourceManagementClient(credentials, self.subscription_id)
                log.info("Azure API clients initialized.")
245539
public static base_response add(nitro_service client, sslcertkey resource) throws Exception {
		sslcertkey addresource = new sslcertkey();
		addresource.certkey = resource.certkey;
		addresource.cert = resource.cert;
		addresource.key = resource.key;
		addresource.password = resource.password;
		addresource.fipskey = resource.fipskey;
		addresource.inform = resource.inform;
		addresource.passplain = resource.passplain;
		addresource.expirymonitor = resource.expirymonitor;
		addresource.notificationperiod = resource.notificationperiod;
		addresource.bundle = resource.bundle;
		return addresource.add_resource(client);
	}
101383
public static JSONObject oauth(String apiKey, String secretKey, AipClientConfiguration config) {
        try {
            AipRequest request = new AipRequest();
            request.setUri(new URI(AipClientConst.OAUTH_URL));
            request.addBody("grant_type", "client_credentials");
            request.addBody("client_id", apiKey);
            request.addBody("client_secret", secretKey);
            request.setConfig(config);
            int statusCode = 500;
            AipResponse response = null;
            // add retry
            int cnt = 0;
            while (statusCode == 500 && cnt < 3) {
                response = AipHttpClient.post(request);
                statusCode = response.getStatus();
                cnt++;
            }
            String res = response.getBodyStr();
            if (res != null && !res.equals("")) {
                return new JSONObject(res);
            } else {
                return Util.getGeneralError(statusCode, "Server response code: " + statusCode);
            }
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
        return Util.getGeneralError(-1, "unknown error");
    }
578033
public function sendRequest(ApiKey $apiKey, RestRequest $request)
    {
        $hmac = $this->generateHmac($apiKey->getPrivateKey(), $request->getEndpoint(), array_merge($request->getQueryData(), $request->getPostData()));

        $client = new Client([
            'base_uri' => $request->getHost()
        ]);
        
        $args = [
            'auth' => [$apiKey->getPublicKey(), $hmac],
            'headers' => [
                'Accept' => 'application/json'
            ]
        ];
        
        if ($request->getRequestMethod() === 'POST') {
            $args['form_params'] = $request->getPostData();
        } else {
            $args['query'] = $request->getQueryData();
        }
        
        try {
            $responseRaw = $client->request($request->getRequestMethod(), $request->getEndpoint(), $args);
        } catch (RequestException $e) {
            if (!$e->hasResponse()) {
                throw new Exception('Cannot send REST request.', 0, $e);
            }
            
            $responseRaw = $e->getResponse();
        }
        
        return $this->prepareResponse($responseRaw, $request);
    }
630243
public static synchronized SailthruClient getInstance(String apiKey, String apiSecret) {
        if (_instance == null) {
            _instance = new SailthruClient(apiKey, apiSecret, DEFAULT_API_URL);
        }
        return _instance;
    }
1004889
public static base_response init(nitro_service client, sslfipssimtarget resource) throws Exception {
		sslfipssimtarget initresource = new sslfipssimtarget();
		initresource.certfile = resource.certfile;
		initresource.keyvector = resource.keyvector;
		initresource.targetsecret = resource.targetsecret;
		return initresource.perform_operation(client,"init");
	}
1078824
public static ClientConfiguration createClient(final AuthScope authScope, final Credentials credentials) {
        return createClient(authScope, credentials, emptyList(), emptyList());
    }
429996
@Override
    public ResourceSet<OriginationUrl> read(final TwilioRestClient client) {
        return new ResourceSet<>(this, client, firstPage(client));
    }
1232472
public void setApiKey(String apiKey) {
        for (Authentication auth : authentications.values()) {
            if (auth instanceof ApiKeyAuth) {
                ((ApiKeyAuth) auth).setApiKey(apiKey);
                return;
            }
        }
        throw new RuntimeException("No API key authentication configured!");
    }
828008
public static FaceAPI authenticate(String baseUrl, final String subscriptionKey) {
        ServiceClientCredentials serviceClientCredentials = new ServiceClientCredentials() {
            @Override
            public void applyCredentialsFilter(OkHttpClient.Builder builder) {
                builder.addNetworkInterceptor(
                        new Interceptor() {
                            @Override
                            public Response intercept(Chain chain) throws IOException {
                                Request request = null;
                                Request original = chain.request();
                                // Request customization: add request headers
                                Request.Builder requestBuilder = original.newBuilder()
                                        .addHeader("Ocp-Apim-Subscription-Key", subscriptionKey);
                                request = requestBuilder.build();
                                return chain.proceed(request);
                            }
                        });
            }
        };
        return authenticate(baseUrl, serviceClientCredentials);
    }
569409
public HttpClientActionBuilder client(HttpClient httpClient) {
		HttpClientActionBuilder clientAction = new HttpClientActionBuilder(action, httpClient)
				.withApplicationContext(applicationContext);
		return clientAction;
	}