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

com.github.alexdlaird.ngrok.protocol.TunnelPolicyActions Maven / Gradle / Ivy

There is a newer version: 2.3.1
Show newest version
/*
 * Copyright (c) 2021-2024 Alex Laird
 *
 * SPDX-License-Identifier: MIT
 */

package com.github.alexdlaird.ngrok.protocol;

import java.util.Map;

/**
 * An object that represents policy actions configuration for a {@link CreateTunnel}.
 */
public class TunnelPolicyActions {

    private final String type;
    private final String config;

    private TunnelPolicyActions(final Builder builder) {
        this.type = builder.type;
        this.config = builder.config;
    }

    /**
     * Get the action type.
     */
    public String getType() {
        return type;
    }

    /**
     * Get the action config.
     */
    public String getConfig() {
        return config;
    }

    /**
     * Builder for a {@link TunnelPolicyActions}.
     */
    public static class Builder {

        private String type;
        private String config;

        /**
         * Construct a TunnelPolicy Builder.
         */
        public Builder() {
        }

        /**
         * Construct a TunnelPolicyActions Builder from tunnel definition of policy.inbound.actions or
         * policy.outbound.actions.
         *
         * @param tunnelPolicyActionsDefinition The map of Tunnel policy action attributes.
         */
        public Builder(final Map tunnelPolicyActionsDefinition) {
            if (tunnelPolicyActionsDefinition.containsKey("type")) {
                this.type = (String) tunnelPolicyActionsDefinition.get("type");
            }
            if (tunnelPolicyActionsDefinition.containsKey("config")) {
                this.config = (String) tunnelPolicyActionsDefinition.get("config");
            }
        }

        /**
         * The action type.
         */
        public TunnelPolicyActions.Builder withType(final String type) {
            this.type = type;
            return this;
        }

        /**
         * The action config.
         */
        public TunnelPolicyActions.Builder withConfig(final String config) {
            this.config = config;
            return this;
        }

        /**
         * Build the {@link TunnelPolicyActions}.
         */
        public TunnelPolicyActions build() {
            return new TunnelPolicyActions(this);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy