Skip to content

Commit

Permalink
Adds implementation for (IP) Rules Lists (cloudflare#507)
Browse files Browse the repository at this point in the history
* Adds implementation for Rules Lists

* Apply suggestions from code review

Co-authored-by: Jacob Bednarz <[email protected]>

* Returns an error if BulkOperation returns an unexpected status

Co-authored-by: Christian Ehrig <[email protected]>
Co-authored-by: Jacob Bednarz <[email protected]>
  • Loading branch information
3 people authored Jul 30, 2020
1 parent a57da28 commit 4f8e993
Show file tree
Hide file tree
Showing 4 changed files with 945 additions and 12 deletions.
19 changes: 13 additions & 6 deletions cloudflare.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,21 @@ type Response struct {
Messages []ResponseInfo `json:"messages"`
}

// ResultInfoCursors contains information about cursors.
type ResultInfoCursors struct {
Before string `json:"before"`
After string `json:"after"`
}

// ResultInfo contains metadata about the Response.
type ResultInfo struct {
Page int `json:"page"`
PerPage int `json:"per_page"`
TotalPages int `json:"total_pages"`
Count int `json:"count"`
Total int `json:"total_count"`
Cursor string `json:"cursor"`
Page int `json:"page"`
PerPage int `json:"per_page"`
TotalPages int `json:"total_pages"`
Count int `json:"count"`
Total int `json:"total_count"`
Cursor string `json:"cursor"`
Cursors ResultInfoCursors `json:"cursors"`
}

// RawResponse keeps the result as JSON form
Expand Down
14 changes: 8 additions & 6 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package cloudflare

// Error messages
const (
errEmptyCredentials = "invalid credentials: key & email must not be empty"
errEmptyAPIToken = "invalid credentials: API Token must not be empty"
errMakeRequestError = "error from makeRequest"
errUnmarshalError = "error unmarshalling the JSON response"
errRequestNotSuccessful = "error reported by API"
errMissingAccountID = "account ID is empty and must be provided"
errEmptyCredentials = "invalid credentials: key & email must not be empty"
errEmptyAPIToken = "invalid credentials: API Token must not be empty"
errMakeRequestError = "error from makeRequest"
errUnmarshalError = "error unmarshalling the JSON response"
errRequestNotSuccessful = "error reported by API"
errMissingAccountID = "account ID is empty and must be provided"
errOperationStillRunning = "bulk operation did not finish before timeout"
errOperationUnexpectedStatus = "bulk operation returned an unexpected status"
)

var _ Error = &UserError{}
Expand Down
Loading

0 comments on commit 4f8e993

Please sign in to comment.