forked from Hithomelabs/CFTunnels
67 lines
1.9 KiB
Java
67 lines
1.9 KiB
Java
package com.hithomelabs.cftunnels.Entity;
|
|
|
|
import jakarta.persistence.*;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.Getter;
|
|
import lombok.NoArgsConstructor;
|
|
import lombok.Setter;
|
|
|
|
import java.util.UUID;
|
|
|
|
/**
|
|
* JPA Entity representing a Cloudflare Tunnel configuration.
|
|
*
|
|
* <p>This entity stores the locally cached configuration of a Cloudflare Tunnel,
|
|
* linking the tunnel's unique identifier from Cloudflare with its local
|
|
* environment name for easier reference and management.</p>
|
|
*
|
|
* <p>The entity is uniquely constrained by tunnel ID and environment name,
|
|
* ensuring only one configuration exists per tunnel per environment.</p>
|
|
*
|
|
* <p><b>Database Table:</b> {@code tunnels}</p>
|
|
*
|
|
* <p><b>Relationships:</b></p>
|
|
* <ul>
|
|
* <li>One Tunnel has many Mappings (via tunnel_id foreign key)</li>
|
|
* </ul>
|
|
*
|
|
* @see Mapping
|
|
* @see Request
|
|
*/
|
|
@Entity
|
|
@Getter
|
|
@Setter
|
|
@NoArgsConstructor
|
|
@AllArgsConstructor
|
|
@Table(name = "tunnels")
|
|
public class Tunnel {
|
|
|
|
/**
|
|
* Unique identifier for the tunnel (UUID).
|
|
*
|
|
* <p>This corresponds to the Cloudflare-assigned tunnel ID
|
|
* and serves as the primary key for this entity.</p>
|
|
*/
|
|
@Id
|
|
@Column(columnDefinition = "uuid", insertable = false, updatable = false, nullable = false)
|
|
private UUID id;
|
|
|
|
/**
|
|
* Environment name associated with this tunnel configuration.
|
|
*
|
|
* <p>Examples: "production", "staging", "development"</p>
|
|
* <p>Each tunnel can be configured for multiple environments.</p>
|
|
*/
|
|
@Column(length = 10, unique = true, nullable = false)
|
|
private String environment;
|
|
|
|
/**
|
|
* Display name of the tunnel as configured in Cloudflare.
|
|
*
|
|
* <p>This is the user-friendly name assigned to the tunnel
|
|
* when it was created in Cloudflare Zero Trust Dashboard
|
|
* or via the Cloudflare API.</p>
|
|
*/
|
|
@Column(length = 50, unique = true, nullable = false)
|
|
private String name;
|
|
} |