Key Lifecycle Rules

A KeyLifecycleRule represents a rule that applies to API keys, GPG keys, and SSH keys (also called User Public Keys) based on their inactivity or age.

Keys that have been unused for the specified number of days will be deleted. SSH keys can also be configured to expire after a specified number of days. SSH key expiration applies only to User Public Keys used for inbound SFTP/SSH login, not Remote Server outbound SSH keys.

List Key Lifecycle Rules

SDK Method

Files::KeyLifecycleRule.list

Return Object

List<KeyLifecycleRule>

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Additional Arguments

Example Request

begin
  key_lifecycle_rules = Files::KeyLifecycleRule.list
  key_lifecycle_rules.auto_paging_each do |key_lifecycle_rule|
    # Operate on key_lifecycle_rule
  end
rescue Files::NotAuthenticatedError => e
  puts "Authentication Error Occurred (#{e.class.to_s}): " + e.message
rescue Files::Error => e
  puts "Unknown Error Occurred (#{e.class.to_s}): " + e.message
end

Show Key Lifecycle Rule

SDK Method

Files::KeyLifecycleRule.find

Return Object

KeyLifecycleRule

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Method Arguments

ArgumentDescription
id
int64
Required
Key Lifecycle Rule ID.

Example Request

begin
  key_lifecycle_rule = Files::KeyLifecycleRule.find(id)
  # Operate on key_lifecycle_rule
rescue Files::NotAuthenticatedError => e
  puts "Authentication Error Occurred (#{e.class.to_s}): " + e.message
rescue Files::Error => e
  puts "Unknown Error Occurred (#{e.class.to_s}): " + e.message
end

Create Key Lifecycle Rule

SDK Method

Files::KeyLifecycleRule.create

Return Object

KeyLifecycleRule

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Method Arguments

ArgumentDefaultDescription
apply_to_all_workspaces
boolean
falseIf true, a default-workspace rule also applies to keys in all workspaces.
expiration_days
int64
Number of days after creation before an SSH key expires. Applies only to SSH keys.
key_type
string
Key type for which the rule will apply (gpg, ssh, or api).
Possible values: gpg, ssh, api
inactivity_days
int64
Number of days of inactivity before the rule applies.
name
string
Key Lifecycle Rule name
workspace_id
int64
0Workspace ID. 0 means the default workspace.

Example Request

begin
  key_lifecycle_rule = Files::KeyLifecycleRule.create(
    apply_to_all_workspaces: true
  )
  # Operate on key_lifecycle_rule
rescue Files::NotAuthenticatedError => e
  puts "Authentication Error Occurred (#{e.class.to_s}): " + e.message
rescue Files::Error => e
  puts "Unknown Error Occurred (#{e.class.to_s}): " + e.message
end

Update Key Lifecycle Rule

SDK Method

key_lifecycle_rule.update

Return Object

KeyLifecycleRule

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Method Arguments

ArgumentDescription
apply_to_all_workspaces
boolean
If true, a default-workspace rule also applies to keys in all workspaces.
expiration_days
int64
Number of days after creation before an SSH key expires. Applies only to SSH keys.
key_type
string
Key type for which the rule will apply (gpg, ssh, or api).
Possible values: gpg, ssh, api
inactivity_days
int64
Number of days of inactivity before the rule applies.
name
string
Key Lifecycle Rule name
workspace_id
int64
Workspace ID. 0 means the default workspace.

Example Request

begin
  # Find the key_lifecycle_rule object by its id.
  key_lifecycle_rule = Files::KeyLifecycleRule.find(id)
  key_lifecycle_rule.update(
    apply_to_all_workspaces: true
  )
rescue Files::NotAuthenticatedError => e
  puts "Authentication Error Occurred (#{e.class.to_s}): " + e.message
rescue Files::Error => e
  puts "Unknown Error Occurred (#{e.class.to_s}): " + e.message
end

Delete Key Lifecycle Rule

SDK Method

key_lifecycle_rule.delete

Return Object

nil

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Example Request

begin
  # Find the key_lifecycle_rule object by its id.
  key_lifecycle_rule = Files::KeyLifecycleRule.find(id)
  key_lifecycle_rule.delete
rescue Files::NotAuthenticatedError => e
  puts "Authentication Error Occurred (#{e.class.to_s}): " + e.message
rescue Files::Error => e
  puts "Unknown Error Occurred (#{e.class.to_s}): " + e.message
end

The KeyLifecycleRule Object

Some of the methods above return a KeyLifecycleRule object. The attributes of this object are listed below.

AttributeDescription
id
int64
Key Lifecycle Rule ID
key_type
string
Key type for which the rule will apply (gpg, ssh, or api).
Possible values: gpg, ssh, api
inactivity_days
int64
Number of days of inactivity before the rule applies.
expiration_days
int64
Number of days after creation before an SSH key expires. Applies only to SSH keys.
apply_to_all_workspaces
boolean
If true, a default-workspace rule also applies to keys in all workspaces.
name
string
Key Lifecycle Rule name
workspace_id
int64
Workspace ID. 0 means the default workspace.