Class: GeneratorLabs::Client

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

Overview

Main API client for Generator Labs.

The Generator Labs API is a RESTful web service API that lets customers manage their RBL monitoring hosts, certificate monitoring, contacts, and retrieve listing information.

Examples:

Basic usage

client = GeneratorLabs::Client.new('your_account_sid', 'your_auth_token')

# RBL monitoring
hosts = client.rbl.hosts.get

# Certificate monitoring
monitors = client.cert.monitors.get

# Contact management
contacts = client.contact.contacts.get

With custom configuration

config = GeneratorLabs::Config.new(
  timeout: 45,
  max_retries: 5,
  retry_backoff: 2.0
)
client = GeneratorLabs::Client.new('your_account_sid', 'your_auth_token', config)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account_sid, auth_token, config = nil) ⇒ Client

Initialize a new Generator Labs client.

The account SID must be in the format of 2 uppercase letters followed by 32 hexadecimal characters (e.g., “AC” + 32 hex chars).

The auth token must be 64 hexadecimal characters.

Examples:

client = GeneratorLabs::Client.new('ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'your_auth_token')

With custom config

config = GeneratorLabs::Config.new(timeout: 60)
client = GeneratorLabs::Client.new('ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'your_auth_token', config)

Parameters:

  • account_sid (String)

    Your Generator Labs account SID

  • auth_token (String)

    Your Generator Labs auth token

  • config (Config, nil) (defaults to: nil)

    Optional configuration object for custom timeouts and retry behavior

Raises:

  • (Error)

    if account_sid or auth_token format is invalid



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/generatorlabs/client.rb', line 66

def initialize(, auth_token, config = nil)
  # Validate account SID format
  raise Error, "Invalid account SID format: #{}" unless .match?(/^[A-Z]{2}[0-9a-fA-F]{32}$/)

  # Validate auth token format
  raise Error, 'Invalid auth token format' unless auth_token.match?(/^[0-9a-fA-F]{64}$/)

  @account_sid = 
  @auth_token = auth_token
  @config = config || Config.default
  @handler = RequestHandler.new(, auth_token, @config)
end

Instance Attribute Details

#account_sidString (readonly)

Returns The account SID (2 uppercase + 32 hex characters).

Returns:

  • (String)

    The account SID (2 uppercase + 32 hex characters)



40
41
42
# File 'lib/generatorlabs/client.rb', line 40

def 
  @account_sid
end

#auth_tokenString (readonly)

Returns The authentication token (64 hex characters).

Returns:

  • (String)

    The authentication token (64 hex characters)



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

def auth_token
  @auth_token
end

#configConfig (readonly)

Returns The configuration object.

Returns:

  • (Config)

    The configuration object



46
47
48
# File 'lib/generatorlabs/client.rb', line 46

def config
  @config
end

Instance Method Details

#certCert

Get the Certificate monitoring API namespace.

The Cert namespace provides access to:

  • Monitors: Manage certificate monitors

  • Profiles: Manage certificate monitoring profiles

  • Errors: Retrieve current certificate errors

Examples:

monitors = client.cert.monitors.get
errors = client.cert.errors.get

Returns:

  • (Cert)

    Cert namespace with endpoints for errors, monitors, and profiles



124
125
126
# File 'lib/generatorlabs/client.rb', line 124

def cert
  @cert ||= Cert.new(@handler)
end

#contactContact

Get the Contact management API namespace.

The Contact namespace provides access to:

  • Contacts: Manage individual contacts

  • Groups: Manage contact groups

Examples:

contacts = client.contact.contacts.get
groups = client.contact.groups.get

Returns:

  • (Contact)

    Contact namespace with endpoints for contacts and groups



108
109
110
# File 'lib/generatorlabs/client.rb', line 108

def contact
  @contact ||= Contact.new(@handler)
end

#rblRBL

Get the RBL monitoring API namespace.

The RBL namespace provides access to:

  • Hosts: Manage monitored hosts (IP addresses and domains)

  • Profiles: Manage monitoring profiles (which RBLs to check)

  • Sources: Manage RBL sources

  • Check: Perform ad-hoc RBL checks

  • Listings: Retrieve current RBL listings

Examples:

hosts = client.rbl.hosts.get
listings = client.rbl.listings

Returns:

  • (RBL)

    RBL namespace with endpoints for hosts, profiles, sources, etc.



93
94
95
# File 'lib/generatorlabs/client.rb', line 93

def rbl
  @rbl ||= RBL.new(@handler)
end