Class: Infisical::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/infisical/client.rb

Overview

Entry point for the SDK. Construct one, authenticate via #auth, then use #secrets to talk to Infisical.

Examples:

Fetch a secret

client = Infisical::Client.new
client.auth.(client_id: "...", client_secret: "...")
secret = client.secrets.get("DATABASE_URL", project_id: "...", environment: "dev")
secret.secret_value # => "postgres://..."

Constant Summary collapse

DEFAULT_SITE_URL =
"https://app.infisical.com"
ALLOWED_SCHEMES =
%w[http https].freeze

Instance Method Summary collapse

Constructor Details

#initialize(site_url: DEFAULT_SITE_URL, timeout: HTTPClient::DEFAULT_TIMEOUT) ⇒ Client

Returns a new instance of Client.

Parameters:

  • site_url (String) (defaults to: DEFAULT_SITE_URL)

    base URL of the Infisical instance; defaults to Infisical Cloud, so only self-hosted deployments need to set it. A trailing "/api" is tolerated and stripped.

  • timeout (Numeric) (defaults to: HTTPClient::DEFAULT_TIMEOUT)

    open/read timeout in seconds for each request

Raises:

  • (ArgumentError)

    if site_url is not an http(s) URL



27
28
29
30
# File 'lib/infisical/client.rb', line 27

def initialize(site_url: DEFAULT_SITE_URL, timeout: HTTPClient::DEFAULT_TIMEOUT)
  validate_site_url!(site_url)
  @http_client = HTTPClient.new(base_url: normalize_site_url(site_url), timeout: timeout)
end

Instance Method Details

#authAuth

Authentication operations. Logging in through this authenticates the whole client, since all resource clients share one HTTP client.

Returns:



36
37
38
# File 'lib/infisical/client.rb', line 36

def auth
  @auth ||= Auth.new(@http_client)
end

#secretsSecrets

Secret CRUD operations.

Returns:



43
44
45
# File 'lib/infisical/client.rb', line 43

def secrets
  @secrets ||= Secrets.new(@http_client)
end