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

io.micronaut.management.endpoint.EndpointDefaultConfiguration Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2017-2020 original authors
 *
 * 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
 *
 * https://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.micronaut.management.endpoint;

import io.micronaut.context.annotation.ConfigurationProperties;
import io.micronaut.core.annotation.Nullable;
import io.micronaut.core.util.StringUtils;

import java.util.Optional;

/**
 * The default {@link io.micronaut.management.endpoint.annotation.Endpoint} configuration.
 *
 * @author James Kleeh
 * @since 1.0
 */
@ConfigurationProperties(EndpointDefaultConfiguration.PREFIX)
public class EndpointDefaultConfiguration {

    /**
     * The prefix for endpoints settings.
     */
    public static final String PREFIX = "endpoints.all";

    /**
     * The path for endpoints settings.
     */
    public static final String PATH = "endpoints.all.path";

    /**
     * The context for endpoints settings.
     */
    public static final String CONTEXT_PATH = "endpoints.all.context.path";

    /**
     * The path for endpoints settings.
     */
    public static final String PORT = "endpoints.all.port";

    /**
     * The default base path.
     */
    public static final String DEFAULT_ENDPOINT_BASE_PATH = "/";

    /**
     * The default context path.
     */
    public static final String DEFAULT_ENDPOINT_CONTEXT_PATH = null;

    private Boolean enabled;
    private Boolean sensitive;
    private Integer port;
    private String path = DEFAULT_ENDPOINT_BASE_PATH;
    private String contextPath = DEFAULT_ENDPOINT_CONTEXT_PATH;

    /**
     * @return endpoints Base Path (defaults to: {@value #DEFAULT_ENDPOINT_BASE_PATH})
     */
    public String getPath() {
        return path;
    }

    /**
     * @return endpoints Context Path (defaults is null)
     */
    public @Nullable String getContextPath() {
        return contextPath;
    }

    /**
     * @return Whether the endpoint is enabled
     */
    public Optional isEnabled() {
        return Optional.ofNullable(enabled);
    }

    /**
     * @return Does the endpoint expose sensitive information
     */
    public Optional isSensitive() {
        return Optional.ofNullable(sensitive);
    }

    /**
     * Sets whether the endpoint is enabled.
     *
     * @param enabled True it is enabled, null for the default behaviour
     */
    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    /**
     * Sets whether the endpoint is sensitive.
     *
     * @param sensitive True it is sensitive, null for the default behaviour
     */
    public void setSensitive(Boolean sensitive) {
        this.sensitive = sensitive;
    }

    /**
     * The endpoints base path. It must include a leading and trailing '/'. Default value ({@value #DEFAULT_ENDPOINT_BASE_PATH}).
     *
     * @param path The path
     */
    public void setPath(String path) {
        if (StringUtils.isNotEmpty(path)) {
            this.path = path;
        }
    }

    /**
     * The endpoints context path. Default value is null.
     *
     * @param contextPath The Context Path
     */
    public void setContextPath(String contextPath) {
        if (StringUtils.isNotEmpty(contextPath)) {
            this.contextPath = contextPath;
        }
    }

    /**
     * @return The port to expose endpoints via.
     */
    public Optional getPort() {
        return Optional.ofNullable(port);
    }

    /**
     * Sets the port to expose endpoints via.
     *
     * @param port The port
     */
    public void setPort(@Nullable Integer port) {
        this.port = port;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy