Represents a storage box’s subaccount
List all subaccounts
storage_box = HCloud::StorageBox.find(1)
storage_box.subaccounts
Search subaccounts
storage_box = HCloud::StorageBox.find(1)
storage_box.subaccounts.where(label_selector: "environment=production")
Find subaccount by ID
storage_box = HCloud::StorageBox.find(1)
storage_box.subaccounts.find(1)
Create subaccount
storage_box = HCloud::StorageBox.find(1)
subaccount = storage_box.subaccounts.new(password: "my_password", description: "my_subaccount", home_directory: "backup/", access_settings: { samba_enabled: false, ssh_enabled: true, webdav_enabled: false, readonly: false, reachable_externally: false })
subaccount.create
subaccount.created?
# => false
Note: this method returns a {HCloud::Action} instance rather than the created resource itself, as the subaccount is created asynchronously.
Reload the subaccount to check if it was created successfully.
subaccount.reload
subaccount.created?
# => true
subaccount = storage_box.subaccounts.create(password: "my_password", description: "my_subaccount", home_directory: "backup/", access_settings: { samba_enabled: false, ssh_enabled: true, webdav_enabled: false, readonly: false, reachable_externally: false })
# => #<HCloud::Action id: 1, ...>
Note: this method returns a {HCloud::Action} instance rather than the created resource itself
subaccount = HCloud::StorageBox::Subaccount.create(storage_box: 1, password: "my_password", description: "my_subaccount", home_directory: "backup/", access_settings: { samba_enabled: false, ssh_enabled: true, webdav_enabled: false, readonly: false, reachable_externally: false })
# => #<HCloud::Action id: 1, ...>
Note: this method returns a {HCloud::Action} instance rather than the created resource itself
Update subaccount
storage_box = HCloud::StorageBox.find(1)
subaccount = storage_box.subaccounts.find(1)
subaccount.description = "another_subaccount"
subaccount.update
Delete subaccount
storage_box = HCloud::StorageBox.find(1)
subaccount = storage_box.subaccounts.find(1)
subaccount.delete
# => #<HCloud::Action id: 1, ...>
subaccount.deleted?
# => true
Note: this method returns a {HCloud::Action} instance rather than the deleted resource itself
Resource-specific actions
Reset password
storage_box = HCloud::StorageBox.find(1)
subaccount = storage_box.subaccounts.find(1)
subaccount.reset_subaccount_password(password: "mypassword")
Update access settings
storage_box = HCloud::StorageBox.find(1)
subaccount = storage_box.subaccounts.find(1)
subaccount.update_access_settings(samba_enabled: false, ssh_enabled: true, webdav_enabled: false, zfs_enabled: false, reachable_externally: false)