Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
Listsendpoint for account-level lists (IP, hostname, ASN and redirect) that rule expressions use, e.g.ip.src in $my_list. The SDK had no way to manage these, so you had to call the adapter directly.Changes
New
Cloudflare\API\Endpoints\Listsclass, following the pattern of the other endpoints (getBody()returns the last response):listLists($accountId)GET accounts/{account_id}/rules/listsgetListDetails($accountId, $listId)GET accounts/{account_id}/rules/lists/{list_id}createList($accountId, $kind, $name, $description = '')POST accounts/{account_id}/rules/listsupdateListDescription($accountId, $listId, $description)PUT accounts/{account_id}/rules/lists/{list_id}deleteList($accountId, $listId)DELETE accounts/{account_id}/rules/lists/{list_id}listListItems($accountId, $listId, $search = '', $perPage = 0, $cursor = '')GET accounts/{account_id}/rules/lists/{list_id}/itemsgetListItem($accountId, $listId, $itemId)GET accounts/{account_id}/rules/lists/{list_id}/items/{item_id}createListItems($accountId, $listId, $items)POST accounts/{account_id}/rules/lists/{list_id}/itemsreplaceListItems($accountId, $listId, $items)PUT accounts/{account_id}/rules/lists/{list_id}/itemsdeleteListItems($accountId, $listId, $itemIds)DELETE accounts/{account_id}/rules/lists/{list_id}/itemsgetBulkOperation($accountId, $operationId)GET accounts/{account_id}/rules/lists/bulk_operations/{operation_id}Notes on behaviour:
getBulkOperation()returns its status (pending,running,completed, orfailedwith anerrormessage).$itemsis passed as is, so it works for any list kind, e.g.[['ip' => '192.0.2.1', 'comment' => 'optional']].listListItems()returnsresultandresult_info. To get the next page, passresult_info->cursors->afteras$cursor.AccessRules.Also updated the README feature list and added an Unreleased entry to the changelog.
Example
Testing
tests/Endpoints/ListsTest.php(13 tests) with JSON fixtures taken from the API reference.make fixchanged nothing, and phpmd reports nothing for the new files.make test: everything passes except 5 tests inGuzzleTest, which call httpbin.org and fail onmasteras well. They don't touch the code in this PR.API reference: https://developers.cloudflare.com/api/resources/rules/subresources/lists/