Class: Falcon::Cloud

Inherits:
Object
  • Object
show all
Defined in:
lib/crimson-falcon/cloud.rb

Overview

Validates and returns the cloud to use for API Requests.

Constant Summary collapse

VALID_CLOUDS =
{
  "us-1" => "api.crowdstrike.com",
  "us-2" => "api.us-2.crowdstrike.com",
  "us-gov-1" => "api.laggar.gcw.crowdstrike.com",
  "eu-1" => "api.eu-1.crowdstrike.com",
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cloud) ⇒ Cloud

Initializes a new ‘Cloud` instance with the specified cloud name.

Parameters:

  • cloud (String)

    The name of the cloud instance.

Raises:

  • (ArgumentError)

    If the specified cloud name is not valid.



42
43
44
45
46
47
# File 'lib/crimson-falcon/cloud.rb', line 42

def initialize(cloud)
  message = "Invalid cloud '#{cloud}'. Valid clouds are: #{VALID_CLOUDS.keys.map { |c| "'#{c}'" }.join(", ")}"
  raise ArgumentError, message unless VALID_CLOUDS.key?(cloud)

  @cloud = cloud
end

Instance Attribute Details

#cloudString (readonly)

The name of the cloud instance.

Returns:

  • (String)

    The name of the cloud instance.



59
60
61
# File 'lib/crimson-falcon/cloud.rb', line 59

def cloud
  @cloud
end

Instance Method Details

#hostString

Returns the host name for the current cloud instance.

Returns:

  • (String)

    The host name for the current cloud instance.



52
53
54
# File 'lib/crimson-falcon/cloud.rb', line 52

def host
  VALID_CLOUDS[cloud]
end