Class Settings
java.lang.Object
com.example.adkspam.Settings
Configuration read from environment variables. Mirrors
settings.py in the Python ADK
issue monitoring (spam detection) agent.
Values are exposed as accessor methods (read lazily on each call) rather than
static final fields. This keeps the class loadable in unit tests and adk web agent
loaders without a GITHUB_TOKEN present — only githubToken() throws when
the token is actually required (i.e. right before a network call).
Required variables:
GITHUB_TOKEN— GitHub Personal Access Token (or the Actions built-in token) withissues:writepermission. Required for both interactive and workflow modes.GOOGLE_API_KEY— Gemini API key. Required for both modes (or set up Vertex AI credentials andGOOGLE_GENAI_USE_VERTEXAI=TRUE).
Optional variables:
OWNER— defaults togoogle.REPO— defaults toadk-java.MODEL— Gemini model used for moderation. Defaults togemini-flash-latest(a Flash model favors latency/cost for this high-volume scan, matching the Python sample'sgemini-2.5-flash). Overridable without a code change.SPAM_LABEL_NAME— label applied to flagged issues. Defaults tospam.BOT_NAME— GitHub handle of the official bot whose content is never scanned. Defaults toadk-bot.BOT_ALERT_SIGNATURE— signature prefix the agent writes in its alert comment; also used as the idempotency marker so the agent never double-posts. Defaults to a fixed alert banner.INITIAL_FULL_SCAN—1/trueaudits every open issue; otherwise only issues updated in the last 24 hours are audited. Defaults to off (daily sweep).ISSUE_SCAN_LIMIT— safety cap on how many open issues a single sweep processes. Defaults to100.INTERACTIVE—1/truefor interactive mode (asks for confirmation before flagging),0/falsefor unattended workflow mode. Defaults to interactive when unset.DRY_RUN—1/truelogs intended labels/comments without calling the GitHub mutation endpoints. Lets you verify the full pipeline (incl. Gemini) without modifying any real issue. Defaults to off.EVENT_NAME— the GitHub event that triggered the workflow (issues,schedule, etc.). Drives single-issue vs. sweep behavior inSpamDetectionAgentRun.ISSUE_NUMBER,ISSUE_TITLE,ISSUE_BODY— populated by the GitHub Actions workflow when the trigger is an issue event.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic StringbotName()static @Nullable Stringstatic StringReturns the GitHub token, throwing a clear error if it is not configured.static booleanReturns true if aGITHUB_TOKENis configured, without throwing.static booleanisDryRun()static booleanstatic booleanstatic @Nullable Stringstatic @Nullable Stringstatic intstatic @Nullable Stringstatic Stringmodel()Returns the Gemini model used for moderation.static Stringowner()static intparseNumberString(@Nullable String value, int defaultValue) Parses a number from a string, falling back todefaultValueon null/blank/invalid input.static Stringrepo()static String
-
Method Details
-
githubToken
Returns the GitHub token, throwing a clear error if it is not configured. -
hasGithubToken
public static boolean hasGithubToken()Returns true if aGITHUB_TOKENis configured, without throwing. -
owner
-
repo
-
model
Returns the Gemini model used for moderation. Defaults togemini-flash-latest(a Flash model favors latency/cost for this high-volume scan) and is overridable via theMODELenvironment variable, so it can be changed without editing source. -
spamLabel
-
botName
-
botAlertSignature
-
isInitialFullScan
public static boolean isInitialFullScan() -
issueScanLimit
public static int issueScanLimit() -
eventName
-
issueNumber
-
issueTitle
-
issueBody
-
isInteractive
public static boolean isInteractive() -
isDryRun
public static boolean isDryRun() -
parseNumberString
Parses a number from a string, falling back todefaultValueon null/blank/invalid input. Mirrorsparse_number_stringin the Python utils.
-