190 lines
5.3 KiB
Text
190 lines
5.3 KiB
Text
#!/usr/bin/env nu
|
|
|
|
# Provider Interface - Standard provider function signatures
|
|
#
|
|
# This module defines the interface that all provider implementations should follow.
|
|
# It serves as documentation and type contract for provider modules.
|
|
#
|
|
# Note: These are signature examples, not implementations. Actual providers override these.
|
|
|
|
# Query/list all servers from provider (returns list)
|
|
export def provider_query_servers [
|
|
find: string # Filter servers by name/pattern
|
|
cols: string # Columns to return (comma-separated)
|
|
] {
|
|
[]
|
|
}
|
|
|
|
# Get detailed information about a specific server (returns record)
|
|
export def provider_server_info [
|
|
server: record # Server configuration with hostname
|
|
check: bool # Check mode (no errors if not found)
|
|
] {
|
|
{}
|
|
}
|
|
|
|
# Check if server exists in the provider (returns bool)
|
|
export def provider_server_exists [
|
|
server: record # Server configuration
|
|
error_exit: bool # Exit on error if true
|
|
] {
|
|
false
|
|
}
|
|
|
|
# Check if server is in running state (returns bool)
|
|
export def provider_server_is_running [
|
|
server: record # Server configuration
|
|
error_exit: bool # Exit on error if true
|
|
] {
|
|
false
|
|
}
|
|
|
|
# Get current status of a server (returns string)
|
|
export def provider_status_server [
|
|
hostname: string # Server hostname
|
|
] {
|
|
""
|
|
}
|
|
|
|
# Change server state (returns bool)
|
|
export def provider_server_state [
|
|
server: record # Server configuration
|
|
new_state: string # Target state
|
|
error_exit: bool # Exit on error
|
|
wait: bool # Wait for state change
|
|
settings: record # Provisioning settings
|
|
] {
|
|
false
|
|
}
|
|
|
|
# Get IP address from server (returns string)
|
|
export def provider_get_ip [
|
|
settings: record # Provisioning settings
|
|
server: record # Server configuration
|
|
ip_type: string # "public", "private", "ipv4", "ipv6"
|
|
] {
|
|
""
|
|
}
|
|
|
|
# Validate server requirements before creation (returns bool)
|
|
export def provider_check_server_requirements [
|
|
settings: record # Provisioning settings
|
|
server: record # Server configuration
|
|
check: bool # Check mode
|
|
] {
|
|
false
|
|
}
|
|
|
|
# Create a new server in the provider (returns record)
|
|
export def provider_create_server [
|
|
settings: record # Provisioning settings
|
|
server: record # Server configuration
|
|
check: bool # Check mode (no creation)
|
|
wait: bool # Wait for creation
|
|
] {
|
|
{}
|
|
}
|
|
|
|
# Delete a server from the provider (returns bool)
|
|
export def provider_delete_server [
|
|
settings: record # Provisioning settings
|
|
server: record # Server configuration
|
|
keep_storage: bool # Keep storage volumes
|
|
error_exit: bool # Exit on error
|
|
] {
|
|
false
|
|
}
|
|
|
|
# Delete server storage/volumes (returns bool)
|
|
export def provider_delete_server_storage [
|
|
settings: record # Provisioning settings
|
|
server: record # Server configuration
|
|
error_exit: bool # Exit on error
|
|
] {
|
|
false
|
|
}
|
|
|
|
# Modify server configuration (returns string)
|
|
export def provider_modify_server [
|
|
settings: record # Provisioning settings
|
|
server: record # Server configuration
|
|
new_values: list # Values to modify
|
|
error_exit: bool # Exit on error
|
|
] {
|
|
""
|
|
}
|
|
|
|
# Post-creation server configuration (returns string)
|
|
export def provider_post_create_server [
|
|
settings: record # Provisioning settings
|
|
server: record # Server configuration
|
|
check: bool # Check mode
|
|
] {
|
|
""
|
|
}
|
|
|
|
# Check and wait for storage state change (returns bool)
|
|
export def provider_wait_storage [
|
|
settings: record # Provisioning settings
|
|
server: record # Server configuration
|
|
new_state: string # Target state (e.g., "online", "available")
|
|
id: string # Storage/volume ID
|
|
] {
|
|
false
|
|
}
|
|
|
|
# Create storage volume for server (returns record)
|
|
export def provider_create_storage [
|
|
settings: record # Provisioning settings
|
|
server: record # Server configuration
|
|
server_info: record # Server info response
|
|
storage: record # Storage configuration
|
|
volumes: list # Existing volumes
|
|
total_size: int # Total size in GB
|
|
] {
|
|
{}
|
|
}
|
|
|
|
# Fix/adjust storage size after creation (returns string)
|
|
export def provider_storage_fix_size [
|
|
settings: record # Provisioning settings
|
|
server: record # Server configuration
|
|
storage_pos: int # Storage index
|
|
] {
|
|
""
|
|
}
|
|
|
|
# Create private network for server (returns string)
|
|
export def provider_create_private_network [
|
|
settings: record # Provisioning settings
|
|
server: record # Server configuration
|
|
check: bool # Check mode
|
|
] {
|
|
""
|
|
}
|
|
|
|
# Save provider-specific settings (returns bool)
|
|
export def provider_make_settings [
|
|
settings: record # Provisioning settings
|
|
server: record # Server configuration
|
|
] {
|
|
false
|
|
}
|
|
|
|
# Delete/cleanup provider settings (returns nothing)
|
|
export def provider_delete_settings [
|
|
settings: record # Provisioning settings
|
|
server: record # Server configuration
|
|
] {
|
|
}
|
|
|
|
# Main provider entry point
|
|
export def provider [
|
|
args: list<string> # Command arguments
|
|
--server: record # Server configuration
|
|
--settings: string # Settings file path
|
|
--check # Check mode
|
|
--wait # Wait flag
|
|
] {
|
|
""
|
|
}
|