Record Class PagingRequest

java.lang.Object
java.lang.Record
codes.thischwa.cf.model.PagingRequest

public record PagingRequest(int page, int perPage) extends Record
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

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Default page size, valid for zones and DNS records.
    static final int
    Maximum number of DNS records allowed per page by Cloudflare.
    static final int
    Maximum number of zones allowed per page by Cloudflare.
    static final int
    Minimum number of zones allowed per page by Cloudflare.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PagingRequest(int page, int perPage)
    Validates the page number and page size.
  • Method Summary

    Modifier and Type
    Method
    Description
    Appends Cloudflare-compatible pagination parameters (page and per_page) to an endpoint.
    Creates a request for page 1 with 50 items per page.
    final boolean
    Indicates whether some other object is "equal to" this one.
    forRecords(int page, int perPage)
    Creates pagination parameters for a DNS record request.
    forZones(int page, int perPage)
    Creates pagination parameters for a zone request.
    final int
    Returns a hash code value for this object.
    Returns a request for the next page, retaining the current page size.
    int
    Returns the value of the page record component.
    int
    Returns the value of the perPage record component.
    final String
    Returns a string representation of this record class.
    withPage(int page)
    Returns a copy of this request with the specified page number.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • DEFAULT_PAGE_SIZE

      public static final int DEFAULT_PAGE_SIZE
      Default page size, valid for zones and DNS records.
      See Also:
    • MAX_RECORDS_PER_PAGE

      public static final int MAX_RECORDS_PER_PAGE
      Maximum number of DNS records allowed per page by Cloudflare.
      See Also:
    • MIN_ZONES_PER_PAGE

      public static final int MIN_ZONES_PER_PAGE
      Minimum number of zones allowed per page by Cloudflare.
      See Also:
    • MAX_ZONES_PER_PAGE

      public static final int MAX_ZONES_PER_PAGE
      Maximum 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

      public static PagingRequest forRecords(int page, int perPage)
      Creates pagination parameters for a DNS record request.
      Parameters:
      page - the 1-based page number
      perPage - 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

      public static PagingRequest forZones(int page, int perPage)
      Creates pagination parameters for a zone request.
      Parameters:
      page - the 1-based page number
      perPage - 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

      public static PagingRequest 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

      public PagingRequest next()
      Returns a request for the next page, retaining the current page size.
      Returns:
      the next page request
    • withPage

      public PagingRequest withPage(int page)
      Returns a copy of this request with the specified page number.
      Parameters:
      page - the 1-based page number
      Returns:
      the updated pagination request
    • addQueryString

      public String addQueryString(String endpoint)
      Appends Cloudflare-compatible pagination parameters (page and per_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 - if endpoint is null
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • page

      public int page()
      Returns the value of the page record component.
      Returns:
      the value of the page record component
    • perPage

      public int perPage()
      Returns the value of the perPage record component.
      Returns:
      the value of the perPage record component