Skip to content

Add getCollection and getSingle on Client#3

Merged
ndamiens merged 3 commits intondamiens:masterfrom
richardlawley:add-getcollection
Nov 6, 2023
Merged

Add getCollection and getSingle on Client#3
ndamiens merged 3 commits intondamiens:masterfrom
richardlawley:add-getcollection

Conversation

@richardlawley
Copy link
Contributor

@richardlawley richardlawley commented Aug 8, 2023

This PR introduces a number of small changes:

  • Refactor code in Client.php to use getCollection or getSingle
  • Modify constructor of Collection to accept a single item (so URLs like /api/tenancy/tenants/1 can be used instead of /api/tenancy/tenants/?id=1)
  • Use correct URLs for collections (/api/tenancy/tenants redirects to /api/tenancy/tenants/ - works but extra request)
  • Use correct URLs for single items (/api/tenancy/tenants/1 instead of /api/tenancy/tenants/?id=1)

The main purpose here was to allow users of the client to call getCollection or getSingle directly, for cases where the correct endpoint has not been defined. For example, there is no getRegions in this client. but a user can call getCollection('/api/dcim/regions/') instead now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants