Class CountVisitsRequest


public class CountVisitsRequest extends GetRequest
Request to count visits. Corresponds to endpoint GET /v1/gatekeeper/visits/count. EXPERIMENTAL: This route is not guaranteed to have stable performance yet. The API is also subject to change, based on supportable queries.

Sample 1:

 // Count number of visits from IP address 1.2.3.4 that were denied.
 int numVisits = gatekeeperClient.newCountVisitsRequest()
     .ip("1.2.3.4")
     .authorization("deny")
     .send();
 

Sample 2:

 // Count number of visits from Google crawler in the past 30 days.
 int numVisits = gatekeeperClient.newCountVisitsRequest()
     .tag("Google crawler")
     .earliest(OffsetDateTime.now().minusDays(30))
     .send();
 
  • Constructor Details

  • Method Details

    • getPath

      protected String getPath()
      Specified by:
      getPath in class BaseApiRequest
    • ip

      public CountVisitsRequest ip(String strIpAddress)
      Sets the IP address to query. Expects dot notation for IPv4 and hexadecimal for IPv6.
      Parameters:
      strIpAddress - the IP address in dot or hexadecimal format
      Returns:
      this
    • userId

      public CountVisitsRequest userId(long lUserId)
      Sets the user ID to query.
      Parameters:
      lUserId - the user ID
      Returns:
      this
    • tag

      public CountVisitsRequest tag(String strTag)
      Sets the tag to query. See the supported tags page for available options.
      Parameters:
      strTag - the tag name
      Returns:
      this
    • country

      public CountVisitsRequest country(String strCountry)
      Sets the country to query. Expects either a ISO 3166 alpha-2 country code (e.g. "US", "JP") or a full country name (e.g. "United States", "Japan"). For a full list of supported values, see the IANA Language Subtag Registry and search for "Type: region".
      Parameters:
      strCountry - the country name or country code
      Returns:
      this
    • pagePrefix

      public CountVisitsRequest pagePrefix(String strPagePrefix)
      Sets the page prefix to query. The page is everything in the URL from the first "/" onward (e.g. in "https://www.example.com/index.html?a=b", the page would be "/index.html?a=b"). The visit's page must start with the page prefix to be counted.
      Parameters:
      strPagePrefix - the page prefix
      Returns:
      this
    • authorization

      public CountVisitsRequest authorization(String strAuthorization)
      Sets the authorization to query. Valid authorizations include "allow", "deny", "captcha", and any custom authorizations. Only applicable to visits created by the visit authorization route.
      Parameters:
      strAuthorization - the authorization
      Returns:
      this
    • earliest

      public CountVisitsRequest earliest(OffsetDateTime timestamp)
      Sets the earliest time to query. Visits before this time will not be counted.
      Parameters:
      timestamp - the earliest timestamp
      Returns:
      this
    • earliest

      public CountVisitsRequest earliest(Instant timestamp)
      Sets the earliest time to query. Visits before this time will not be counted.
      Parameters:
      timestamp - the earliest timestamp
      Returns:
      this
    • earliest

      public CountVisitsRequest earliest(long lTimestamp)
      Sets the earliest time to query. Visits before this time will not be counted.
      Parameters:
      lTimestamp - the earliest timestamp in epoch milliseconds
      Returns:
      this
    • latest

      public CountVisitsRequest latest(OffsetDateTime timestamp)
      Sets the latest time to query. Visits after this time will not be counted.
      Parameters:
      timestamp - the latest timestamp
      Returns:
      this
    • latest

      public CountVisitsRequest latest(Instant timestamp)
      Sets the latest time to query. Visits after this time will not be counted.
      Parameters:
      timestamp - the latest timestamp
      Returns:
      this
    • latest

      public CountVisitsRequest latest(long lTimestamp)
      Sets the latest time to query. Visits after this time will not be counted.
      Parameters:
      lTimestamp - the latest timestamp in epoch milliseconds
      Returns:
      this
    • send

      public int send() throws NetToolKitException
      Sends the request.
      Returns:
      the visit count for IP address as seen by policy
      Throws:
      NetToolKitException