Class JsonSource
java.lang.Object
hudson.model.AbstractDescribableImpl<JsonSource>
com.github.cyanbaz.jenkins.plugins.jsonparameter.JsonSource
- All Implemented Interfaces:
ExtensionPoint
,Describable<JsonSource>
,Serializable
- Direct Known Subclasses:
ConfigFileSource
,RemoteSource
public abstract class JsonSource
extends AbstractDescribableImpl<JsonSource>
implements ExtensionPoint, Serializable
Base class for all JSON data sources used in the
json-parameter-plugin
.
This abstract class defines the contract for loading JSON data from different sources, such as remote URLs or Jenkins Config File Provider entries.
Implementations must provide logic to retrieve JSON content via loadJson()
,
and can rely on the provided loadOptions(String)
method to extract
dropdown entries using a JSONPath expression.
Subclasses must be registered as Jenkins ExtensionPoint
s and extend
Descriptor
to be selectable in the UI via
dropdownDescriptorSelector
.
- Author:
- Caner Yanbaz
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract String
loadJson()
Loads the raw JSON string from the configured data source.loadOptions
(String query) Extracts a list of values from the loaded JSON using the given JSONPath query.Methods inherited from class hudson.model.AbstractDescribableImpl
getDescriptor
-
Constructor Details
-
JsonSource
public JsonSource()
-
-
Method Details
-
loadJson
Loads the raw JSON string from the configured data source.- Returns:
- a valid JSON string (never null)
- Throws:
IOException
- if the data could not be retrievedInterruptedException
- if the request is interrupted
-
loadOptions
Extracts a list of values from the loaded JSON using the given JSONPath query.This method returns a
ListBoxModel
suitable for use in Jenkins dropdown parameters. IfloadJson()
throwsIllegalStateException
, the model will contain a single disabled "Invalid" option based on a localized message.- Parameters:
query
- a valid JSONPath expression- Returns:
- a populated
ListBoxModel
-