Class GitHubSecurityAdvisoryClient
- java.lang.Object
-
- io.github.jeremylong.openvulnerability.client.ghsa.GitHubSecurityAdvisoryClient
-
- All Implemented Interfaces:
PagedDataSource<SecurityAdvisory>,java.lang.AutoCloseable,java.util.Iterator<java.util.Collection<SecurityAdvisory>>
public class GitHubSecurityAdvisoryClient extends java.lang.Object implements PagedDataSource<SecurityAdvisory>
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringGITHUB_GRAPHQL_ENDPOINT
-
Constructor Summary
Constructors Constructor Description GitHubSecurityAdvisoryClient(java.lang.String githubToken)Constructs a new client.GitHubSecurityAdvisoryClient(java.lang.String githubToken, java.lang.String endpoint)Constructs a new client.GitHubSecurityAdvisoryClient(java.lang.String githubToken, java.lang.String endpoint, HttpAsyncClientSupplier httpClientSupplier)Constructs a new client.GitHubSecurityAdvisoryClient(java.lang.String githubToken, java.lang.String endpoint, HttpAsyncClientSupplier httpClientSupplier, java.lang.String userAgent)Constructs a new client.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Cleanup allocated resources.intgetLastStatusCode()Returns the last HTTP Status Code received.java.time.ZonedDateTimegetLastUpdated()Returns the latest updated date.intgetTotalAvailable()The number of available entries; only available after the first call to `next()`.booleanhasNext()Returnstrueif there are more records available; otherwisefalse.java.util.Collection<SecurityAdvisory>next()Returns the next list of security advisories.voidsetClassifications(java.lang.String classifications)The classification of the advisory ("GENERAL", "MALWARE")voidsetPublishedSinceFilter(java.time.ZonedDateTime utcPublishedSinceFilter)Filter the Security Advisories by those published since the give date time.voidsetUpdatedSinceFilter(java.time.ZonedDateTime utcUpdatedSinceFilter)Filter the Security Advisories by those updated since the give date time.
-
-
-
Field Detail
-
GITHUB_GRAPHQL_ENDPOINT
public static final java.lang.String GITHUB_GRAPHQL_ENDPOINT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GitHubSecurityAdvisoryClient
public GitHubSecurityAdvisoryClient(java.lang.String githubToken)
Constructs a new client.- Parameters:
githubToken- the GitHub API Token.
-
GitHubSecurityAdvisoryClient
public GitHubSecurityAdvisoryClient(java.lang.String githubToken, java.lang.String endpoint)Constructs a new client.- Parameters:
endpoint- the GraphQL endpoint of GitHub or GHE.githubToken- the GitHub API Token.
-
GitHubSecurityAdvisoryClient
public GitHubSecurityAdvisoryClient(java.lang.String githubToken, java.lang.String endpoint, HttpAsyncClientSupplier httpClientSupplier)Constructs a new client.- Parameters:
githubToken- the GitHub API Token.endpoint- the GraphQL endpoint of GitHub or GHE.httpClientSupplier- supplier for custom HTTP clients; ifnulla default client will be used
-
GitHubSecurityAdvisoryClient
public GitHubSecurityAdvisoryClient(java.lang.String githubToken, java.lang.String endpoint, HttpAsyncClientSupplier httpClientSupplier, java.lang.String userAgent)Constructs a new client.- Parameters:
githubToken- the GitHub API Token.endpoint- the GraphQL endpoint of GitHub or GHE.httpClientSupplier- supplier for custom HTTP clients; ifnulla default client will be useduserAgent- the user agent to append to the default open-vulnerability-client's user-agent string
-
-
Method Detail
-
setClassifications
public void setClassifications(java.lang.String classifications)
The classification of the advisory ("GENERAL", "MALWARE")- Parameters:
classifications- the classification of the advisory.
-
setUpdatedSinceFilter
public void setUpdatedSinceFilter(java.time.ZonedDateTime utcUpdatedSinceFilter)
Filter the Security Advisories by those updated since the give date time.- Parameters:
utcUpdatedSinceFilter- the date to filter on.
-
setPublishedSinceFilter
public void setPublishedSinceFilter(java.time.ZonedDateTime utcPublishedSinceFilter)
Filter the Security Advisories by those published since the give date time.- Parameters:
utcPublishedSinceFilter- the date to filter on.
-
close
public void close() throws java.lang.ExceptionCleanup allocated resources.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacePagedDataSource<SecurityAdvisory>- Throws:
java.lang.Exception- thrown if there is a problem.
-
getTotalAvailable
public int getTotalAvailable()
The number of available entries; only available after the first call to `next()`.- Specified by:
getTotalAvailablein interfacePagedDataSource<SecurityAdvisory>- Returns:
- the number of available entries
-
getLastStatusCode
public int getLastStatusCode()
Returns the last HTTP Status Code received.- Specified by:
getLastStatusCodein interfacePagedDataSource<SecurityAdvisory>- Returns:
- the last HTTP Status Code received.
-
hasNext
public boolean hasNext()
Returnstrueif there are more records available; otherwisefalse.- Specified by:
hasNextin interfacejava.util.Iterator<java.util.Collection<SecurityAdvisory>>- Specified by:
hasNextin interfacePagedDataSource<SecurityAdvisory>- Returns:
trueif there are more records available; otherwisefalse.
-
next
public java.util.Collection<SecurityAdvisory> next()
Returns the next list of security advisories. Note that even if `hasNext()` returns true it is possible that `next()` will return null. This will generally only occur on the very first call.- Specified by:
nextin interfacejava.util.Iterator<java.util.Collection<SecurityAdvisory>>- Specified by:
nextin interfacePagedDataSource<SecurityAdvisory>- Returns:
- a list of security advisories.
-
getLastUpdated
public java.time.ZonedDateTime getLastUpdated()
Returns the latest updated date.- Specified by:
getLastUpdatedin interfacePagedDataSource<SecurityAdvisory>- Returns:
- the latest updated date
-
-