|
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\Account\Repository\AccountAvailabilityRepository; |
|
15
|
|
|
use Linode\Account\Repository\BetaProgramEnrolledRepository; |
|
16
|
|
|
use Linode\Account\Repository\EventRepository; |
|
17
|
|
|
use Linode\Account\Repository\InvoiceRepository; |
|
18
|
|
|
use Linode\Account\Repository\NotificationRepository; |
|
19
|
|
|
use Linode\Account\Repository\OAuthClientRepository; |
|
20
|
|
|
use Linode\Account\Repository\PaymentMethodRepository; |
|
21
|
|
|
use Linode\Account\Repository\PaymentRepository; |
|
22
|
|
|
use Linode\Account\Repository\ServiceTransferRepository; |
|
23
|
|
|
use Linode\Account\Repository\UserRepository; |
|
24
|
|
|
use Linode\Entity; |
|
25
|
|
|
use Linode\Exception\LinodeException; |
|
26
|
|
|
use Linode\LinodeClient; |
|
27
|
|
|
use Linode\Longview\LongviewSubscription; |
|
28
|
|
|
use Linode\Managed\StatsDataAvailable; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Account object. |
|
32
|
|
|
* |
|
33
|
|
|
* @property string $first_name The first name of the person associated with this Account. |
|
34
|
|
|
* Must not include any of the following characters: `<` `>` `(` `)` `"` `=` |
|
35
|
|
|
* @property string $last_name The last name of the person associated with this Account. |
|
36
|
|
|
* Must not include any of the following characters: `<` `>` `(` `)` `"` `=` |
|
37
|
|
|
* @property string $email The email address of the person associated with this Account. |
|
38
|
|
|
* @property float $balance This Account's balance, in US dollars. |
|
39
|
|
|
* @property float $balance_uninvoiced This Account's current estimated invoice in US dollars. This is not your final |
|
40
|
|
|
* invoice balance. Transfer charges are not included in the estimate. |
|
41
|
|
|
* @property string $company The company name associated with this Account. |
|
42
|
|
|
* Must not include any of the following characters: `<` `>` `(` `)` `"` `=` |
|
43
|
|
|
* @property string $address_1 First line of this Account's billing address. |
|
44
|
|
|
* @property string $address_2 Second line of this Account's billing address. |
|
45
|
|
|
* @property string $city The city for this Account's billing address. |
|
46
|
|
|
* @property string $state If billing address is in the United States (US) or Canada (CA), only the |
|
47
|
|
|
* two-letter ISO 3166 State or Province code are accepted. If entering a US military |
|
48
|
|
|
* address, state abbreviations (AA, AE, AP) should be entered. If the address is |
|
49
|
|
|
* outside the US or CA, this is the Province associated with the Account's billing |
|
50
|
|
|
* address. |
|
51
|
|
|
* @property string $zip The zip code of this Account's billing address. The following restrictions apply: |
|
52
|
|
|
* - Can only contain ASCII letters, numbers, and hyphens (`-`). |
|
53
|
|
|
* - Must not contain more than 9 letter or number characters. |
|
54
|
|
|
* @property string $country The two-letter ISO 3166 country code of this Account's billing address. |
|
55
|
|
|
* @property string $phone The phone number associated with this Account. |
|
56
|
|
|
* @property string $tax_id The tax identification number associated with this Account, for tax calculations |
|
57
|
|
|
* in some countries. If you do not live in a country that collects tax, this should |
|
58
|
|
|
* be an empty string (`""`). |
|
59
|
|
|
* @property CreditCardData $credit_card Credit Card information associated with this Account. |
|
60
|
|
|
* @property string $active_since The datetime of when the account was activated. |
|
61
|
|
|
* @property string[] $capabilities A list of capabilities your account supports. |
|
62
|
|
|
* @property Promotion[] $active_promotions A list of active promotions on your account. |
|
63
|
|
|
* @property string $billing_source The source of service charges for this Account, as determined by its relationship |
|
64
|
|
|
* with Akamai. |
|
65
|
|
|
* Accounts that are associated with Akamai-specific customers return a value of |
|
66
|
|
|
* `akamai`. |
|
67
|
|
|
* All other Accounts return a value of `linode`. |
|
68
|
|
|
* @property string $euuid An external unique identifier for this account. |
|
69
|
|
|
* @property AccountAvailabilityRepositoryInterface $availability Account Service Availability. |
|
70
|
|
|
* @property BetaProgramEnrolledRepositoryInterface $betaPrograms List of all enrolled Beta Program objects for the Account. |
|
71
|
|
|
* @property EventRepositoryInterface $events List of Event objects representing actions taken on your Account. The Events |
|
72
|
|
|
* returned depends on your grants. |
|
73
|
|
|
* @property InvoiceRepositoryInterface $invoices List of Invoices against your Account. |
|
74
|
|
|
* @property NotificationRepositoryInterface $notifications List of Notification objects representing important, often time-sensitive items |
|
75
|
|
|
* related to your Account. |
|
76
|
|
|
* @property OAuthClientRepositoryInterface $oauth_clients List of OAuth Clients registered to your Account. OAuth Clients allow users to log |
|
77
|
|
|
* into applications you write or host using their Linode Account, and may allow them |
|
78
|
|
|
* to grant some level of access to their Linodes or other entities to your |
|
79
|
|
|
* application. |
|
80
|
|
|
* @property PaymentRepositoryInterface $payments List of Payments made on this Account. |
|
81
|
|
|
* @property PaymentMethodRepositoryInterface $paymentMethods List of Payment Methods for this Account. |
|
82
|
|
|
* @property ServiceTransferRepositoryInterface $serviceTransfers List of Service Transfer objects containing the details of all transfers that have |
|
83
|
|
|
* been created and accepted by this account. |
|
84
|
|
|
* @property UserRepositoryInterface $users List of Users on your Account. Users may access all or part of your Account based |
|
85
|
|
|
* on their restricted status and grants. An unrestricted User may access everything |
|
86
|
|
|
* on the account, whereas restricted User may only access entities or perform |
|
87
|
|
|
* actions they've been given specific grants to. |
|
88
|
|
|
* |
|
89
|
|
|
* @codeCoverageIgnore This class was autogenerated. |
|
90
|
|
|
*/ |
|
91
|
|
|
class Account extends Entity |
|
92
|
|
|
{ |
|
93
|
|
|
// Available fields. |
|
94
|
|
|
public const FIELD_FIRST_NAME = 'first_name'; |
|
95
|
|
|
public const FIELD_LAST_NAME = 'last_name'; |
|
96
|
|
|
public const FIELD_EMAIL = 'email'; |
|
97
|
|
|
public const FIELD_BALANCE = 'balance'; |
|
98
|
|
|
public const FIELD_BALANCE_UNINVOICED = 'balance_uninvoiced'; |
|
99
|
|
|
public const FIELD_COMPANY = 'company'; |
|
100
|
|
|
public const FIELD_ADDRESS_1 = 'address_1'; |
|
101
|
|
|
public const FIELD_ADDRESS_2 = 'address_2'; |
|
102
|
|
|
public const FIELD_CITY = 'city'; |
|
103
|
|
|
public const FIELD_STATE = 'state'; |
|
104
|
|
|
public const FIELD_ZIP = 'zip'; |
|
105
|
|
|
public const FIELD_COUNTRY = 'country'; |
|
106
|
|
|
public const FIELD_PHONE = 'phone'; |
|
107
|
|
|
public const FIELD_TAX_ID = 'tax_id'; |
|
108
|
|
|
public const FIELD_CREDIT_CARD = 'credit_card'; |
|
109
|
|
|
public const FIELD_ACTIVE_SINCE = 'active_since'; |
|
110
|
|
|
public const FIELD_CAPABILITIES = 'capabilities'; |
|
111
|
|
|
public const FIELD_ACTIVE_PROMOTIONS = 'active_promotions'; |
|
112
|
|
|
public const FIELD_BILLING_SOURCE = 'billing_source'; |
|
113
|
|
|
public const FIELD_EUUID = 'euuid'; |
|
114
|
|
|
|
|
115
|
|
|
// `FIELD_BILLING_SOURCE` values. |
|
116
|
|
|
public const BILLING_SOURCE_AKAMAI = 'akamai'; |
|
117
|
|
|
public const BILLING_SOURCE_LINODE = 'linode'; |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* Returns the contact and billing information related to your Account. |
|
121
|
|
|
* |
|
122
|
|
|
* @throws LinodeException |
|
123
|
|
|
*/ |
|
124
|
|
|
public function __construct(LinodeClient $client) |
|
125
|
|
|
{ |
|
126
|
|
|
parent::__construct($client); |
|
127
|
|
|
|
|
128
|
|
|
$response = $this->client->get('/account'); |
|
129
|
|
|
$contents = $response->getBody()->getContents(); |
|
130
|
|
|
$json = json_decode($contents, true); |
|
131
|
|
|
|
|
132
|
|
|
$this->data = $json; |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* @codeCoverageIgnore This method was autogenerated. |
|
137
|
|
|
*/ |
|
138
|
|
|
public function __get(string $name): mixed |
|
139
|
|
|
{ |
|
140
|
|
|
return match ($name) { |
|
141
|
|
|
self::FIELD_CREDIT_CARD => new CreditCardData($this->client, $this->data[$name]), |
|
142
|
|
|
self::FIELD_ACTIVE_PROMOTIONS => array_map(fn ($data) => new Promotion($this->client, $data), $this->data[$name]), |
|
143
|
|
|
'availability' => new AccountAvailabilityRepository($this->client), |
|
144
|
|
|
'betaPrograms' => new BetaProgramEnrolledRepository($this->client), |
|
145
|
|
|
'events' => new EventRepository($this->client), |
|
146
|
|
|
'invoices' => new InvoiceRepository($this->client), |
|
147
|
|
|
'notifications' => new NotificationRepository($this->client), |
|
148
|
|
|
'oauth_clients' => new OAuthClientRepository($this->client), |
|
149
|
|
|
'payments' => new PaymentRepository($this->client), |
|
150
|
|
|
'paymentMethods' => new PaymentMethodRepository($this->client), |
|
151
|
|
|
'serviceTransfers' => new ServiceTransferRepository($this->client), |
|
152
|
|
|
'users' => new UserRepository($this->client), |
|
153
|
|
|
default => parent::__get($name), |
|
154
|
|
|
}; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* Updates contact and billing information related to your Account. |
|
159
|
|
|
* |
|
160
|
|
|
* @param array $parameters Update contact and billing information. |
|
161
|
|
|
* |
|
162
|
|
|
* Account properties that are excluded from a request remain unchanged. |
|
163
|
|
|
* |
|
164
|
|
|
* When updating an Account's `country` to "US", an error is returned if the |
|
165
|
|
|
* Account's `zip` is not a valid US zip code. |
|
166
|
|
|
* |
|
167
|
|
|
* @throws LinodeException |
|
168
|
|
|
*/ |
|
169
|
|
|
public function updateAccount(array $parameters = []): self |
|
170
|
|
|
{ |
|
171
|
|
|
$response = $this->client->put('/account', $parameters); |
|
172
|
|
|
$contents = $response->getBody()->getContents(); |
|
173
|
|
|
$this->data = json_decode($contents, true); |
|
174
|
|
|
|
|
175
|
|
|
return $this; |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* Cancels an active Linode account. This action will cause Linode to attempt to |
|
180
|
|
|
* charge the credit card on file for the remaining balance. An error will occur if |
|
181
|
|
|
* Linode fails to charge the credit card on file. Restricted users will not be able |
|
182
|
|
|
* to cancel an account. |
|
183
|
|
|
* |
|
184
|
|
|
* @param string $comments Any reason for cancelling the account, and any other comments you might have about |
|
185
|
|
|
* your Linode service. |
|
186
|
|
|
* |
|
187
|
|
|
* @return string A link to Linode's exit survey. |
|
188
|
|
|
* |
|
189
|
|
|
* @throws LinodeException |
|
190
|
|
|
*/ |
|
191
|
|
|
public function cancelAccount(string $comments): string |
|
192
|
|
|
{ |
|
193
|
|
|
$parameters = [ |
|
194
|
|
|
'comments' => $comments, |
|
195
|
|
|
]; |
|
196
|
|
|
|
|
197
|
|
|
$response = $this->client->post('/account/cancel', $parameters); |
|
198
|
|
|
$contents = $response->getBody()->getContents(); |
|
199
|
|
|
$json = json_decode($contents, true); |
|
200
|
|
|
|
|
201
|
|
|
return $json['survey_link']; |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
/** |
|
205
|
|
|
* **DEPRECATED**. Please use Payment Method Add (POST /account/payment-methods). |
|
206
|
|
|
* |
|
207
|
|
|
* Adds a credit card Payment Method to your account and sets it as the default |
|
208
|
|
|
* method. |
|
209
|
|
|
* |
|
210
|
|
|
* @param string $card_number Your credit card number. No spaces or dashes allowed. |
|
211
|
|
|
* @param string $expiry_month A value from 1-12 representing the expiration month of your credit card. |
|
212
|
|
|
* @param string $expiry_year A four-digit integer representing the expiration year of your credit card. |
|
213
|
|
|
* @param string $cvv The Card Verification Value on the back of the card. |
|
214
|
|
|
* |
|
215
|
|
|
* @throws LinodeException |
|
216
|
|
|
*/ |
|
217
|
|
|
public function createCreditCard(string $card_number, string $expiry_month, string $expiry_year, string $cvv): void |
|
218
|
|
|
{ |
|
219
|
|
|
$parameters = [ |
|
220
|
|
|
'card_number' => $card_number, |
|
221
|
|
|
'expiry_month' => $expiry_month, |
|
222
|
|
|
'expiry_year' => $expiry_year, |
|
223
|
|
|
'cvv' => $cvv, |
|
224
|
|
|
]; |
|
225
|
|
|
|
|
226
|
|
|
$this->client->post('/account/credit-card', $parameters); |
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
/** |
|
230
|
|
|
* Returns a collection of successful logins for all users on the account during the |
|
231
|
|
|
* last 90 days. This command can only be accessed by the unrestricted users of an |
|
232
|
|
|
* account. |
|
233
|
|
|
* |
|
234
|
|
|
* @return Login[] A collection of successful logins for all users on the account during the last 90 |
|
235
|
|
|
* days. |
|
236
|
|
|
* |
|
237
|
|
|
* @throws LinodeException |
|
238
|
|
|
*/ |
|
239
|
|
|
public function getAccountLogins(): array |
|
240
|
|
|
{ |
|
241
|
|
|
$response = $this->client->get('/account/logins'); |
|
242
|
|
|
$contents = $response->getBody()->getContents(); |
|
243
|
|
|
$json = json_decode($contents, true); |
|
244
|
|
|
|
|
245
|
|
|
return array_map(fn ($data) => new Login($this->client, $data), $json['data']); |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
|
/** |
|
249
|
|
|
* Returns a Login object that displays information about a successful login. The |
|
250
|
|
|
* logins that can be viewed can be for any user on the account, and are not limited |
|
251
|
|
|
* to only the logins of the user that is accessing this API endpoint. This command |
|
252
|
|
|
* can only be accessed by the unrestricted users of the account. |
|
253
|
|
|
* |
|
254
|
|
|
* @param int $loginId The ID of the login object to access. |
|
255
|
|
|
* |
|
256
|
|
|
* @throws LinodeException |
|
257
|
|
|
*/ |
|
258
|
|
|
public function getAccountLogin(int $loginId): Login |
|
259
|
|
|
{ |
|
260
|
|
|
$response = $this->client->get("/account/logins/{$loginId}"); |
|
261
|
|
|
$contents = $response->getBody()->getContents(); |
|
262
|
|
|
$json = json_decode($contents, true); |
|
263
|
|
|
|
|
264
|
|
|
return new Login($this->client, $json); |
|
265
|
|
|
} |
|
266
|
|
|
|
|
267
|
|
|
/** |
|
268
|
|
|
* Returns a collection of Maintenance objects for any entity a user has permissions |
|
269
|
|
|
* to view. Canceled Maintenance objects are not returned. |
|
270
|
|
|
* |
|
271
|
|
|
* Currently, Linodes are the only entities available for viewing. |
|
272
|
|
|
* |
|
273
|
|
|
* @throws LinodeException |
|
274
|
|
|
*/ |
|
275
|
|
|
public function getMaintenance(): array |
|
276
|
|
|
{ |
|
277
|
|
|
$response = $this->client->get('/account/maintenance'); |
|
278
|
|
|
$contents = $response->getBody()->getContents(); |
|
279
|
|
|
|
|
280
|
|
|
return json_decode($contents, true); |
|
281
|
|
|
} |
|
282
|
|
|
|
|
283
|
|
|
/** |
|
284
|
|
|
* Returns a Transfer object showing your network utilization, in GB, for the current |
|
285
|
|
|
* month. |
|
286
|
|
|
* |
|
287
|
|
|
* @throws LinodeException |
|
288
|
|
|
*/ |
|
289
|
|
|
public function getTransfer(): Transfer |
|
290
|
|
|
{ |
|
291
|
|
|
$response = $this->client->get('/account/transfer'); |
|
292
|
|
|
$contents = $response->getBody()->getContents(); |
|
293
|
|
|
$json = json_decode($contents, true); |
|
294
|
|
|
|
|
295
|
|
|
return new Transfer($this->client, $json); |
|
296
|
|
|
} |
|
297
|
|
|
|
|
298
|
|
|
/** |
|
299
|
|
|
* Returns information related to your Account settings: Managed service |
|
300
|
|
|
* subscription, Longview subscription, and network helper. |
|
301
|
|
|
* |
|
302
|
|
|
* @throws LinodeException |
|
303
|
|
|
*/ |
|
304
|
|
|
public function getAccountSettings(): AccountSettings |
|
305
|
|
|
{ |
|
306
|
|
|
$response = $this->client->get('/account/settings'); |
|
307
|
|
|
$contents = $response->getBody()->getContents(); |
|
308
|
|
|
$json = json_decode($contents, true); |
|
309
|
|
|
|
|
310
|
|
|
return new AccountSettings($this->client, $json); |
|
311
|
|
|
} |
|
312
|
|
|
|
|
313
|
|
|
/** |
|
314
|
|
|
* Updates your Account settings. |
|
315
|
|
|
* |
|
316
|
|
|
* To update your Longview subscription plan, send a request to Update Longview Plan. |
|
317
|
|
|
* |
|
318
|
|
|
* @param array $parameters Update Account settings information. |
|
319
|
|
|
* |
|
320
|
|
|
* @throws LinodeException |
|
321
|
|
|
*/ |
|
322
|
|
|
public function updateAccountSettings(array $parameters = []): AccountSettings |
|
323
|
|
|
{ |
|
324
|
|
|
$response = $this->client->put('/account/settings', $parameters); |
|
325
|
|
|
$contents = $response->getBody()->getContents(); |
|
326
|
|
|
$json = json_decode($contents, true); |
|
327
|
|
|
|
|
328
|
|
|
return new AccountSettings($this->client, $json); |
|
329
|
|
|
} |
|
330
|
|
|
|
|
331
|
|
|
/** |
|
332
|
|
|
* Enables Linode Managed for the entire account and sends a welcome email to the |
|
333
|
|
|
* account's associated email address. Linode Managed can monitor any service or |
|
334
|
|
|
* software stack reachable over TCP or HTTP. See our Linode Managed guide to learn |
|
335
|
|
|
* more. |
|
336
|
|
|
* |
|
337
|
|
|
* @throws LinodeException |
|
338
|
|
|
*/ |
|
339
|
|
|
public function enableAccountManaged(): void |
|
340
|
|
|
{ |
|
341
|
|
|
$this->client->post('/account/settings/managed-enable'); |
|
342
|
|
|
} |
|
343
|
|
|
|
|
344
|
|
|
/** |
|
345
|
|
|
* Send a one-time verification code via SMS message to the submitted phone number. |
|
346
|
|
|
* Providing your phone number helps ensure you can securely access your Account in |
|
347
|
|
|
* case other ways to connect are lost. Your phone number is only used to verify your |
|
348
|
|
|
* identity by sending an SMS message. Standard carrier messaging fees may apply. |
|
349
|
|
|
* |
|
350
|
|
|
* * By accessing this command you are opting in to receive SMS messages. You can opt |
|
351
|
|
|
* out of SMS messages by using the **Phone Number Delete** (DELETE |
|
352
|
|
|
* /profile/phone-number) command after your phone number is verified. |
|
353
|
|
|
* |
|
354
|
|
|
* * Verification codes are valid for 10 minutes after they are sent. |
|
355
|
|
|
* |
|
356
|
|
|
* * Subsequent requests made prior to code expiration result in sending the same |
|
357
|
|
|
* code. |
|
358
|
|
|
* |
|
359
|
|
|
* Once a verification code is received, verify your phone number with the **Phone |
|
360
|
|
|
* Number Verify** (POST /profile/phone-number/verify) command. |
|
361
|
|
|
* |
|
362
|
|
|
* @param string $iso_code The two-letter ISO 3166 country code associated with the phone number. |
|
363
|
|
|
* @param string $phone_number A valid phone number. |
|
364
|
|
|
* |
|
365
|
|
|
* @throws LinodeException |
|
366
|
|
|
*/ |
|
367
|
|
|
public function postProfilePhoneNumber(string $iso_code, string $phone_number): void |
|
368
|
|
|
{ |
|
369
|
|
|
$parameters = [ |
|
370
|
|
|
'iso_code' => $iso_code, |
|
371
|
|
|
'phone_number' => $phone_number, |
|
372
|
|
|
]; |
|
373
|
|
|
|
|
374
|
|
|
$this->client->post('/profile/phone-number', $parameters); |
|
375
|
|
|
} |
|
376
|
|
|
|
|
377
|
|
|
/** |
|
378
|
|
|
* Verify a phone number by confirming the one-time code received via SMS message |
|
379
|
|
|
* after accessing the **Phone Verification Code Send** (POST /profile/phone-number) |
|
380
|
|
|
* command. |
|
381
|
|
|
* |
|
382
|
|
|
* * Verification codes are valid for 10 minutes after they are sent. |
|
383
|
|
|
* |
|
384
|
|
|
* * Only the same User that made the verification code request can use that code |
|
385
|
|
|
* with this command. |
|
386
|
|
|
* |
|
387
|
|
|
* Once completed, the verified phone number is assigned to the User making the |
|
388
|
|
|
* request. To change the verified phone number for a User, first use the **Phone |
|
389
|
|
|
* Number Delete** (DELETE /profile/phone-number) command, then begin the |
|
390
|
|
|
* verification process again with the **Phone Verification Code Send** (POST |
|
391
|
|
|
* /profile/phone-number) command. |
|
392
|
|
|
* |
|
393
|
|
|
* @param string $otp_code The one-time code received via SMS message after accessing the **Phone |
|
394
|
|
|
* Verification Code Send** (POST /profile/phone-number) command. |
|
395
|
|
|
* |
|
396
|
|
|
* @throws LinodeException |
|
397
|
|
|
*/ |
|
398
|
|
|
public function postProfilePhoneNumberVerify(string $otp_code): void |
|
399
|
|
|
{ |
|
400
|
|
|
$parameters = [ |
|
401
|
|
|
'otp_code' => $otp_code, |
|
402
|
|
|
]; |
|
403
|
|
|
|
|
404
|
|
|
$this->client->post('/profile/phone-number/verify', $parameters); |
|
405
|
|
|
} |
|
406
|
|
|
|
|
407
|
|
|
/** |
|
408
|
|
|
* Delete the verified phone number for the User making this request. |
|
409
|
|
|
* |
|
410
|
|
|
* Use this command to opt out of SMS messages for the requesting User after a phone |
|
411
|
|
|
* number has been verified with the **Phone Number Verify** (POST |
|
412
|
|
|
* /profile/phone-number/verify) command. |
|
413
|
|
|
* |
|
414
|
|
|
* @throws LinodeException |
|
415
|
|
|
*/ |
|
416
|
|
|
public function deleteProfilePhoneNumber(): void |
|
417
|
|
|
{ |
|
418
|
|
|
$this->client->delete('/profile/phone-number'); |
|
419
|
|
|
} |
|
420
|
|
|
|
|
421
|
|
|
/** |
|
422
|
|
|
* Returns a collection of security questions and their responses, if any, for your |
|
423
|
|
|
* User Profile. |
|
424
|
|
|
* |
|
425
|
|
|
* @return SecurityQuestion[] List of security questions. |
|
426
|
|
|
* |
|
427
|
|
|
* @throws LinodeException |
|
428
|
|
|
*/ |
|
429
|
|
|
public function getSecurityQuestions(): array |
|
430
|
|
|
{ |
|
431
|
|
|
$response = $this->client->get('/profile/security-questions'); |
|
432
|
|
|
$contents = $response->getBody()->getContents(); |
|
433
|
|
|
$json = json_decode($contents, true); |
|
434
|
|
|
|
|
435
|
|
|
return array_map(fn ($data) => new SecurityQuestion($this->client, $data), $json['security_questions']); |
|
436
|
|
|
} |
|
437
|
|
|
|
|
438
|
|
|
/** |
|
439
|
|
|
* Adds security question responses for your User. |
|
440
|
|
|
* |
|
441
|
|
|
* Requires exactly three unique questions. |
|
442
|
|
|
* |
|
443
|
|
|
* Previous responses are overwritten if answered or reset to `null` if unanswered. |
|
444
|
|
|
* |
|
445
|
|
|
* **Note**: Security questions must be answered for your User prior to accessing the |
|
446
|
|
|
* **Two Factor Secret Create** (POST /profile/tfa-enable) command. |
|
447
|
|
|
* |
|
448
|
|
|
* @param array $parameters Answer Security Questions |
|
449
|
|
|
* |
|
450
|
|
|
* @return SecurityQuestion[] List of security questions. |
|
451
|
|
|
* |
|
452
|
|
|
* @throws LinodeException |
|
453
|
|
|
*/ |
|
454
|
|
|
public function postSecurityQuestions(array $parameters = []): array |
|
455
|
|
|
{ |
|
456
|
|
|
$response = $this->client->post('/profile/security-questions', $parameters); |
|
457
|
|
|
$contents = $response->getBody()->getContents(); |
|
458
|
|
|
$json = json_decode($contents, true); |
|
459
|
|
|
|
|
460
|
|
|
return array_map(fn ($data) => new SecurityQuestion($this->client, $data), $json['security_questions']); |
|
461
|
|
|
} |
|
462
|
|
|
|
|
463
|
|
|
/** |
|
464
|
|
|
* Get the details of your current Longview plan. This returns a |
|
465
|
|
|
* `LongviewSubscription` object for your current Longview Pro plan, or an empty set |
|
466
|
|
|
* `{}` if your current plan is Longview Free. |
|
467
|
|
|
* |
|
468
|
|
|
* You must have at least one of the following `global` User Grants in order to |
|
469
|
|
|
* access this endpoint: |
|
470
|
|
|
* |
|
471
|
|
|
* - `"account_access": read_write` |
|
472
|
|
|
* - `"account_access": read_only` |
|
473
|
|
|
* - `"longview_subscription": true` |
|
474
|
|
|
* - `"add_longview": true` |
|
475
|
|
|
* |
|
476
|
|
|
* To update your subscription plan, send a request to Update Longview Plan. |
|
477
|
|
|
* |
|
478
|
|
|
* @throws LinodeException |
|
479
|
|
|
*/ |
|
480
|
|
|
public function getLongviewPlan(): LongviewSubscription |
|
481
|
|
|
{ |
|
482
|
|
|
$response = $this->client->get('/longview/plan'); |
|
483
|
|
|
$contents = $response->getBody()->getContents(); |
|
484
|
|
|
$json = json_decode($contents, true); |
|
485
|
|
|
|
|
486
|
|
|
return new LongviewSubscription($this->client, $json); |
|
487
|
|
|
} |
|
488
|
|
|
|
|
489
|
|
|
/** |
|
490
|
|
|
* Update your Longview plan to that of the given subcription ID. This returns a |
|
491
|
|
|
* `LongviewSubscription` object for the updated Longview Pro plan, or an empty set |
|
492
|
|
|
* `{}` if the updated plan is Longview Free. |
|
493
|
|
|
* |
|
494
|
|
|
* You must have `"longview_subscription": true` configured as a `global` User Grant |
|
495
|
|
|
* in order to access this endpoint. |
|
496
|
|
|
* |
|
497
|
|
|
* You can send a request to the List Longview Subscriptions endpoint to receive the |
|
498
|
|
|
* details, including `id`'s, of each plan. |
|
499
|
|
|
* |
|
500
|
|
|
* @param array $parameters Update your Longview subscription plan. |
|
501
|
|
|
* |
|
502
|
|
|
* @throws LinodeException |
|
503
|
|
|
*/ |
|
504
|
|
|
public function updateLongviewPlan(array $parameters = []): LongviewSubscription |
|
505
|
|
|
{ |
|
506
|
|
|
$response = $this->client->put('/longview/plan', $parameters); |
|
507
|
|
|
$contents = $response->getBody()->getContents(); |
|
508
|
|
|
$json = json_decode($contents, true); |
|
509
|
|
|
|
|
510
|
|
|
return new LongviewSubscription($this->client, $json); |
|
511
|
|
|
} |
|
512
|
|
|
|
|
513
|
|
|
/** |
|
514
|
|
|
* Adds an expiring Promo Credit to your account. |
|
515
|
|
|
* |
|
516
|
|
|
* The following restrictions apply: |
|
517
|
|
|
* |
|
518
|
|
|
* * Your account must be less than 90 days old. |
|
519
|
|
|
* * There must not be an existing Promo Credit already on your account. |
|
520
|
|
|
* * The requesting User must be unrestricted. Use the User Update |
|
521
|
|
|
* (PUT /account/users/{username}) to change a User's restricted status. |
|
522
|
|
|
* * The `promo_code` must be valid and unexpired. |
|
523
|
|
|
* |
|
524
|
|
|
* @param array $parameters Enter a Promo Code to add its associated credit to your Account. |
|
525
|
|
|
* |
|
526
|
|
|
* @throws LinodeException |
|
527
|
|
|
*/ |
|
528
|
|
|
public function createPromoCredit(array $parameters = []): Promotion |
|
529
|
|
|
{ |
|
530
|
|
|
$response = $this->client->post('/account/promo-codes', $parameters); |
|
531
|
|
|
$contents = $response->getBody()->getContents(); |
|
532
|
|
|
$json = json_decode($contents, true); |
|
533
|
|
|
|
|
534
|
|
|
return new Promotion($this->client, $json); |
|
535
|
|
|
} |
|
536
|
|
|
|
|
537
|
|
|
/** |
|
538
|
|
|
* Returns a list of Managed Stats on your Account in the form of x and y data |
|
539
|
|
|
* points. |
|
540
|
|
|
* You can use these data points to plot your own graph visualizations. These stats |
|
541
|
|
|
* reflect the last 24 hours of combined usage across all managed Linodes on your |
|
542
|
|
|
* account |
|
543
|
|
|
* giving you a high-level snapshot of data for the following: |
|
544
|
|
|
* |
|
545
|
|
|
* * cpu |
|
546
|
|
|
* * disk |
|
547
|
|
|
* * swap |
|
548
|
|
|
* * network in |
|
549
|
|
|
* * network out |
|
550
|
|
|
* |
|
551
|
|
|
* This command can only be accessed by the unrestricted users of an account. |
|
552
|
|
|
* |
|
553
|
|
|
* @return StatsDataAvailable A list of Managed Stats from the last 24 hours. |
|
554
|
|
|
* |
|
555
|
|
|
* @throws LinodeException |
|
556
|
|
|
*/ |
|
557
|
|
|
public function getManagedStats(): StatsDataAvailable |
|
558
|
|
|
{ |
|
559
|
|
|
$response = $this->client->get('/managed/stats'); |
|
560
|
|
|
$contents = $response->getBody()->getContents(); |
|
561
|
|
|
$json = json_decode($contents, true); |
|
562
|
|
|
|
|
563
|
|
|
return new StatsDataAvailable($this->client, $json); |
|
564
|
|
|
} |
|
565
|
|
|
} |
|
566
|
|
|
|