subkt / myaa.subkt.tasks / HTTP
open class HTTP :
PropertyTask
,
SubTask
(source)
Task for sending general HTTP requests. Data should be sent using one of json, body and form. The response can be retrieved from responseData or responseJson.
"http"<HTTP> {
host("example.com")
endpoint("/api/v2/post")
port(8080)
https(false)
method("POST")
json(
"content" to "This is the content",
"author" to "Jane Doe"
)
// equivalently:
contentType(ContentType.Application.Json)
body("{\"content\":\"This is the content\",\"author\":\"Jane Doe\"}")
doLast {
println(responseData)
}
}
Name | Summary |
---|---|
<init> | HTTP() Task for sending general HTTP requests. Data should be sent using one of json, body and form. The response can be retrieved from responseData or responseJson. |
Name | Summary |
---|---|
attachment | val attachment: ConfigurableFileCollection ! Binary file data to send. |
basicAuthPass | val basicAuthPass: Property < String > Password for basic authentication. |
basicAuthUser | val basicAuthUser: Property < String > Username for basic authentication. |
body | val body: Property < String > Plain text data to send. |
contentType | val contentType: Property <ContentType> The content type. Only used if sending data using body. |
endpoint | val endpoint: Property < String > The endpoint to request. Defaults to /. |
form | val form: MapProperty < String , String > URL encoded form data to send. |
headers | val headers: Provider < Map < String , String >> HTTP headers. |
host | val host: Property < String > The hostname or IP address. |
https | val https: Property < Boolean > If true, use HTTPS; HTTP otherwise. Defaults to true. |
json | val json: MapProperty < String , Any > JSON data to send. |
method | val method: Property < String > The HTTP method. Defaults to GET. |
out | val out: File |
parameters | val parameters: Provider < Map < String , String >> Query parameters. |
port | val port: Property < Int > The port to use. Defaults to the default port for the protocol used. |
responseData | var responseData: String The response. |
responseJson | val responseJson: JsonElement The response as JSON. |
urlPass | val urlPass: Property < String > A password for https://username:[email protected] style authentication. |
urlUser | val urlUser: Property < String > A username for https://username:[email protected] style authentication. |
userAgent | val userAgent: Property < String > The user agent. |
Name | Summary |
---|---|
propertyFile | val propertyFile: File |
Name | Summary |
---|---|
header | fun header(name: String , value: Provider < String >): Unit fun header(name: String , value: String ): Unit Add an HTTP header. |
parameter | fun parameter(name: String , value: Provider < String >): Unit fun parameter(name: String , value: String ): Unit Add a query parameter. |
run | open fun run(): Unit |
Name | Summary |
---|---|
doTask | fun doTask(): Unit |
Name | Summary |
---|---|
batch | val Task .batch: String The same as entry if this is a batch task; error otherwise. |
currentTask | val Task .currentTask: String The name of this task. |
entry | val Task .entry: String The entry (batch or episode) this task corresponds to. |
episode | val Task .episode: String The same as entry if this is an episode task; error otherwise. |
episodes | val Task .episodes: List < String > The episodes this task corresponds to. A single-item list containing episode if this is an episode task; a list of the episodes for the batch given by batch otherwise. |
isBatch | val Task .isBatch: Boolean True if this task is a batch task. |
release | val Task .release: String The release this task was generated for. |
taskGroup | val <T : Task > T .taskGroup: TaskGroup < T > The TaskGroup instance this task belongs to. |
Name | Summary |
---|---|
defaultProperty | fun <T> Task .defaultProperty(default: T ): Property < T > Returns a Property with a default value set. |
evaluate | fun Task .evaluate(expression: String ): Provider < List < String >!>! Evaluates a string using Velocity, splits it on ` |
evaluateTemplate | fun Task .evaluateTemplate(expression: String ): Provider < String !>! Like evaluate but only processes the template syntax, without globbing. |
get | fun Task .get(propertyName: String ): Provider < String !>! Searches for the given property in the Subs object's SubProperties instance, evaluates its value using evaluate, and returns a single string, assuming that the resulting list contains only one element. |
getAs | fun <T> Task .getAs(propertyName: String ): Provider < T >! Searches for the given property in the Subs object's SubProperties instance, evaluates its value using evaluate, and returns a single string, cast to the given type using String.asType, assuming that the resulting list contains only one element. |
getFile | fun Task .getFile(filename: String ): Provider < String !>! fun Task .getFile(filename: Provider < String >): Provider < String !>! Reads the specified file and processes it using Velocity. |
getList | fun Task .getList(propertyName: String ): Provider < List < String >> Searches for the given property in the Subs object's SubProperties instance, and evaluates its value using evaluate. |
getListAs | fun <T> Task .getListAs(propertyName: String ): Provider < List < T >!>! Searches for the given property in the Subs object's SubProperties instance, evaluates its value using evaluate, and casts the list elements to the given type using String.asType. |
getRaw | fun Task .getRaw(propertyName: String ): String Searches for the given property in the Subs object's SubProperties instance, and returns the raw string. Raises an error if not found. |
getRawMaybe | fun Task .getRawMaybe(propertyName: String ): String ? Searches for the given property in the Subs object's SubProperties instance, and returns the raw string, possibly null. |
outputFile | fun Task .outputFile(extension: String ): ConfigurableFileCollection Returns a ConfigurableFileCollection containing a single file taskName.extension located in the build directory. |
propertyExists | fun Task .propertyExists(propertyName: String ): Boolean Returns true if the given property exists in the Subs object's SubProperties instance for the given context. |