All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.helidon.integrations.vault.sys.SysRx Maven / Gradle / Ivy

There is a newer version: 4.1.2
Show newest version
/*
 * Copyright (c) 2021 Oracle and/or its affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.helidon.integrations.vault.sys;

import io.helidon.common.reactive.Single;
import io.helidon.integrations.vault.AuthMethod;
import io.helidon.integrations.vault.Engine;
import io.helidon.integrations.vault.SysApi;

/**
 * Vault sys operation as reactive non-blocking API.
 *
 * @see io.helidon.integrations.vault.Vault#sys(io.helidon.integrations.vault.SysApi)
 */
public interface SysRx {
    /**
     * The API of this sys implementation.
     */
    SysApi API = SysApi.create(SysRx.class);

    /**
     * Enable (mount) a secret engine on a default path.
     *
     * @param engine engine to enable
     * @return when the engine is enabled
     */
    default Single enableEngine(Engine engine) {
        return enableEngine(EnableEngine.Request.builder().engine(engine));
    }

    /**
     * Enable (mount) a secret engine with custom configuration.
     *
     * @param request request for mount operation
     * @return when the engine is enabled
     */
    Single enableEngine(EnableEngine.Request request);

    /**
     * Disable (unmount) a secret engine from default path.
     *
     * @param engine to disable
     * @return when the engine is disabled
     */
    default Single disableEngine(Engine engine) {
        return disableEngine(DisableEngine.Request.builder()
                                     .engine(engine));
    }

    /**
     * Disable (unmount) a secrets engine from specific path.
     *
     * @param path mount path
     * @return when the engine is disabled
     */
    default Single disableEngine(String path) {
        return disableEngine(DisableEngine.Request.builder()
                                     .path(path));
    }

    /**
     * Disable (unmount) a secrets engine.
     *
     * @param request disable engine request
     * @return disable engine response
     */
    Single disableEngine(DisableEngine.Request request);

    /**
     * Enable an authentication method on default path.
     *
     * @param authMethod authentication method to enable
     * @return when the method is enabled
     */
    default Single enableAuth(AuthMethod authMethod) {
        return enableAuth(EnableAuth.Request.builder()
                                  .auth(authMethod));
    }

    /**
     * Enable an authentication method on custom path or with additional configuration.
     *
     * @param request mount request
     * @return when the method is enabled
     */
    Single enableAuth(EnableAuth.Request request);

    /**
     * Disable an authentication method.
     *
     * @param path path of the method
     * @return disable authentication method response
     */
    default Single disableAuth(String path) {
        return disableAuth(DisableAuth.Request.builder()
                                   .path(path));
    }

    /**
     * Disable an authentication method.
     *
     * @param request disable authentication method request
     * @return disable authentication method response
     */
    Single disableAuth(DisableAuth.Request request);

    /**
     * Create a policy.
     *
     * @param name name of the policy
     * @param policy policy document
     * @return when policy is created
     */
    default Single createPolicy(String name, String policy) {
        return createPolicy(CreatePolicy.Request.create(name, policy));
    }

    /**
     * Create a policy.
     *
     * @param request create a policy request
     * @return create policy response
     */
    Single createPolicy(CreatePolicy.Request request);

    /**
     * Delete a policy.
     *
     * @param name name of the policy
     * @return when policy is deleted
     */
    default Single deletePolicy(String name) {
        return deletePolicy(DeletePolicy.Request.create(name));
    }

    /**
     * Delete a policy.
     *
     * @param request delete policy request
     * @return delete policy response
     */
    Single deletePolicy(DeletePolicy.Request request);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy