Search in sources :

Example 11 with V1Secret

use of io.kubernetes.client.models.V1Secret in project java by kubernetes-client.

the class CoreV1Api method createNamespacedSecretAsync.

/**
 *  (asynchronously)
 * create a Secret
 * @param namespace object name and auth scope, such as for teams and projects (required)
 * @param body  (required)
 * @param pretty If 'true', then the output is pretty printed. (optional)
 * @param callback The callback to be executed when the API call finishes
 * @return The request call
 * @throws ApiException If fail to process the API call, e.g. serializing the request body object
 */
public com.squareup.okhttp.Call createNamespacedSecretAsync(String namespace, V1Secret body, String pretty, final ApiCallback<V1Secret> callback) throws ApiException {
    ProgressResponseBody.ProgressListener progressListener = null;
    ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
    if (callback != null) {
        progressListener = new ProgressResponseBody.ProgressListener() {

            @Override
            public void update(long bytesRead, long contentLength, boolean done) {
                callback.onDownloadProgress(bytesRead, contentLength, done);
            }
        };
        progressRequestListener = new ProgressRequestBody.ProgressRequestListener() {

            @Override
            public void onRequestProgress(long bytesWritten, long contentLength, boolean done) {
                callback.onUploadProgress(bytesWritten, contentLength, done);
            }
        };
    }
    com.squareup.okhttp.Call call = createNamespacedSecretValidateBeforeCall(namespace, body, pretty, progressListener, progressRequestListener);
    Type localVarReturnType = new TypeToken<V1Secret>() {
    }.getType();
    apiClient.executeAsync(call, localVarReturnType, callback);
    return call;
}
Also used : ProgressResponseBody(io.kubernetes.client.ProgressResponseBody) Type(java.lang.reflect.Type) V1Secret(io.kubernetes.client.models.V1Secret) ProgressRequestBody(io.kubernetes.client.ProgressRequestBody)

Example 12 with V1Secret

use of io.kubernetes.client.models.V1Secret in project java by kubernetes-client.

the class CoreV1ApiTest method replaceNamespacedSecretTest.

/**
 * replace the specified Secret
 *
 * @throws ApiException
 *          if the Api call fails
 */
@Test
public void replaceNamespacedSecretTest() throws ApiException {
    String name = null;
    String namespace = null;
    V1Secret body = null;
    String pretty = null;
    V1Secret response = api.replaceNamespacedSecret(name, namespace, body, pretty);
// TODO: test validations
}
Also used : V1Secret(io.kubernetes.client.models.V1Secret) Test(org.junit.Test)

Example 13 with V1Secret

use of io.kubernetes.client.models.V1Secret in project java by kubernetes-client.

the class CoreV1ApiTest method readNamespacedSecretTest.

/**
 * read the specified Secret
 *
 * @throws ApiException
 *          if the Api call fails
 */
@Test
public void readNamespacedSecretTest() throws ApiException {
    String name = null;
    String namespace = null;
    String pretty = null;
    Boolean exact = null;
    Boolean export = null;
    V1Secret response = api.readNamespacedSecret(name, namespace, pretty, exact, export);
// TODO: test validations
}
Also used : V1Secret(io.kubernetes.client.models.V1Secret) Test(org.junit.Test)

Example 14 with V1Secret

use of io.kubernetes.client.models.V1Secret in project java by kubernetes-client.

the class CoreV1Api method readNamespacedSecretWithHttpInfo.

/**
 * read the specified Secret
 * @param name name of the Secret (required)
 * @param namespace object name and auth scope, such as for teams and projects (required)
 * @param pretty If &#39;true&#39;, then the output is pretty printed. (optional)
 * @param exact Should the export be exact.  Exact export maintains cluster-specific fields like &#39;Namespace&#39;. (optional)
 * @param export Should this value be exported.  Export strips fields that a user can not specify. (optional)
 * @return ApiResponse&lt;V1Secret&gt;
 * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
 */
public ApiResponse<V1Secret> readNamespacedSecretWithHttpInfo(String name, String namespace, String pretty, Boolean exact, Boolean export) throws ApiException {
    com.squareup.okhttp.Call call = readNamespacedSecretValidateBeforeCall(name, namespace, pretty, exact, export, null, null);
    Type localVarReturnType = new TypeToken<V1Secret>() {
    }.getType();
    return apiClient.execute(call, localVarReturnType);
}
Also used : Type(java.lang.reflect.Type) V1Secret(io.kubernetes.client.models.V1Secret)

Example 15 with V1Secret

use of io.kubernetes.client.models.V1Secret in project weblogic-kubernetes-operator by oracle.

the class Authenticator method authenticateByServiceAccount.

/**
 * Given a V1ServiceAccount object, pull the authentication secrets and
 * initialize a new ApiClient to authenticate with those credentials.
 *
 * @param serviceAccount The name of the Service Account to authenticate with.
 * @return ApiClient An ApiClient for the given Service Account.
 * @throws ApiException if there is an API error.
 */
private ApiClient authenticateByServiceAccount(V1ServiceAccount serviceAccount) throws ApiException {
    LOGGER.entering();
    byte[] caCert = null;
    String token = null;
    List<V1ObjectReference> secretList = serviceAccount.getSecrets();
    for (V1ObjectReference reference : secretList) {
        // Get the secret.
        V1Secret secret = helper.readSecretByReference(reference, serviceAccount.getMetadata().getNamespace());
        Map<String, byte[]> secretMap = secret.getData();
        for (Entry<String, byte[]> entry : secretMap.entrySet()) {
            if (entry.getKey().equals("ca.crt")) {
                caCert = entry.getValue();
            }
            if (entry.getKey().equals("token")) {
                token = new String(entry.getValue());
            }
        }
    }
    serviceToken = token;
    String serviceHost = System.getenv(_SERVICE_HOST);
    String servicePort = System.getenv(_SERVICE_PORT);
    String serviceUrl = "https://" + serviceHost + ":" + servicePort;
    ApiClient newClient = new ApiClient();
    newClient.setBasePath(serviceUrl);
    newClient.setApiKey("Bearer " + token);
    newClient.setSslCaCert(new ByteArrayInputStream(caCert));
    LOGGER.exiting(newClient);
    return newClient;
}
Also used : V1ObjectReference(io.kubernetes.client.models.V1ObjectReference) ByteArrayInputStream(java.io.ByteArrayInputStream) ApiClient(io.kubernetes.client.ApiClient) V1Secret(io.kubernetes.client.models.V1Secret)

Aggregations

V1Secret (io.kubernetes.client.models.V1Secret)18 Type (java.lang.reflect.Type)8 ProgressRequestBody (io.kubernetes.client.ProgressRequestBody)4 ProgressResponseBody (io.kubernetes.client.ProgressResponseBody)4 Test (org.junit.Test)4 ApiException (io.kubernetes.client.ApiException)3 V1ObjectMeta (io.kubernetes.client.models.V1ObjectMeta)2 V1ObjectReference (io.kubernetes.client.models.V1ObjectReference)2 CallBuilderFactory (oracle.kubernetes.operator.helpers.CallBuilderFactory)2 ApiClient (io.kubernetes.client.ApiClient)1 V1ServiceAccount (io.kubernetes.client.models.V1ServiceAccount)1 V1ServiceAccountList (io.kubernetes.client.models.V1ServiceAccountList)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 HashMap (java.util.HashMap)1