Package codes.thischwa.cf.model
Record Class PagingRequest
java.lang.Object
java.lang.Record
codes.thischwa.cf.model.PagingRequest
Immutable pagination parameters for Cloudflare list endpoints. Page numbers start at 1.
Use forZones(int, int) for zone requests and forRecords(int, int) for DNS
record requests. For example:
List<RecordEntity> records = client.recordList(zone, PagingRequest.forRecords(1, 100));
List<ZoneEntity> zones = client.zoneList(PagingRequest.forZones(1, 50));
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault page size, valid for zones and DNS records.static final intMaximum number of DNS records allowed per page by Cloudflare.static final intMaximum number of zones allowed per page by Cloudflare.static final intMinimum number of zones allowed per page by Cloudflare. -
Constructor Summary
ConstructorsConstructorDescriptionPagingRequest(int page, int perPage) Validates the page number and page size. -
Method Summary
Modifier and TypeMethodDescriptionaddQueryString(String endpoint) Appends Cloudflare-compatible pagination parameters (pageandper_page) to an endpoint.static PagingRequestCreates a request for page 1 with 50 items per page.final booleanIndicates whether some other object is "equal to" this one.static PagingRequestforRecords(int page, int perPage) Creates pagination parameters for a DNS record request.static PagingRequestforZones(int page, int perPage) Creates pagination parameters for a zone request.final inthashCode()Returns a hash code value for this object.next()Returns a request for the next page, retaining the current page size.intpage()Returns the value of thepagerecord component.intperPage()Returns the value of theperPagerecord component.final StringtoString()Returns a string representation of this record class.withPage(int page) Returns a copy of this request with the specified page number.
-
Field Details
-
DEFAULT_PAGE_SIZE
public static final int DEFAULT_PAGE_SIZEDefault page size, valid for zones and DNS records.- See Also:
-
MAX_RECORDS_PER_PAGE
public static final int MAX_RECORDS_PER_PAGEMaximum number of DNS records allowed per page by Cloudflare.- See Also:
-
MIN_ZONES_PER_PAGE
public static final int MIN_ZONES_PER_PAGEMinimum number of zones allowed per page by Cloudflare.- See Also:
-
MAX_ZONES_PER_PAGE
public static final int MAX_ZONES_PER_PAGEMaximum number of zones allowed per page by Cloudflare.- See Also:
-
-
Constructor Details
-
PagingRequest
public PagingRequest(int page, int perPage) Validates the page number and page size.
-
-
Method Details
-
forRecords
Creates pagination parameters for a DNS record request.- Parameters:
page- the 1-based page numberperPage- the number of records per page, from 1 to 5000000- Returns:
- the validated pagination request
- Throws:
IllegalArgumentException- if either value is outside its allowed range
-
forZones
Creates pagination parameters for a zone request.- Parameters:
page- the 1-based page numberperPage- the number of zones per page, from 5 to 50- Returns:
- the validated pagination request
- Throws:
IllegalArgumentException- if either value is outside its allowed range
-
defaultPaging
Creates a request for page 1 with 50 items per page. This requests one page; it does not fetch additional pages.- Returns:
- the default pagination request
-
next
Returns a request for the next page, retaining the current page size.- Returns:
- the next page request
-
withPage
Returns a copy of this request with the specified page number.- Parameters:
page- the 1-based page number- Returns:
- the updated pagination request
-
addQueryString
Appends Cloudflare-compatible pagination parameters (pageandper_page) to an endpoint.- Parameters:
endpoint- the base URL or API endpoint, optionally containing a query string- Returns:
- the endpoint with pagination parameters appended
- Throws:
NullPointerException- ifendpointisnull
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
page
public int page()Returns the value of thepagerecord component.- Returns:
- the value of the
pagerecord component
-
perPage
public int perPage()Returns the value of theperPagerecord component.- Returns:
- the value of the
perPagerecord component
-