Search in sources :

Example 6 with V1Secret

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

the class Helpers method readSecretByReference.

/**
 * Read a secret by its object reference.
 *
 * @param reference V1ObjectReference An object reference to the Secret you want to read.
 * @param namespace The Namespace where Secret is defined.
 * @return V1Secret The requested Secret.
 * @throws ApiException if there is an API error.
 */
protected V1Secret readSecretByReference(V1ObjectReference reference, String namespace) throws ApiException {
    LOGGER.entering();
    if (reference.getNamespace() != null) {
        namespace = reference.getNamespace();
    }
    V1Secret secret = coreApi.readNamespacedSecret(reference.getName(), namespace, "false", Boolean.TRUE, Boolean.TRUE);
    LOGGER.exiting(secret);
    return secret;
}
Also used : V1Secret(io.kubernetes.client.models.V1Secret)

Example 7 with V1Secret

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

the class SecretHelperTest method createSecret.

// Create a named secret with username / password in specified name
private V1Secret createSecret(String name, String namespace) throws Exception {
    CallBuilderFactory factory = new CallBuilderFactory(null);
    try {
        V1Secret existing = factory.create().readSecret(name, namespace);
        if (existing != null)
            return existing;
    } catch (ApiException ignore) {
    // Just ignore and try to create it
    }
    if (isVersion18)
        return null;
    V1Secret body = new V1Secret();
    // Set the required api version and kind of resource
    body.setApiVersion("v1");
    body.setKind("Secret");
    // Setup the standard object metadata
    V1ObjectMeta meta = new V1ObjectMeta();
    meta.setName(name);
    meta.setNamespace(namespace);
    body.setMetadata(meta);
    Map<String, byte[]> data = new HashMap<String, byte[]>();
    data.put(SecretHelper.ADMIN_SERVER_CREDENTIALS_USERNAME, USERNAME.getBytes());
    data.put(SecretHelper.ADMIN_SERVER_CREDENTIALS_PASSWORD, PASSWORD.getBytes());
    body.setData(data);
    try {
        return factory.create().createSecret(namespace, body);
    } catch (Exception e) {
        e.printStackTrace(System.out);
        throw e;
    }
}
Also used : HashMap(java.util.HashMap) V1ObjectMeta(io.kubernetes.client.models.V1ObjectMeta) CallBuilderFactory(oracle.kubernetes.operator.helpers.CallBuilderFactory) V1Secret(io.kubernetes.client.models.V1Secret) ApiException(io.kubernetes.client.ApiException) ApiException(io.kubernetes.client.ApiException)

Example 8 with V1Secret

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

the class CoreV1Api method replaceNamespacedSecretAsync.

/**
 *  (asynchronously)
 * replace 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 body  (required)
 * @param pretty If &#39;true&#39;, 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 replaceNamespacedSecretAsync(String name, 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 = replaceNamespacedSecretValidateBeforeCall(name, 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 9 with V1Secret

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

the class CoreV1Api method createNamespacedSecretWithHttpInfo.

/**
 * create a Secret
 * @param namespace object name and auth scope, such as for teams and projects (required)
 * @param body  (required)
 * @param pretty If &#39;true&#39;, then the output is pretty printed. (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> createNamespacedSecretWithHttpInfo(String namespace, V1Secret body, String pretty) throws ApiException {
    com.squareup.okhttp.Call call = createNamespacedSecretValidateBeforeCall(namespace, body, pretty, 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 10 with V1Secret

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

the class CoreV1Api method patchNamespacedSecretAsync.

/**
 *  (asynchronously)
 * partially update 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 body  (required)
 * @param pretty If &#39;true&#39;, 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 patchNamespacedSecretAsync(String name, String namespace, Object 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 = patchNamespacedSecretValidateBeforeCall(name, 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)

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