Skip to content

Commit 5c09cde

Browse files
Added documentation for region.py and profile.py (#268)
## 📝 Description Added documentation for `objects/region.py` and `objects/profile.py` ## ✔️ How to Test `pytest test` Tickets: TPT-1932 and TPT-1933
1 parent 0d58bc0 commit 5c09cde

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

linode_api4/objects/profile.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44

55
class AuthorizedApp(Base):
6+
"""
7+
An application with authorized access to an account.
8+
9+
API Documentation: https://www.linode.com/docs/api/profile/#authorized-app-view
10+
"""
11+
612
api_endpoint = "/profile/apps/{id}"
713

814
properties = {
@@ -17,6 +23,12 @@ class AuthorizedApp(Base):
1723

1824

1925
class PersonalAccessToken(Base):
26+
"""
27+
A Person Access Token associated with a Profile.
28+
29+
API Documentation: https://www.linode.com/docs/api/profile/#personal-access-token-view
30+
"""
31+
2032
api_endpoint = "/profile/tokens/{id}"
2133

2234
properties = {
@@ -30,6 +42,10 @@ class PersonalAccessToken(Base):
3042

3143

3244
class WhitelistEntry(Base):
45+
"""
46+
DEPRECATED: Limited to customers with a feature tag
47+
"""
48+
3349
api_endpoint = "/profile/whitelist/{id}"
3450

3551
properties = {
@@ -41,6 +57,12 @@ class WhitelistEntry(Base):
4157

4258

4359
class Profile(Base):
60+
"""
61+
A Profile containing information about the current User.
62+
63+
API Documentation: https://www.linode.com/docs/api/profile/#profile-view
64+
"""
65+
4466
api_endpoint = "/profile"
4567
id_attribute = "username"
4668

@@ -65,6 +87,11 @@ def enable_tfa(self):
6587
"""
6688
Enables TFA for the token's user. This requies a follow-up request
6789
to confirm TFA. Returns the TFA secret that needs to be confirmed.
90+
91+
API Documentation: https://www.linode.com/docs/api/profile/#two-factor-secret-create
92+
93+
:returns: The TFA secret
94+
:rtype: str
6895
"""
6996
result = self._client.post("/profile/tfa-enable")
7097

@@ -73,6 +100,15 @@ def enable_tfa(self):
73100
def confirm_tfa(self, code):
74101
"""
75102
Confirms TFA for an account. Needs a TFA code generated by enable_tfa
103+
104+
API Documentation: https://www.linode.com/docs/api/profile/#two-factor-authentication-confirmenable
105+
106+
:param code: The Two Factor code you generated with your Two Factor secret.
107+
These codes are time-based, so be sure it is current.
108+
:type code: str
109+
110+
:returns: Returns true if operation was successful
111+
:rtype: bool
76112
"""
77113
self._client.post(
78114
"/profile/tfa-enable-confirm", data={"tfa_code": code}
@@ -83,6 +119,11 @@ def confirm_tfa(self, code):
83119
def disable_tfa(self):
84120
"""
85121
Turns off TFA for this user's account.
122+
123+
API Documentation: https://www.linode.com/docs/api/profile/#two-factor-authentication-disable
124+
125+
:returns: Returns true if operation was successful
126+
:rtype: bool
86127
"""
87128
self._client.post("/profile/tfa-disable")
88129

@@ -92,6 +133,11 @@ def disable_tfa(self):
92133
def grants(self):
93134
"""
94135
Returns grants for the current user
136+
137+
API Documentation: https://www.linode.com/docs/api/profile/#grants-list
138+
139+
:returns: The grants for the current user
140+
:rtype: UserGrants
95141
"""
96142
from linode_api4.objects.account import ( # pylint: disable-all
97143
UserGrants,
@@ -112,12 +158,16 @@ def grants(self):
112158
def whitelist(self):
113159
"""
114160
Returns the user's whitelist entries, if whitelist is enabled
161+
162+
DEPRECATED: Limited to customers with a feature tag
115163
"""
116164
return self._client._get_and_filter(WhitelistEntry)
117165

118166
def add_whitelist_entry(self, address, netmask, note=None):
119167
"""
120168
Adds a new entry to this user's IP whitelist, if enabled
169+
170+
DEPRECATED: Limited to customers with a feature tag
121171
"""
122172
result = self._client.post(
123173
"{}/whitelist".format(Profile.api_endpoint),
@@ -139,6 +189,8 @@ def add_whitelist_entry(self, address, netmask, note=None):
139189
class SSHKey(Base):
140190
"""
141191
An SSH Public Key uploaded to your profile for use in Linode Instance deployments.
192+
193+
API Documentation: https://www.linode.com/docs/api/profile/#ssh-key-view
142194
"""
143195

144196
api_endpoint = "/profile/sshkeys/{id}"
@@ -152,6 +204,12 @@ class SSHKey(Base):
152204

153205

154206
class TrustedDevice(Base):
207+
"""
208+
A Trusted Device for a User.
209+
210+
API Documentation: https://www.linode.com/docs/api/profile/#trusted-device-view
211+
"""
212+
155213
api_endpoint = "/profile/devices/{id}"
156214

157215
properties = {
@@ -165,6 +223,12 @@ class TrustedDevice(Base):
165223

166224

167225
class ProfileLogin(Base):
226+
"""
227+
A Login object displaying information about a successful account login from this user.
228+
229+
API Documentation: https://www.linode.com/docs/api/profile/#login-view
230+
"""
231+
168232
api_endpoint = "profile/logins/{id}"
169233

170234
properties = {

linode_api4/objects/region.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33

44
class Region(Base):
5+
"""
6+
A Region. Regions correspond to individual data centers, each located in a different geographical area.
7+
8+
API Documentation: https://www.linode.com/docs/api/regions/#region-view
9+
"""
10+
511
api_endpoint = "/regions/{id}"
612
properties = {
713
"id": Property(identifier=True),

0 commit comments

Comments
 (0)