1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
// --------------------------------------------------------------------- |
4
|
|
|
// |
5
|
|
|
// Copyright (C) 2018-2024 Artem Rodygin |
6
|
|
|
// |
7
|
|
|
// You should have received a copy of the MIT License along with |
8
|
|
|
// this file. If not, see <https://opensource.org/licenses/MIT>. |
9
|
|
|
// |
10
|
|
|
// --------------------------------------------------------------------- |
11
|
|
|
|
12
|
|
|
namespace Linode\Account; |
13
|
|
|
|
14
|
|
|
use Linode\Entity; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* A User on your Account. Unrestricted users can log in and access information about |
18
|
|
|
* your Account, while restricted users may only access entities or perform actions |
19
|
|
|
* they've been granted access to. |
20
|
|
|
* |
21
|
|
|
* @property string $username The User's username. This is used for logging in, and may also be displayed |
22
|
|
|
* alongside actions the User performs (for example, in Events or public |
23
|
|
|
* StackScripts). |
24
|
|
|
* @property string $email The email address for the User. Linode sends emails to this address for account |
25
|
|
|
* management communications. May be used for other communications as configured. |
26
|
|
|
* @property bool $restricted If true, the User must be granted access to perform actions or access entities on |
27
|
|
|
* this Account. See User Grants View (GET /account/users/{username}/grants) for |
28
|
|
|
* details on how to configure grants for a restricted User. |
29
|
|
|
* @property string[] $ssh_keys A list of SSH Key labels added by this User. |
30
|
|
|
* Users can add keys with the SSH Key Add (POST /profile/sshkeys) command. |
31
|
|
|
* These keys are deployed when this User is included in the `authorized_users` |
32
|
|
|
* field of the following requests: |
33
|
|
|
* - Linode Create (POST /linode/instances) |
34
|
|
|
* - Linode Rebuild (POST /linode/instances/{linodeId}/rebuild) |
35
|
|
|
* - Disk Create (POST /linode/instances/{linodeId}/disks) |
36
|
|
|
* @property bool $tfa_enabled A boolean value indicating if the User has Two Factor Authentication (TFA) |
37
|
|
|
* enabled. See the Create Two Factor Secret (POST /profile/tfa-enable) endpoint to |
38
|
|
|
* enable TFA. |
39
|
|
|
* @property null|string $verified_phone_number The phone number verified for this User Profile with the **Phone Number Verify** |
40
|
|
|
* (POST /profile/phone-number/verify) command. |
41
|
|
|
* `null` if this User Profile has no verified phone number. |
42
|
|
|
* @property null|string $password_created The date and time when this User's current password was created. |
43
|
|
|
* User passwords are first created during the Account sign-up process, and updated |
44
|
|
|
* using the Reset Password webpage. |
45
|
|
|
* `null` if this User has not created a password yet. |
46
|
|
|
* @property null|LastLogin $last_login Information for the most recent login attempt for this User. |
47
|
|
|
* `null` if no login attempts have been made since creation of this User. |
48
|
|
|
* Access the User Logins List All command for additional login information. |
49
|
|
|
*/ |
50
|
|
|
class User extends Entity |
51
|
|
|
{ |
52
|
|
|
// Available fields. |
53
|
|
|
public const FIELD_USERNAME = 'username'; |
54
|
|
|
public const FIELD_EMAIL = 'email'; |
55
|
|
|
public const FIELD_RESTRICTED = 'restricted'; |
56
|
|
|
public const FIELD_SSH_KEYS = 'ssh_keys'; |
57
|
|
|
public const FIELD_TFA_ENABLED = 'tfa_enabled'; |
58
|
|
|
public const FIELD_VERIFIED_PHONE_NUMBER = 'verified_phone_number'; |
59
|
|
|
public const FIELD_PASSWORD_CREATED = 'password_created'; |
60
|
|
|
public const FIELD_LAST_LOGIN = 'last_login'; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @codeCoverageIgnore This method was autogenerated. |
64
|
|
|
*/ |
65
|
|
|
public function __get(string $name): mixed |
66
|
|
|
{ |
67
|
|
|
return match ($name) { |
68
|
|
|
self::FIELD_LAST_LOGIN => null === $this->data[$name] ? null : new LastLogin($this->client, $this->data[$name]), |
69
|
|
|
default => parent::__get($name), |
70
|
|
|
}; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|