use std/data/string_map::StringMap
use std/data/string_map::|map
use std/flow::emit
use std/flow::trigger
use std/ops/option::|unwrap_or
use root/client::HttpClient
use root/status::HttpStatus
use root/client::delete as fullDelete
use root/client::get as fullGet
use root/client::head as fullHead
use root/client::options as fullOptions
use root/client::patch as fullPatch
use root/client::post as fullPost
use root/client::put as fullPut
use root/client::trace as fullTrace
/** Performs HTTP DELETE operation.
Parameters:
- `url`: the URL to call DELETE on.
- `headers`: headers to send in request.
Inputs:
- `trigger`: starts the request.
Outputs:
- `status`: HTTP status response.
- `headers`: headers received in response.
- `data`: data received as response, corresponding to the HTTP body.
- `completed`: emitted when the request finished successfully.
- `failed`: emitted if the request failed technically.
- `error`: message containing error when request failed technically.
- `finished`: emitted when the request finished, regardless of state.
Also see [MDN documentation](https://developer.mozilla.org/docs/Web/HTTP/Methods/DELETE).
*/
treatment delete(url: string, headers: Option<StringMap> = _)
model client: HttpClient(
base_url = _,
headers = |map([])
)
input trigger: Block<void>
output data: Stream<byte>
output headers: Block<StringMap>
output completed: Block<void>
output failed: Block<void>
output finished: Block<void>
output error: Block<string>
output status: Block<HttpStatus>
{
fullDelete[client=client]()
url: emit<string>(value=url)
headers: emit<StringMap>(value=|unwrap_or<StringMap>(headers, |map([])))
Self.trigger -----> url.trigger,emit -> fullDelete.url
Self.trigger -> headers.trigger,emit -> fullDelete.headers
fullDelete.data --------> Self.data
fullDelete.headers -----> Self.headers
fullDelete.completed ---> Self.completed
fullDelete.failed ------> Self.failed
fullDelete.finished ----> Self.finished
fullDelete.error -------> Self.error
fullDelete.status ------> Self.status
}
/** Performs HTTP GET operation.
Parameters:
- `url`: the URL to call GET on.
- `headers`: headers to send in request.
Inputs:
- `trigger`: starts the request.
Outputs:
- `status`: HTTP status response.
- `headers`: headers received in response.
- `data`: data received as response, corresponding to the HTTP body.
- `completed`: emitted when the request finished successfully.
- `failed`: emitted if the request failed technically.
- `error`: message containing error when request failed technically.
- `finished`: emitted when the request finished, regardless of state.
Also see [MDN documentation](https://developer.mozilla.org/docs/Web/HTTP/Methods/GET).
*/
treatment get(url: string, headers: Option<StringMap> = _)
model client: HttpClient(
base_url = _,
headers = |map([])
)
input trigger: Block<void>
output data: Stream<byte>
output headers: Block<StringMap>
output completed: Block<void>
output failed: Block<void>
output finished: Block<void>
output error: Block<string>
output status: Block<HttpStatus>
{
fullGet[client=client]()
url: emit<string>(value=url)
headers: emit<StringMap>(value=|unwrap_or<StringMap>(headers, |map([])))
Self.trigger -----> url.trigger,emit -> fullGet.url
Self.trigger -> headers.trigger,emit -> fullGet.headers
fullGet.status ----> Self.status
fullGet.headers ---> Self.headers
fullGet.data ------> Self.data
fullGet.completed -> Self.completed
fullGet.failed ----> Self.failed
fullGet.finished --> Self.finished
fullGet.error -----> Self.error
}
/** Performs HTTP HEAD operation.
Parameters:
- `url`: the URL to call HEAD on.
- `headers`: headers to send in request.
Inputs:
- `trigger`: starts the request.
Outputs:
- `status`: HTTP status response.
- `headers`: headers received in response.
- `completed`: emitted when the request finished successfully.
- `failed`: emitted if the request failed technically.
- `error`: message containing error when request failed technically.
- `finished`: emitted when the request finished, regardless of state.
Also see [MDN documentation](https://developer.mozilla.org/docs/Web/HTTP/Methods/HEAD).
*/
treatment head(url: string, headers: Option<StringMap> = _)
model client: HttpClient(
base_url = _,
headers = |map([])
)
input trigger: Block<void>
output headers: Block<StringMap>
output completed: Block<void>
output failed: Block<void>
output finished: Block<void>
output error: Block<string>
output status: Block<HttpStatus>
{
fullHead[client=client]()
url: emit<string>(value=url)
headers: emit<StringMap>(value=|unwrap_or<StringMap>(headers, |map([])))
Self.trigger -----> url.trigger,emit -> fullHead.url
Self.trigger -> headers.trigger,emit -> fullHead.headers
fullHead.status ----> Self.status
fullHead.headers ---> Self.headers
fullHead.completed -> Self.completed
fullHead.failed ----> Self.failed
fullHead.finished --> Self.finished
fullHead.error -----> Self.error
}
/** Performs HTTP OPTIONS operation.
Parameters:
- `url`: the URL to call OPTIONS on.
- `headers`: headers to send in request.
Inputs:
- `trigger`: starts the request.
Outputs:
- `status`: HTTP status response.
- `headers`: headers received in response.
- `data`: data received as response, corresponding to the HTTP body.
- `completed`: emitted when the request finished successfully.
- `failed`: emitted if the request failed technically.
- `error`: message containing error when request failed technically.
- `finished`: emitted when the request finished, regardless of state.
Also see [MDN documentation](https://developer.mozilla.org/docs/Web/HTTP/Methods/OPTIONS).
*/
treatment options(url: string, headers: Option<StringMap> = _)
model client: HttpClient(
base_url = _,
headers = |map([])
)
input trigger: Block<void>
output data: Stream<byte>
output headers: Block<StringMap>
output completed: Block<void>
output failed: Block<void>
output finished: Block<void>
output error: Block<string>
output status: Block<HttpStatus>
{
fullOptions[client=client]()
url: emit<string>(value=url)
headers: emit<StringMap>(value=|unwrap_or<StringMap>(headers, |map([])))
Self.trigger -----> url.trigger,emit -> fullOptions.url
Self.trigger -> headers.trigger,emit -> fullOptions.headers
fullOptions.status ----> Self.status
fullOptions.headers ---> Self.headers
fullOptions.data ------> Self.data
fullOptions.completed -> Self.completed
fullOptions.failed ----> Self.failed
fullOptions.finished --> Self.finished
fullOptions.error -----> Self.error
}
/** Performs HTTP PATCH operation.
Parameters:
- `url`: the URL to call PATCH on.
- `headers`: headers to send in request.
Inputs:
- `data`: data sent in request, corresponding to the HTTP body.
Outputs:
- `status`: HTTP status response.
- `headers`: headers received in response.
- `completed`: emitted when the request finished successfully.
- `failed`: emitted if the request failed technically.
- `error`: message containing error when request failed technically.
- `finished`: emitted when the request finished, regardless of state.
Also see [MDN documentation](https://developer.mozilla.org/docs/Web/HTTP/Methods/PATCH).
*/
treatment patch(url: string, headers: Option<StringMap> = _)
model client: HttpClient(
base_url = _,
headers = |map([])
)
input data: Stream<byte>
output headers: Block<StringMap>
output completed: Block<void>
output failed: Block<void>
output finished: Block<void>
output error: Block<string>
output status: Block<HttpStatus>
{
fullPatch[client=client]()
trigger<byte>()
url: emit<string>(value=url)
headers: emit<StringMap>(value=|unwrap_or<StringMap>(headers, |map([])))
Self.data -> trigger.stream,start -----> url.trigger,emit -> fullPatch.url
trigger.start --------> headers.trigger,emit -> fullPatch.headers
Self.data -------------------------------------------------> fullPatch.data
fullPatch.status ----> Self.status
fullPatch.headers ---> Self.headers
fullPatch.completed -> Self.completed
fullPatch.failed ----> Self.failed
fullPatch.finished --> Self.finished
fullPatch.error -----> Self.error
}
/** Performs HTTP POST operation.
Parameters:
- `url`: the URL to call POST on.
- `headers`: headers to send in request.
Inputs:
- `data`: data sent in request, corresponding to the HTTP body.
Outputs:
- `status`: HTTP status response.
- `headers`: headers received in response.
- `data`: data received as response, corresponding to the HTTP body.
- `completed`: emitted when the request finished successfully.
- `failed`: emitted if the request failed technically.
- `error`: message containing error when request failed technically.
- `finished`: emitted when the request finished, regardless of state.
Also see [MDN documentation](https://developer.mozilla.org/docs/Web/HTTP/Methods/POST).
*/
treatment post(url: string, headers: Option<StringMap> = _)
model client: HttpClient(
base_url = _,
headers = |map([])
)
input data: Stream<byte>
output headers: Block<StringMap>
output data: Stream<byte>
output completed: Block<void>
output failed: Block<void>
output finished: Block<void>
output error: Block<string>
output status: Block<HttpStatus>
{
fullPost[client=client]()
trigger<byte>()
url: emit<string>(value=url)
headers: emit<StringMap>(value=|unwrap_or<StringMap>(headers, |map([])))
Self.data -> trigger.stream,start -----> url.trigger,emit -> fullPost.url
trigger.start --------> headers.trigger,emit -> fullPost.headers
Self.data -------------------------------------------------> fullPost.data
fullPost.status ----> Self.status
fullPost.headers ---> Self.headers
fullPost.data ------> Self.data
fullPost.completed -> Self.completed
fullPost.failed ----> Self.failed
fullPost.finished --> Self.finished
fullPost.error -----> Self.error
}
/** Performs HTTP PUT operation.
Parameters:
- `url`: the URL to call PUT on.
- `headers`: headers to send in request.
Inputs:
- `data`: data sent in request, corresponding to the HTTP body.
Outputs:
- `status`: HTTP status response.
- `headers`: headers received in response.
- `data`: data received as response, corresponding to the HTTP body.
- `completed`: emitted when the request finished successfully.
- `failed`: emitted if the request failed technically.
- `error`: message containing error when request failed technically.
- `finished`: emitted when the request finished, regardless of state.
Also see [MDN documentation](https://developer.mozilla.org/docs/Web/HTTP/Methods/PUT).
*/
treatment put(url: string, headers: Option<StringMap> = _)
model client: HttpClient(
base_url = _,
headers = |map([])
)
input data: Stream<byte>
output headers: Block<StringMap>
output completed: Block<void>
output failed: Block<void>
output finished: Block<void>
output error: Block<string>
output status: Block<HttpStatus>
{
fullPut[client=client]()
trigger<byte>()
url: emit<string>(value=url)
headers: emit<StringMap>(value=|unwrap_or<StringMap>(headers, |map([])))
Self.data -> trigger.stream,start -----> url.trigger,emit -> fullPut.url
trigger.start --------> headers.trigger,emit -> fullPut.headers
Self.data -------------------------------------------------> fullPut.data
fullPut.status ----> Self.status
fullPut.headers ---> Self.headers
fullPut.completed -> Self.completed
fullPut.failed ----> Self.failed
fullPut.finished --> Self.finished
fullPut.error -----> Self.error
}
/** Performs HTTP TRACE operation.
Parameters:
- `url`: the URL to call TRACE on.
- `headers`: headers to send in request.
Inputs:
- `trigger`: starts the request.
Outputs:
- `status`: HTTP status response.
- `headers`: headers received in response.
- `completed`: emitted when the request finished successfully.
- `failed`: emitted if the request failed technically.
- `error`: message containing error when request failed technically.
- `finished`: emitted when the request finished, regardless of state.
Also see [MDN documentation](https://developer.mozilla.org/docs/Web/HTTP/Methods/TRACE).
*/
treatment trace(url: string, headers: Option<StringMap> = _)
model client: HttpClient(
base_url = _,
headers = |map([])
)
input trigger: Block<void>
output headers: Block<StringMap>
output completed: Block<void>
output failed: Block<void>
output finished: Block<void>
output error: Block<string>
output status: Block<HttpStatus>
{
fullTrace[client=client]()
url: emit<string>(value=url)
headers: emit<StringMap>(value=|unwrap_or<StringMap>(headers, |map([])))
Self.trigger -----> url.trigger,emit -> fullTrace.url
Self.trigger -> headers.trigger,emit -> fullTrace.headers
fullTrace.status ----> Self.status
fullTrace.headers ---> Self.headers
fullTrace.completed -> Self.completed
fullTrace.failed ----> Self.failed
fullTrace.finished --> Self.finished
fullTrace.error -----> Self.error
}