Skip to content

Commit 3455420

Browse files
doc: Improve filtering documentation (linode#301)
## 📝 Description This change makes various improvements to the documentation relevant to filtering in this repository. This includes correcting broken links, adding an import example, and linking from filter params to the filtering guide. Resolves linode#217
1 parent 83e8269 commit 3455420

19 files changed

+93
-11
lines changed

docs/guides/core_concepts.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ certain group. This library implements filtering with a SQLAlchemy-like
4949
syntax, where a model's attributes may be used in comparisons to generate
5050
filters. For example::
5151

52+
from linode_api4 import Instance
53+
5254
prod_linodes = client.linode.instances(Instance.group == "production")
5355

5456
Filters may be combined using boolean operators similar to SQLAlchemy::
5557

5658
# and_ and or_ can be imported from the linode package to combine filters
57-
from linode_api4 import or_
5859
prod_or_staging = client.linode.instances(or_(Instance.group == "production",
5960
Instance.group == "staging"))
6061

@@ -66,7 +67,7 @@ Filters may be combined using boolean operators similar to SQLAlchemy::
6667
Filters are generally only applicable for the type of model you are querying,
6768
but can be combined to your heart's content. For numeric fields, the standard
6869
numeric comparisons are accepted, and work as you'd expect. See
69-
:doc:`Filtering Collections<../linode/objects/filtering>` for full details.
70+
:doc:`Filtering Collections</linode_api4/objects/filtering>` for full details.
7071

7172
Models
7273
------

linode_api4/groups/account.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ def events(self, *filters):
4949
API Documentation: https://www.linode.com/docs/api/account/#events-list
5050
5151
:param filters: Any number of filters to apply to this query.
52+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
53+
for more details on filtering.
5254
5355
:returns: A list of events on the current account matching the given filters.
5456
:rtype: PaginatedList of Event
@@ -124,6 +126,8 @@ def oauth_clients(self, *filters):
124126
API Documentation: https://www.linode.com/docs/api/account/#oauth-clients-list
125127
126128
:param filters: Any number of filters to apply to this query.
129+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
130+
for more details on filtering.
127131
128132
:returns: A list of OAuth Clients associated with this account.
129133
:rtype: PaginatedList of OAuthClient
@@ -167,6 +171,8 @@ def users(self, *filters):
167171
API Documentation: https://www.linode.com/docs/api/account/#users-list
168172
169173
:param filters: Any number of filters to apply to this query.
174+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
175+
for more details on filtering.
170176
171177
:returns: A list of users on this account.
172178
:rtype: PaginatedList of User

linode_api4/groups/database.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ def types(self, *filters):
3333
3434
API Documentation: https://www.linode.com/docs/api/databases/#managed-database-types-list
3535
36-
:param filters: Any number of filters to apply to the query.
36+
:param filters: Any number of filters to apply to this query.
37+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
38+
for more details on filtering.
3739
3840
:returns: A list of types that match the query.
3941
:rtype: PaginatedList of DatabaseType
@@ -51,7 +53,9 @@ def engines(self, *filters):
5153
5254
API Documentation: https://www.linode.com/docs/api/databases/#managed-database-engines-list
5355
54-
:param filters: Any number of filters to apply to the query.
56+
:param filters: Any number of filters to apply to this query.
57+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
58+
for more details on filtering.
5559
5660
:returns: A list of types that match the query.
5761
:rtype: PaginatedList of DatabaseEngine
@@ -65,6 +69,8 @@ def instances(self, *filters):
6569
API Documentation: https://www.linode.com/docs/api/databases/#managed-databases-list-all
6670
6771
:param filters: Any number of filters to apply to this query.
72+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
73+
for more details on filtering.
6874
6975
:returns: A list of databases that matched the query.
7076
:rtype: PaginatedList of Database
@@ -78,6 +84,8 @@ def mysql_instances(self, *filters):
7884
API Documentation: https://www.linode.com/docs/api/databases/#managed-mysql-databases-list
7985
8086
:param filters: Any number of filters to apply to this query.
87+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
88+
for more details on filtering.
8189
8290
:returns: A list of MySQL databases that matched the query.
8391
:rtype: PaginatedList of MySQLDatabase
@@ -141,6 +149,8 @@ def postgresql_instances(self, *filters):
141149
API Documentation: https://www.linode.com/docs/api/databases/#managed-postgresql-databases-list
142150
143151
:param filters: Any number of filters to apply to this query.
152+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
153+
for more details on filtering.
144154
145155
:returns: A list of PostgreSQL databases that matched the query.
146156
:rtype: PaginatedList of PostgreSQLDatabase

linode_api4/groups/domain.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ def __call__(self, *filters):
1616
API Documentation: https://www.linode.com/docs/api/domains/#domains-list
1717
1818
:param filters: Any number of filters to apply to this query.
19+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
20+
for more details on filtering.
1921
2022
:returns: A list of Domains the acting user can access.
2123
:rtype: PaginatedList of Domain

linode_api4/groups/image.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ def __call__(self, *filters):
2020
2121
API Documentation: https://www.linode.com/docs/api/images/#images-list
2222
23-
:param filters: Any number of filters to apply to the query.
23+
:param filters: Any number of filters to apply to this query.
24+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
25+
for more details on filtering.
2426
2527
:returns: A list of available Images.
2628
:rtype: PaginatedList of Image

linode_api4/groups/linode.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ def types(self, *filters):
4141
4242
API documentation: https://www.linode.com/docs/api/linode-types/#types-list
4343
44-
:param filters: Any number of filters to apply to the query.
44+
:param filters: Any number of filters to apply to this query.
45+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
46+
for more details on filtering.
4547
4648
:returns: A list of types that match the query.
4749
:rtype: PaginatedList of Type
@@ -58,6 +60,8 @@ def instances(self, *filters):
5860
API Documentation: https://www.linode.com/docs/api/linode-instances/#linodes-list
5961
6062
:param filters: Any number of filters to apply to this query.
63+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
64+
for more details on filtering.
6165
6266
:returns: A list of Instances that matched the query.
6367
:rtype: PaginatedList of Instance
@@ -76,6 +80,8 @@ def stackscripts(self, *filters, **kwargs):
7680
API Documentation: https://www.linode.com/docs/api/stackscripts/#stackscripts-list
7781
7882
:param filters: Any number of filters to apply to this query.
83+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
84+
for more details on filtering.
7985
:param mine_only: If True, returns only private StackScripts
8086
:type mine_only: bool
8187
@@ -111,6 +117,8 @@ def kernels(self, *filters):
111117
API Documentation: https://www.linode.com/docs/api/linode-instances/#kernels-list
112118
113119
:param filters: Any number of filters to apply to this query.
120+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
121+
for more details on filtering.
114122
115123
:returns: A list of available kernels that match the query.
116124
:rtype: PaginatedList of Kernel

linode_api4/groups/lke.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def versions(self, *filters):
2222
2323
API Documentation: https://www.linode.com/docs/api/linode-kubernetes-engine-lke/#kubernetes-versions-list
2424
25-
:param filters: Any number of filters to apply to the query.
25+
:param filters: Any number of filters to apply to this query.
26+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
27+
for more details on filtering.
2628
2729
:returns: A Paginated List of kube versions that match the query.
2830
:rtype: PaginatedList of KubeVersion
@@ -36,7 +38,9 @@ def clusters(self, *filters):
3638
3739
https://www.linode.com/docs/api/linode-kubernetes-engine-lke/#kubernetes-clusters-list
3840
39-
:param filters: Any number of filters to apply to the query.
41+
:param filters: Any number of filters to apply to this query.
42+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
43+
for more details on filtering.
4044
4145
:returns: A Paginated List of LKE clusters that match the query.
4246
:rtype: PaginatedList of LKECluster

linode_api4/groups/longview.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ def clients(self, *filters):
2020
API Documentation: https://www.linode.com/docs/api/longview/#longview-clients-list
2121
2222
:param filters: Any number of filters to apply to this query.
23+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
24+
for more details on filtering.
2325
2426
:returns: A list of Longview Clients matching the given filters.
2527
:rtype: PaginatedList of LongviewClient
@@ -59,6 +61,8 @@ def subscriptions(self, *filters):
5961
API Documentation: https://www.linode.com/docs/api/longview/#longview-subscriptions-list
6062
6163
:param filters: Any number of filters to apply to this query.
64+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
65+
for more details on filtering.
6266
6367
:returns: A list of Longview Subscriptions matching the given filters.
6468
:rtype: PaginatedList of LongviewSubscription

linode_api4/groups/networking.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ def firewalls(self, *filters):
2424
API Documentation: https://www.linode.com/docs/api/networking/#firewalls-list
2525
2626
:param filters: Any number of filters to apply to this query.
27+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
28+
for more details on filtering.
2729
2830
:returns: A list of Firewalls the acting user can access.
2931
:rtype: PaginatedList of Firewall
@@ -98,6 +100,8 @@ def ips(self, *filters):
98100
API Documentation: https://www.linode.com/docs/api/networking/#ip-addresses-list
99101
100102
:param filters: Any number of filters to apply to this query.
103+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
104+
for more details on filtering.
101105
102106
:returns: A list of IP addresses on this account.
103107
:rtype: PaginatedList of IPAddress
@@ -111,6 +115,8 @@ def ipv6_ranges(self, *filters):
111115
API Documentation: https://www.linode.com/docs/api/networking/#ipv6-ranges-list
112116
113117
:param filters: Any number of filters to apply to this query.
118+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
119+
for more details on filtering.
114120
115121
:returns: A list of IPv6 ranges on this account.
116122
:rtype: PaginatedList of IPv6Range
@@ -124,6 +130,8 @@ def ipv6_pools(self, *filters):
124130
API Documentation: https://www.linode.com/docs/api/networking/#ipv6-pools-list
125131
126132
:param filters: Any number of filters to apply to this query.
133+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
134+
for more details on filtering.
127135
128136
:returns: A list of IPv6 pools on this account.
129137
:rtype: PaginatedList of IPv6Pool
@@ -140,6 +148,8 @@ def vlans(self, *filters):
140148
API Documentation: https://www.linode.com/docs/api/networking/#vlans-list
141149
142150
:param filters: Any number of filters to apply to this query.
151+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
152+
for more details on filtering.
143153
144154
:returns: A List of VLANs on your account.
145155
:rtype: PaginatedList of VLAN

linode_api4/groups/nodebalancer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ def __call__(self, *filters):
1616
API Documentation: https://www.linode.com/docs/api/nodebalancers/#nodebalancers-list
1717
1818
:param filters: Any number of filters to apply to this query.
19+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
20+
for more details on filtering.
1921
2022
:returns: A list of NodeBalancers the acting user can access.
2123
:rtype: PaginatedList of NodeBalancers

linode_api4/groups/obj.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ def clusters(self, *filters):
1919
API Documentation: https://www.linode.com/docs/api/object-storage/#clusters-list
2020
2121
:param filters: Any number of filters to apply to this query.
22+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
23+
for more details on filtering.
2224
2325
:returns: A list of Object Storage Clusters that matched the query.
2426
:rtype: PaginatedList of ObjectStorageCluster
@@ -33,6 +35,8 @@ def keys(self, *filters):
3335
API Documentation: https://www.linode.com/docs/api/object-storage/#object-storage-keys-list
3436
3537
:param filters: Any number of filters to apply to this query.
38+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
39+
for more details on filtering.
3640
3741
:returns: A list of Object Storage Keys that matched the query.
3842
:rtype: PaginatedList of ObjectStorageKeys

linode_api4/groups/object_storage.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ def clusters(self, *filters):
2727
API Documentation: https://www.linode.com/docs/api/object-storage/#clusters-list
2828
2929
:param filters: Any number of filters to apply to this query.
30+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
31+
for more details on filtering.
3032
3133
:returns: A list of Object Storage Clusters that matched the query.
3234
:rtype: PaginatedList of ObjectStorageCluster
@@ -41,6 +43,8 @@ def keys(self, *filters):
4143
API Documentation: https://www.linode.com/docs/api/object-storage/#object-storage-keys-list
4244
4345
:param filters: Any number of filters to apply to this query.
46+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
47+
for more details on filtering.
4448
4549
:returns: A list of Object Storage Keys that matched the query.
4650
:rtype: PaginatedList of ObjectStorageKeys
@@ -174,6 +178,10 @@ def buckets(self, *filters):
174178
175179
API Documentation: https://www.linode.com/docs/api/object-storage/#object-storage-buckets-list
176180
181+
:param filters: Any number of filters to apply to this query.
182+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
183+
for more details on filtering.
184+
177185
:returns: A list of Object Storage Buckets that matched the query.
178186
:rtype: PaginatedList of ObjectStorageBucket
179187
"""

linode_api4/groups/profile.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ def tokens(self, *filters):
227227
API Documentation: https://www.linode.com/docs/api/profile/#personal-access-tokens-list
228228
229229
:param filters: Any number of filters to apply to this query.
230+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
231+
for more details on filtering.
230232
231233
:returns: A list of tokens that matches the query.
232234
:rtype: PaginatedList of PersonalAccessToken
@@ -276,6 +278,8 @@ def apps(self, *filters):
276278
API Documentation: https://www.linode.com/docs/api/profile/#authorized-apps-list
277279
278280
:param filters: Any number of filters to apply to this query.
281+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
282+
for more details on filtering.
279283
280284
:returns: A list of Authorized Applications for this user
281285
:rtype: PaginatedList of AuthorizedApp
@@ -289,6 +293,8 @@ def ssh_keys(self, *filters):
289293
API Documentation: https://www.linode.com/docs/api/profile/#ssh-keys-list
290294
291295
:param filters: Any number of filters to apply to this query.
296+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
297+
for more details on filtering.
292298
293299
:returns: A list of SSH Keys for this profile.
294300
:rtype: PaginatedList of SSHKey

linode_api4/groups/region.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ def __call__(self, *filters):
1414
1515
API Documentation: https://www.linode.com/docs/api/regions/#regions-list
1616
17-
:param filters: Any number of filters to apply to the query.
17+
:param filters: Any number of filters to apply to this query.
18+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
19+
for more details on filtering.
1820
1921
:returns: A list of available Regions.
2022
:rtype: PaginatedList of Region

linode_api4/groups/support.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def tickets(self, *filters):
2626
API Documentation: https://www.linode.com/docs/api/support/#support-tickets-list
2727
2828
:param filters: Any number of filters to apply to this query.
29+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
30+
for more details on filtering.
2931
3032
:returns: A list of support tickets on this account.
3133
:rtype: PaginatedList of SupportTicket

linode_api4/groups/tag.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ def __call__(self, *filters):
1717
API Documentation: https://www.linode.com/docs/api/domains/#domain-create
1818
1919
:param filters: Any number of filters to apply to this query.
20+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
21+
for more details on filtering.
2022
2123
:returns: A list of Tags on the account.
2224
:rtype: PaginatedList of Tag

linode_api4/groups/volume.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ def __call__(self, *filters):
1616
API Documentation: https://www.linode.com/docs/api/volumes/#volumes-list
1717
1818
:param filters: Any number of filters to apply to this query.
19+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
20+
for more details on filtering.
1921
2022
:returns: A list of Volumes the acting user can access.
2123
:rtype: PaginatedList of Volume

linode_api4/objects/filtering.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
class of one of its groups, any number of filters may be passed in as boolean
77
comparisons between attributes of the model returned by the collection.
88
9+
When filtering on API responses for list endpoints, you will first need
10+
to import the corresponding object class.
11+
For example, to filter on instances you must first Import :any:`Instance`::
12+
13+
from linode_api4 import Instance
14+
915
For example, calling :any:`instances` returns a list of :any:`Instance`
1016
objects, so we can use properties of :any:`Instance` to filter the results::
1117

linode_api4/objects/object_storage.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,9 @@ def buckets_in_cluster(self, *filters):
481481
482482
API Documentation: https://www.linode.com/docs/api/object-storage/#object-storage-buckets-in-cluster-list
483483
484-
:param cluster_id: The ID of the cluster this bucket exists in.
485-
:type cluster_id: str
484+
:param filters: Any number of filters to apply to this query.
485+
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
486+
for more details on filtering.
486487
487488
:returns: A list of Object Storage Buckets that in the requested cluster.
488489
:rtype: PaginatedList of ObjectStorageBucket

0 commit comments

Comments
 (0)