OpenFaaS API Gateway
POST
Invoke a function asynchronously in an OpenFaaS namespace. Any additional path segments and query parameters will be passed to the function as is. See https---docs.openfaas.com-reference-async-.
{{baseUrl}}/async-function/:functionName.:namespace
QUERY PARAMS
functionName
namespace
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/async-function/:functionName.:namespace");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: */*");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/async-function/:functionName.:namespace" {:headers {:content-type "*/*"}})
require "http/client"
url = "{{baseUrl}}/async-function/:functionName.:namespace"
headers = HTTP::Headers{
"content-type" => "*/*"
}
response = HTTP::Client.post url, headers: headers
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/async-function/:functionName.:namespace"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/async-function/:functionName.:namespace");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "*/*");
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/async-function/:functionName.:namespace"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("content-type", "*/*")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/async-function/:functionName.:namespace HTTP/1.1
Content-Type: */*
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/async-function/:functionName.:namespace")
.setHeader("content-type", "*/*")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/async-function/:functionName.:namespace"))
.header("content-type", "*/*")
.method("POST", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/async-function/:functionName.:namespace")
.post(null)
.addHeader("content-type", "*/*")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/async-function/:functionName.:namespace")
.header("content-type", "*/*")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/async-function/:functionName.:namespace');
xhr.setRequestHeader('content-type', '*/*');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/async-function/:functionName.:namespace',
headers: {'content-type': '*/*'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/async-function/:functionName.:namespace';
const options = {method: 'POST', headers: {'content-type': '*/*'}};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/async-function/:functionName.:namespace',
method: 'POST',
headers: {
'content-type': '*/*'
}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/async-function/:functionName.:namespace")
.post(null)
.addHeader("content-type", "*/*")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/async-function/:functionName.:namespace',
headers: {
'content-type': '*/*'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/async-function/:functionName.:namespace',
headers: {'content-type': '*/*'}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/async-function/:functionName.:namespace');
req.headers({
'content-type': '*/*'
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/async-function/:functionName.:namespace',
headers: {'content-type': '*/*'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/async-function/:functionName.:namespace';
const options = {method: 'POST', headers: {'content-type': '*/*'}};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"*/*" };
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/async-function/:functionName.:namespace"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/async-function/:functionName.:namespace" in
let headers = Header.add (Header.init ()) "content-type" "*/*" in
Client.call ~headers `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/async-function/:functionName.:namespace",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"content-type: */*"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/async-function/:functionName.:namespace', [
'headers' => [
'content-type' => '*/*',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/async-function/:functionName.:namespace');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => '*/*'
]);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/async-function/:functionName.:namespace');
$request->setRequestMethod('POST');
$request->setHeaders([
'content-type' => '*/*'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "*/*")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/async-function/:functionName.:namespace' -Method POST -Headers $headers
$headers=@{}
$headers.Add("content-type", "*/*")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/async-function/:functionName.:namespace' -Method POST -Headers $headers
import http.client
conn = http.client.HTTPSConnection("example.com")
headers = { 'content-type': "*/*" }
conn.request("POST", "/baseUrl/async-function/:functionName.:namespace", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/async-function/:functionName.:namespace"
headers = {"content-type": "*/*"}
response = requests.post(url, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/async-function/:functionName.:namespace"
response <- VERB("POST", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/async-function/:functionName.:namespace")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = '*/*'
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => '*/*'}
)
response = conn.post('/baseUrl/async-function/:functionName.:namespace') do |req|
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/async-function/:functionName.:namespace";
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "*/*".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/async-function/:functionName.:namespace \
--header 'content-type: */*'
http POST {{baseUrl}}/async-function/:functionName.:namespace \
content-type:'*/*'
wget --quiet \
--method POST \
--header 'content-type: */*' \
--output-document \
- {{baseUrl}}/async-function/:functionName.:namespace
import Foundation
let headers = ["content-type": "*/*"]
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/async-function/:functionName.:namespace")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Invoke a function asynchronously in the default OpenFaaS namespace Any additional path segments and query parameters will be passed to the function as is. See https---docs.openfaas.com-reference-async-.
{{baseUrl}}/async-function/:functionName
QUERY PARAMS
functionName
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/async-function/:functionName");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: */*");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/async-function/:functionName" {:headers {:content-type "*/*"}})
require "http/client"
url = "{{baseUrl}}/async-function/:functionName"
headers = HTTP::Headers{
"content-type" => "*/*"
}
response = HTTP::Client.post url, headers: headers
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/async-function/:functionName"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/async-function/:functionName");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "*/*");
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/async-function/:functionName"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("content-type", "*/*")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/async-function/:functionName HTTP/1.1
Content-Type: */*
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/async-function/:functionName")
.setHeader("content-type", "*/*")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/async-function/:functionName"))
.header("content-type", "*/*")
.method("POST", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/async-function/:functionName")
.post(null)
.addHeader("content-type", "*/*")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/async-function/:functionName")
.header("content-type", "*/*")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/async-function/:functionName');
xhr.setRequestHeader('content-type', '*/*');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/async-function/:functionName',
headers: {'content-type': '*/*'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/async-function/:functionName';
const options = {method: 'POST', headers: {'content-type': '*/*'}};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/async-function/:functionName',
method: 'POST',
headers: {
'content-type': '*/*'
}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/async-function/:functionName")
.post(null)
.addHeader("content-type", "*/*")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/async-function/:functionName',
headers: {
'content-type': '*/*'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/async-function/:functionName',
headers: {'content-type': '*/*'}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/async-function/:functionName');
req.headers({
'content-type': '*/*'
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/async-function/:functionName',
headers: {'content-type': '*/*'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/async-function/:functionName';
const options = {method: 'POST', headers: {'content-type': '*/*'}};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"*/*" };
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/async-function/:functionName"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/async-function/:functionName" in
let headers = Header.add (Header.init ()) "content-type" "*/*" in
Client.call ~headers `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/async-function/:functionName",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"content-type: */*"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/async-function/:functionName', [
'headers' => [
'content-type' => '*/*',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/async-function/:functionName');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => '*/*'
]);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/async-function/:functionName');
$request->setRequestMethod('POST');
$request->setHeaders([
'content-type' => '*/*'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "*/*")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/async-function/:functionName' -Method POST -Headers $headers
$headers=@{}
$headers.Add("content-type", "*/*")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/async-function/:functionName' -Method POST -Headers $headers
import http.client
conn = http.client.HTTPSConnection("example.com")
headers = { 'content-type': "*/*" }
conn.request("POST", "/baseUrl/async-function/:functionName", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/async-function/:functionName"
headers = {"content-type": "*/*"}
response = requests.post(url, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/async-function/:functionName"
response <- VERB("POST", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/async-function/:functionName")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = '*/*'
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => '*/*'}
)
response = conn.post('/baseUrl/async-function/:functionName') do |req|
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/async-function/:functionName";
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "*/*".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/async-function/:functionName \
--header 'content-type: */*'
http POST {{baseUrl}}/async-function/:functionName \
content-type:'*/*'
wget --quiet \
--method POST \
--header 'content-type: */*' \
--output-document \
- {{baseUrl}}/async-function/:functionName
import Foundation
let headers = ["content-type": "*/*"]
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/async-function/:functionName")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Synchronously invoke a function defined in te default OpenFaaS namespace. Any additional path segments and query parameters will be passed to the function as is.
{{baseUrl}}/function/:functionName
QUERY PARAMS
functionName
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/function/:functionName");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: */*");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/function/:functionName" {:headers {:content-type "*/*"}})
require "http/client"
url = "{{baseUrl}}/function/:functionName"
headers = HTTP::Headers{
"content-type" => "*/*"
}
response = HTTP::Client.post url, headers: headers
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/function/:functionName"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/function/:functionName");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "*/*");
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/function/:functionName"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("content-type", "*/*")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/function/:functionName HTTP/1.1
Content-Type: */*
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/function/:functionName")
.setHeader("content-type", "*/*")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/function/:functionName"))
.header("content-type", "*/*")
.method("POST", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/function/:functionName")
.post(null)
.addHeader("content-type", "*/*")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/function/:functionName")
.header("content-type", "*/*")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/function/:functionName');
xhr.setRequestHeader('content-type', '*/*');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/function/:functionName',
headers: {'content-type': '*/*'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/function/:functionName';
const options = {method: 'POST', headers: {'content-type': '*/*'}};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/function/:functionName',
method: 'POST',
headers: {
'content-type': '*/*'
}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/function/:functionName")
.post(null)
.addHeader("content-type", "*/*")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/function/:functionName',
headers: {
'content-type': '*/*'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/function/:functionName',
headers: {'content-type': '*/*'}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/function/:functionName');
req.headers({
'content-type': '*/*'
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/function/:functionName',
headers: {'content-type': '*/*'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/function/:functionName';
const options = {method: 'POST', headers: {'content-type': '*/*'}};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"*/*" };
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/function/:functionName"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/function/:functionName" in
let headers = Header.add (Header.init ()) "content-type" "*/*" in
Client.call ~headers `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/function/:functionName",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"content-type: */*"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/function/:functionName', [
'headers' => [
'content-type' => '*/*',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/function/:functionName');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => '*/*'
]);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/function/:functionName');
$request->setRequestMethod('POST');
$request->setHeaders([
'content-type' => '*/*'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "*/*")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/function/:functionName' -Method POST -Headers $headers
$headers=@{}
$headers.Add("content-type", "*/*")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/function/:functionName' -Method POST -Headers $headers
import http.client
conn = http.client.HTTPSConnection("example.com")
headers = { 'content-type': "*/*" }
conn.request("POST", "/baseUrl/function/:functionName", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/function/:functionName"
headers = {"content-type": "*/*"}
response = requests.post(url, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/function/:functionName"
response <- VERB("POST", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/function/:functionName")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = '*/*'
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => '*/*'}
)
response = conn.post('/baseUrl/function/:functionName') do |req|
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/function/:functionName";
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "*/*".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/function/:functionName \
--header 'content-type: */*'
http POST {{baseUrl}}/function/:functionName \
content-type:'*/*'
wget --quiet \
--method POST \
--header 'content-type: */*' \
--output-document \
- {{baseUrl}}/function/:functionName
import Foundation
let headers = ["content-type": "*/*"]
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/function/:functionName")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Synchronously invoke a function defined in the specified namespace. Any additional path segments and query parameters will be passed to the function as is.
{{baseUrl}}/function/:functionName.:namespace
QUERY PARAMS
functionName
namespace
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/function/:functionName.:namespace");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: */*");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/function/:functionName.:namespace" {:headers {:content-type "*/*"}})
require "http/client"
url = "{{baseUrl}}/function/:functionName.:namespace"
headers = HTTP::Headers{
"content-type" => "*/*"
}
response = HTTP::Client.post url, headers: headers
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/function/:functionName.:namespace"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/function/:functionName.:namespace");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "*/*");
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/function/:functionName.:namespace"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("content-type", "*/*")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/function/:functionName.:namespace HTTP/1.1
Content-Type: */*
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/function/:functionName.:namespace")
.setHeader("content-type", "*/*")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/function/:functionName.:namespace"))
.header("content-type", "*/*")
.method("POST", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/function/:functionName.:namespace")
.post(null)
.addHeader("content-type", "*/*")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/function/:functionName.:namespace")
.header("content-type", "*/*")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/function/:functionName.:namespace');
xhr.setRequestHeader('content-type', '*/*');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/function/:functionName.:namespace',
headers: {'content-type': '*/*'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/function/:functionName.:namespace';
const options = {method: 'POST', headers: {'content-type': '*/*'}};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/function/:functionName.:namespace',
method: 'POST',
headers: {
'content-type': '*/*'
}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/function/:functionName.:namespace")
.post(null)
.addHeader("content-type", "*/*")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/function/:functionName.:namespace',
headers: {
'content-type': '*/*'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/function/:functionName.:namespace',
headers: {'content-type': '*/*'}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/function/:functionName.:namespace');
req.headers({
'content-type': '*/*'
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/function/:functionName.:namespace',
headers: {'content-type': '*/*'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/function/:functionName.:namespace';
const options = {method: 'POST', headers: {'content-type': '*/*'}};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"*/*" };
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/function/:functionName.:namespace"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/function/:functionName.:namespace" in
let headers = Header.add (Header.init ()) "content-type" "*/*" in
Client.call ~headers `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/function/:functionName.:namespace",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"content-type: */*"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/function/:functionName.:namespace', [
'headers' => [
'content-type' => '*/*',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/function/:functionName.:namespace');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => '*/*'
]);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/function/:functionName.:namespace');
$request->setRequestMethod('POST');
$request->setHeaders([
'content-type' => '*/*'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "*/*")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/function/:functionName.:namespace' -Method POST -Headers $headers
$headers=@{}
$headers.Add("content-type", "*/*")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/function/:functionName.:namespace' -Method POST -Headers $headers
import http.client
conn = http.client.HTTPSConnection("example.com")
headers = { 'content-type': "*/*" }
conn.request("POST", "/baseUrl/function/:functionName.:namespace", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/function/:functionName.:namespace"
headers = {"content-type": "*/*"}
response = requests.post(url, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/function/:functionName.:namespace"
response <- VERB("POST", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/function/:functionName.:namespace")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = '*/*'
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => '*/*'}
)
response = conn.post('/baseUrl/function/:functionName.:namespace') do |req|
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/function/:functionName.:namespace";
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "*/*".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/function/:functionName.:namespace \
--header 'content-type: */*'
http POST {{baseUrl}}/function/:functionName.:namespace \
content-type:'*/*'
wget --quiet \
--method POST \
--header 'content-type: */*' \
--output-document \
- {{baseUrl}}/function/:functionName.:namespace
import Foundation
let headers = ["content-type": "*/*"]
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/function/:functionName.:namespace")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Event-sink for AlertManager, for auto-scaling Internal use for AlertManager, requires valid AlertManager alert JSON
{{baseUrl}}/system/alert
BODY json
{
"status": "",
"receiver": "",
"alerts": [
{
"status": "",
"labels": {
"alertname": "",
"function_name": ""
}
}
]
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/system/alert");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"receiver\": \"scale-up\",\n \"status\": \"firing\",\n \"alerts\": [\n {\n \"status\": \"firing\",\n \"labels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"annotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"startsAt\": \"2017-03-15T15:52:57.805Z\",\n \"endsAt\": \"0001-01-01T00:00:00Z\",\n \"generatorURL\": \"http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0\"\n }\n ],\n \"groupLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"service\": \"gateway\"\n },\n \"commonLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"commonAnnotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"externalURL\": \"http://f054879d97db:9093\",\n \"version\": \"3\",\n \"groupKey\": 18195285354214865000\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/system/alert" {:content-type :json
:form-params {:receiver "scale-up"
:status "firing"
:alerts [{:status "firing"
:labels {:alertname "APIHighInvocationRate"
:code "200"
:function_name "func_nodeinfo"
:instance "gateway:8080"
:job "gateway"
:monitor "faas-monitor"
:service "gateway"
:severity "major"
:value "8.998200359928017"}
:annotations {:description "High invocation total on gateway:8080"
:summary "High invocation total on gateway:8080"}
:startsAt "2017-03-15T15:52:57.805Z"
:endsAt "0001-01-01T00:00:00Z"
:generatorURL "http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0"}]
:groupLabels {:alertname "APIHighInvocationRate"
:service "gateway"}
:commonLabels {:alertname "APIHighInvocationRate"
:code "200"
:function_name "func_nodeinfo"
:instance "gateway:8080"
:job "gateway"
:monitor "faas-monitor"
:service "gateway"
:severity "major"
:value "8.998200359928017"}
:commonAnnotations {:description "High invocation total on gateway:8080"
:summary "High invocation total on gateway:8080"}
:externalURL "http://f054879d97db:9093"
:version "3"
:groupKey 18195285354214865000}})
require "http/client"
url = "{{baseUrl}}/system/alert"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"receiver\": \"scale-up\",\n \"status\": \"firing\",\n \"alerts\": [\n {\n \"status\": \"firing\",\n \"labels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"annotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"startsAt\": \"2017-03-15T15:52:57.805Z\",\n \"endsAt\": \"0001-01-01T00:00:00Z\",\n \"generatorURL\": \"http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0\"\n }\n ],\n \"groupLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"service\": \"gateway\"\n },\n \"commonLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"commonAnnotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"externalURL\": \"http://f054879d97db:9093\",\n \"version\": \"3\",\n \"groupKey\": 18195285354214865000\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/system/alert"),
Content = new StringContent("{\n \"receiver\": \"scale-up\",\n \"status\": \"firing\",\n \"alerts\": [\n {\n \"status\": \"firing\",\n \"labels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"annotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"startsAt\": \"2017-03-15T15:52:57.805Z\",\n \"endsAt\": \"0001-01-01T00:00:00Z\",\n \"generatorURL\": \"http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0\"\n }\n ],\n \"groupLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"service\": \"gateway\"\n },\n \"commonLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"commonAnnotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"externalURL\": \"http://f054879d97db:9093\",\n \"version\": \"3\",\n \"groupKey\": 18195285354214865000\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/system/alert");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"receiver\": \"scale-up\",\n \"status\": \"firing\",\n \"alerts\": [\n {\n \"status\": \"firing\",\n \"labels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"annotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"startsAt\": \"2017-03-15T15:52:57.805Z\",\n \"endsAt\": \"0001-01-01T00:00:00Z\",\n \"generatorURL\": \"http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0\"\n }\n ],\n \"groupLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"service\": \"gateway\"\n },\n \"commonLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"commonAnnotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"externalURL\": \"http://f054879d97db:9093\",\n \"version\": \"3\",\n \"groupKey\": 18195285354214865000\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/system/alert"
payload := strings.NewReader("{\n \"receiver\": \"scale-up\",\n \"status\": \"firing\",\n \"alerts\": [\n {\n \"status\": \"firing\",\n \"labels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"annotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"startsAt\": \"2017-03-15T15:52:57.805Z\",\n \"endsAt\": \"0001-01-01T00:00:00Z\",\n \"generatorURL\": \"http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0\"\n }\n ],\n \"groupLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"service\": \"gateway\"\n },\n \"commonLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"commonAnnotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"externalURL\": \"http://f054879d97db:9093\",\n \"version\": \"3\",\n \"groupKey\": 18195285354214865000\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/system/alert HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 1438
{
"receiver": "scale-up",
"status": "firing",
"alerts": [
{
"status": "firing",
"labels": {
"alertname": "APIHighInvocationRate",
"code": "200",
"function_name": "func_nodeinfo",
"instance": "gateway:8080",
"job": "gateway",
"monitor": "faas-monitor",
"service": "gateway",
"severity": "major",
"value": "8.998200359928017"
},
"annotations": {
"description": "High invocation total on gateway:8080",
"summary": "High invocation total on gateway:8080"
},
"startsAt": "2017-03-15T15:52:57.805Z",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0"
}
],
"groupLabels": {
"alertname": "APIHighInvocationRate",
"service": "gateway"
},
"commonLabels": {
"alertname": "APIHighInvocationRate",
"code": "200",
"function_name": "func_nodeinfo",
"instance": "gateway:8080",
"job": "gateway",
"monitor": "faas-monitor",
"service": "gateway",
"severity": "major",
"value": "8.998200359928017"
},
"commonAnnotations": {
"description": "High invocation total on gateway:8080",
"summary": "High invocation total on gateway:8080"
},
"externalURL": "http://f054879d97db:9093",
"version": "3",
"groupKey": 18195285354214865000
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/system/alert")
.setHeader("content-type", "application/json")
.setBody("{\n \"receiver\": \"scale-up\",\n \"status\": \"firing\",\n \"alerts\": [\n {\n \"status\": \"firing\",\n \"labels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"annotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"startsAt\": \"2017-03-15T15:52:57.805Z\",\n \"endsAt\": \"0001-01-01T00:00:00Z\",\n \"generatorURL\": \"http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0\"\n }\n ],\n \"groupLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"service\": \"gateway\"\n },\n \"commonLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"commonAnnotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"externalURL\": \"http://f054879d97db:9093\",\n \"version\": \"3\",\n \"groupKey\": 18195285354214865000\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/system/alert"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"receiver\": \"scale-up\",\n \"status\": \"firing\",\n \"alerts\": [\n {\n \"status\": \"firing\",\n \"labels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"annotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"startsAt\": \"2017-03-15T15:52:57.805Z\",\n \"endsAt\": \"0001-01-01T00:00:00Z\",\n \"generatorURL\": \"http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0\"\n }\n ],\n \"groupLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"service\": \"gateway\"\n },\n \"commonLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"commonAnnotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"externalURL\": \"http://f054879d97db:9093\",\n \"version\": \"3\",\n \"groupKey\": 18195285354214865000\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"receiver\": \"scale-up\",\n \"status\": \"firing\",\n \"alerts\": [\n {\n \"status\": \"firing\",\n \"labels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"annotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"startsAt\": \"2017-03-15T15:52:57.805Z\",\n \"endsAt\": \"0001-01-01T00:00:00Z\",\n \"generatorURL\": \"http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0\"\n }\n ],\n \"groupLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"service\": \"gateway\"\n },\n \"commonLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"commonAnnotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"externalURL\": \"http://f054879d97db:9093\",\n \"version\": \"3\",\n \"groupKey\": 18195285354214865000\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/system/alert")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/system/alert")
.header("content-type", "application/json")
.body("{\n \"receiver\": \"scale-up\",\n \"status\": \"firing\",\n \"alerts\": [\n {\n \"status\": \"firing\",\n \"labels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"annotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"startsAt\": \"2017-03-15T15:52:57.805Z\",\n \"endsAt\": \"0001-01-01T00:00:00Z\",\n \"generatorURL\": \"http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0\"\n }\n ],\n \"groupLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"service\": \"gateway\"\n },\n \"commonLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"commonAnnotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"externalURL\": \"http://f054879d97db:9093\",\n \"version\": \"3\",\n \"groupKey\": 18195285354214865000\n}")
.asString();
const data = JSON.stringify({
receiver: 'scale-up',
status: 'firing',
alerts: [
{
status: 'firing',
labels: {
alertname: 'APIHighInvocationRate',
code: '200',
function_name: 'func_nodeinfo',
instance: 'gateway:8080',
job: 'gateway',
monitor: 'faas-monitor',
service: 'gateway',
severity: 'major',
value: '8.998200359928017'
},
annotations: {
description: 'High invocation total on gateway:8080',
summary: 'High invocation total on gateway:8080'
},
startsAt: '2017-03-15T15:52:57.805Z',
endsAt: '0001-01-01T00:00:00Z',
generatorURL: 'http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0'
}
],
groupLabels: {
alertname: 'APIHighInvocationRate',
service: 'gateway'
},
commonLabels: {
alertname: 'APIHighInvocationRate',
code: '200',
function_name: 'func_nodeinfo',
instance: 'gateway:8080',
job: 'gateway',
monitor: 'faas-monitor',
service: 'gateway',
severity: 'major',
value: '8.998200359928017'
},
commonAnnotations: {
description: 'High invocation total on gateway:8080',
summary: 'High invocation total on gateway:8080'
},
externalURL: 'http://f054879d97db:9093',
version: '3',
groupKey: 18195285354214865000
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/system/alert');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/system/alert',
headers: {'content-type': 'application/json'},
data: {
receiver: 'scale-up',
status: 'firing',
alerts: [
{
status: 'firing',
labels: {
alertname: 'APIHighInvocationRate',
code: '200',
function_name: 'func_nodeinfo',
instance: 'gateway:8080',
job: 'gateway',
monitor: 'faas-monitor',
service: 'gateway',
severity: 'major',
value: '8.998200359928017'
},
annotations: {
description: 'High invocation total on gateway:8080',
summary: 'High invocation total on gateway:8080'
},
startsAt: '2017-03-15T15:52:57.805Z',
endsAt: '0001-01-01T00:00:00Z',
generatorURL: 'http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0'
}
],
groupLabels: {alertname: 'APIHighInvocationRate', service: 'gateway'},
commonLabels: {
alertname: 'APIHighInvocationRate',
code: '200',
function_name: 'func_nodeinfo',
instance: 'gateway:8080',
job: 'gateway',
monitor: 'faas-monitor',
service: 'gateway',
severity: 'major',
value: '8.998200359928017'
},
commonAnnotations: {
description: 'High invocation total on gateway:8080',
summary: 'High invocation total on gateway:8080'
},
externalURL: 'http://f054879d97db:9093',
version: '3',
groupKey: 18195285354214865000
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/system/alert';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"receiver":"scale-up","status":"firing","alerts":[{"status":"firing","labels":{"alertname":"APIHighInvocationRate","code":"200","function_name":"func_nodeinfo","instance":"gateway:8080","job":"gateway","monitor":"faas-monitor","service":"gateway","severity":"major","value":"8.998200359928017"},"annotations":{"description":"High invocation total on gateway:8080","summary":"High invocation total on gateway:8080"},"startsAt":"2017-03-15T15:52:57.805Z","endsAt":"0001-01-01T00:00:00Z","generatorURL":"http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0"}],"groupLabels":{"alertname":"APIHighInvocationRate","service":"gateway"},"commonLabels":{"alertname":"APIHighInvocationRate","code":"200","function_name":"func_nodeinfo","instance":"gateway:8080","job":"gateway","monitor":"faas-monitor","service":"gateway","severity":"major","value":"8.998200359928017"},"commonAnnotations":{"description":"High invocation total on gateway:8080","summary":"High invocation total on gateway:8080"},"externalURL":"http://f054879d97db:9093","version":"3","groupKey":18195285354214865000}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/system/alert',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "receiver": "scale-up",\n "status": "firing",\n "alerts": [\n {\n "status": "firing",\n "labels": {\n "alertname": "APIHighInvocationRate",\n "code": "200",\n "function_name": "func_nodeinfo",\n "instance": "gateway:8080",\n "job": "gateway",\n "monitor": "faas-monitor",\n "service": "gateway",\n "severity": "major",\n "value": "8.998200359928017"\n },\n "annotations": {\n "description": "High invocation total on gateway:8080",\n "summary": "High invocation total on gateway:8080"\n },\n "startsAt": "2017-03-15T15:52:57.805Z",\n "endsAt": "0001-01-01T00:00:00Z",\n "generatorURL": "http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0"\n }\n ],\n "groupLabels": {\n "alertname": "APIHighInvocationRate",\n "service": "gateway"\n },\n "commonLabels": {\n "alertname": "APIHighInvocationRate",\n "code": "200",\n "function_name": "func_nodeinfo",\n "instance": "gateway:8080",\n "job": "gateway",\n "monitor": "faas-monitor",\n "service": "gateway",\n "severity": "major",\n "value": "8.998200359928017"\n },\n "commonAnnotations": {\n "description": "High invocation total on gateway:8080",\n "summary": "High invocation total on gateway:8080"\n },\n "externalURL": "http://f054879d97db:9093",\n "version": "3",\n "groupKey": 18195285354214865000\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"receiver\": \"scale-up\",\n \"status\": \"firing\",\n \"alerts\": [\n {\n \"status\": \"firing\",\n \"labels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"annotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"startsAt\": \"2017-03-15T15:52:57.805Z\",\n \"endsAt\": \"0001-01-01T00:00:00Z\",\n \"generatorURL\": \"http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0\"\n }\n ],\n \"groupLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"service\": \"gateway\"\n },\n \"commonLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"commonAnnotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"externalURL\": \"http://f054879d97db:9093\",\n \"version\": \"3\",\n \"groupKey\": 18195285354214865000\n}")
val request = Request.Builder()
.url("{{baseUrl}}/system/alert")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/system/alert',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
receiver: 'scale-up',
status: 'firing',
alerts: [
{
status: 'firing',
labels: {
alertname: 'APIHighInvocationRate',
code: '200',
function_name: 'func_nodeinfo',
instance: 'gateway:8080',
job: 'gateway',
monitor: 'faas-monitor',
service: 'gateway',
severity: 'major',
value: '8.998200359928017'
},
annotations: {
description: 'High invocation total on gateway:8080',
summary: 'High invocation total on gateway:8080'
},
startsAt: '2017-03-15T15:52:57.805Z',
endsAt: '0001-01-01T00:00:00Z',
generatorURL: 'http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0'
}
],
groupLabels: {alertname: 'APIHighInvocationRate', service: 'gateway'},
commonLabels: {
alertname: 'APIHighInvocationRate',
code: '200',
function_name: 'func_nodeinfo',
instance: 'gateway:8080',
job: 'gateway',
monitor: 'faas-monitor',
service: 'gateway',
severity: 'major',
value: '8.998200359928017'
},
commonAnnotations: {
description: 'High invocation total on gateway:8080',
summary: 'High invocation total on gateway:8080'
},
externalURL: 'http://f054879d97db:9093',
version: '3',
groupKey: 18195285354214865000
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/system/alert',
headers: {'content-type': 'application/json'},
body: {
receiver: 'scale-up',
status: 'firing',
alerts: [
{
status: 'firing',
labels: {
alertname: 'APIHighInvocationRate',
code: '200',
function_name: 'func_nodeinfo',
instance: 'gateway:8080',
job: 'gateway',
monitor: 'faas-monitor',
service: 'gateway',
severity: 'major',
value: '8.998200359928017'
},
annotations: {
description: 'High invocation total on gateway:8080',
summary: 'High invocation total on gateway:8080'
},
startsAt: '2017-03-15T15:52:57.805Z',
endsAt: '0001-01-01T00:00:00Z',
generatorURL: 'http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0'
}
],
groupLabels: {alertname: 'APIHighInvocationRate', service: 'gateway'},
commonLabels: {
alertname: 'APIHighInvocationRate',
code: '200',
function_name: 'func_nodeinfo',
instance: 'gateway:8080',
job: 'gateway',
monitor: 'faas-monitor',
service: 'gateway',
severity: 'major',
value: '8.998200359928017'
},
commonAnnotations: {
description: 'High invocation total on gateway:8080',
summary: 'High invocation total on gateway:8080'
},
externalURL: 'http://f054879d97db:9093',
version: '3',
groupKey: 18195285354214865000
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/system/alert');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
receiver: 'scale-up',
status: 'firing',
alerts: [
{
status: 'firing',
labels: {
alertname: 'APIHighInvocationRate',
code: '200',
function_name: 'func_nodeinfo',
instance: 'gateway:8080',
job: 'gateway',
monitor: 'faas-monitor',
service: 'gateway',
severity: 'major',
value: '8.998200359928017'
},
annotations: {
description: 'High invocation total on gateway:8080',
summary: 'High invocation total on gateway:8080'
},
startsAt: '2017-03-15T15:52:57.805Z',
endsAt: '0001-01-01T00:00:00Z',
generatorURL: 'http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0'
}
],
groupLabels: {
alertname: 'APIHighInvocationRate',
service: 'gateway'
},
commonLabels: {
alertname: 'APIHighInvocationRate',
code: '200',
function_name: 'func_nodeinfo',
instance: 'gateway:8080',
job: 'gateway',
monitor: 'faas-monitor',
service: 'gateway',
severity: 'major',
value: '8.998200359928017'
},
commonAnnotations: {
description: 'High invocation total on gateway:8080',
summary: 'High invocation total on gateway:8080'
},
externalURL: 'http://f054879d97db:9093',
version: '3',
groupKey: 18195285354214865000
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/system/alert',
headers: {'content-type': 'application/json'},
data: {
receiver: 'scale-up',
status: 'firing',
alerts: [
{
status: 'firing',
labels: {
alertname: 'APIHighInvocationRate',
code: '200',
function_name: 'func_nodeinfo',
instance: 'gateway:8080',
job: 'gateway',
monitor: 'faas-monitor',
service: 'gateway',
severity: 'major',
value: '8.998200359928017'
},
annotations: {
description: 'High invocation total on gateway:8080',
summary: 'High invocation total on gateway:8080'
},
startsAt: '2017-03-15T15:52:57.805Z',
endsAt: '0001-01-01T00:00:00Z',
generatorURL: 'http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0'
}
],
groupLabels: {alertname: 'APIHighInvocationRate', service: 'gateway'},
commonLabels: {
alertname: 'APIHighInvocationRate',
code: '200',
function_name: 'func_nodeinfo',
instance: 'gateway:8080',
job: 'gateway',
monitor: 'faas-monitor',
service: 'gateway',
severity: 'major',
value: '8.998200359928017'
},
commonAnnotations: {
description: 'High invocation total on gateway:8080',
summary: 'High invocation total on gateway:8080'
},
externalURL: 'http://f054879d97db:9093',
version: '3',
groupKey: 18195285354214865000
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/system/alert';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"receiver":"scale-up","status":"firing","alerts":[{"status":"firing","labels":{"alertname":"APIHighInvocationRate","code":"200","function_name":"func_nodeinfo","instance":"gateway:8080","job":"gateway","monitor":"faas-monitor","service":"gateway","severity":"major","value":"8.998200359928017"},"annotations":{"description":"High invocation total on gateway:8080","summary":"High invocation total on gateway:8080"},"startsAt":"2017-03-15T15:52:57.805Z","endsAt":"0001-01-01T00:00:00Z","generatorURL":"http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0"}],"groupLabels":{"alertname":"APIHighInvocationRate","service":"gateway"},"commonLabels":{"alertname":"APIHighInvocationRate","code":"200","function_name":"func_nodeinfo","instance":"gateway:8080","job":"gateway","monitor":"faas-monitor","service":"gateway","severity":"major","value":"8.998200359928017"},"commonAnnotations":{"description":"High invocation total on gateway:8080","summary":"High invocation total on gateway:8080"},"externalURL":"http://f054879d97db:9093","version":"3","groupKey":18195285354214865000}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"receiver": @"scale-up",
@"status": @"firing",
@"alerts": @[ @{ @"status": @"firing", @"labels": @{ @"alertname": @"APIHighInvocationRate", @"code": @"200", @"function_name": @"func_nodeinfo", @"instance": @"gateway:8080", @"job": @"gateway", @"monitor": @"faas-monitor", @"service": @"gateway", @"severity": @"major", @"value": @"8.998200359928017" }, @"annotations": @{ @"description": @"High invocation total on gateway:8080", @"summary": @"High invocation total on gateway:8080" }, @"startsAt": @"2017-03-15T15:52:57.805Z", @"endsAt": @"0001-01-01T00:00:00Z", @"generatorURL": @"http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0" } ],
@"groupLabels": @{ @"alertname": @"APIHighInvocationRate", @"service": @"gateway" },
@"commonLabels": @{ @"alertname": @"APIHighInvocationRate", @"code": @"200", @"function_name": @"func_nodeinfo", @"instance": @"gateway:8080", @"job": @"gateway", @"monitor": @"faas-monitor", @"service": @"gateway", @"severity": @"major", @"value": @"8.998200359928017" },
@"commonAnnotations": @{ @"description": @"High invocation total on gateway:8080", @"summary": @"High invocation total on gateway:8080" },
@"externalURL": @"http://f054879d97db:9093",
@"version": @"3",
@"groupKey": @18195285354214865000 };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/system/alert"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/system/alert" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"receiver\": \"scale-up\",\n \"status\": \"firing\",\n \"alerts\": [\n {\n \"status\": \"firing\",\n \"labels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"annotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"startsAt\": \"2017-03-15T15:52:57.805Z\",\n \"endsAt\": \"0001-01-01T00:00:00Z\",\n \"generatorURL\": \"http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0\"\n }\n ],\n \"groupLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"service\": \"gateway\"\n },\n \"commonLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"commonAnnotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"externalURL\": \"http://f054879d97db:9093\",\n \"version\": \"3\",\n \"groupKey\": 18195285354214865000\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/system/alert",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'receiver' => 'scale-up',
'status' => 'firing',
'alerts' => [
[
'status' => 'firing',
'labels' => [
'alertname' => 'APIHighInvocationRate',
'code' => '200',
'function_name' => 'func_nodeinfo',
'instance' => 'gateway:8080',
'job' => 'gateway',
'monitor' => 'faas-monitor',
'service' => 'gateway',
'severity' => 'major',
'value' => '8.998200359928017'
],
'annotations' => [
'description' => 'High invocation total on gateway:8080',
'summary' => 'High invocation total on gateway:8080'
],
'startsAt' => '2017-03-15T15:52:57.805Z',
'endsAt' => '0001-01-01T00:00:00Z',
'generatorURL' => 'http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0'
]
],
'groupLabels' => [
'alertname' => 'APIHighInvocationRate',
'service' => 'gateway'
],
'commonLabels' => [
'alertname' => 'APIHighInvocationRate',
'code' => '200',
'function_name' => 'func_nodeinfo',
'instance' => 'gateway:8080',
'job' => 'gateway',
'monitor' => 'faas-monitor',
'service' => 'gateway',
'severity' => 'major',
'value' => '8.998200359928017'
],
'commonAnnotations' => [
'description' => 'High invocation total on gateway:8080',
'summary' => 'High invocation total on gateway:8080'
],
'externalURL' => 'http://f054879d97db:9093',
'version' => '3',
'groupKey' => 18195285354214865000
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/system/alert', [
'body' => '{
"receiver": "scale-up",
"status": "firing",
"alerts": [
{
"status": "firing",
"labels": {
"alertname": "APIHighInvocationRate",
"code": "200",
"function_name": "func_nodeinfo",
"instance": "gateway:8080",
"job": "gateway",
"monitor": "faas-monitor",
"service": "gateway",
"severity": "major",
"value": "8.998200359928017"
},
"annotations": {
"description": "High invocation total on gateway:8080",
"summary": "High invocation total on gateway:8080"
},
"startsAt": "2017-03-15T15:52:57.805Z",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0"
}
],
"groupLabels": {
"alertname": "APIHighInvocationRate",
"service": "gateway"
},
"commonLabels": {
"alertname": "APIHighInvocationRate",
"code": "200",
"function_name": "func_nodeinfo",
"instance": "gateway:8080",
"job": "gateway",
"monitor": "faas-monitor",
"service": "gateway",
"severity": "major",
"value": "8.998200359928017"
},
"commonAnnotations": {
"description": "High invocation total on gateway:8080",
"summary": "High invocation total on gateway:8080"
},
"externalURL": "http://f054879d97db:9093",
"version": "3",
"groupKey": 18195285354214865000
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/system/alert');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'receiver' => 'scale-up',
'status' => 'firing',
'alerts' => [
[
'status' => 'firing',
'labels' => [
'alertname' => 'APIHighInvocationRate',
'code' => '200',
'function_name' => 'func_nodeinfo',
'instance' => 'gateway:8080',
'job' => 'gateway',
'monitor' => 'faas-monitor',
'service' => 'gateway',
'severity' => 'major',
'value' => '8.998200359928017'
],
'annotations' => [
'description' => 'High invocation total on gateway:8080',
'summary' => 'High invocation total on gateway:8080'
],
'startsAt' => '2017-03-15T15:52:57.805Z',
'endsAt' => '0001-01-01T00:00:00Z',
'generatorURL' => 'http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0'
]
],
'groupLabels' => [
'alertname' => 'APIHighInvocationRate',
'service' => 'gateway'
],
'commonLabels' => [
'alertname' => 'APIHighInvocationRate',
'code' => '200',
'function_name' => 'func_nodeinfo',
'instance' => 'gateway:8080',
'job' => 'gateway',
'monitor' => 'faas-monitor',
'service' => 'gateway',
'severity' => 'major',
'value' => '8.998200359928017'
],
'commonAnnotations' => [
'description' => 'High invocation total on gateway:8080',
'summary' => 'High invocation total on gateway:8080'
],
'externalURL' => 'http://f054879d97db:9093',
'version' => '3',
'groupKey' => 18195285354214865000
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'receiver' => 'scale-up',
'status' => 'firing',
'alerts' => [
[
'status' => 'firing',
'labels' => [
'alertname' => 'APIHighInvocationRate',
'code' => '200',
'function_name' => 'func_nodeinfo',
'instance' => 'gateway:8080',
'job' => 'gateway',
'monitor' => 'faas-monitor',
'service' => 'gateway',
'severity' => 'major',
'value' => '8.998200359928017'
],
'annotations' => [
'description' => 'High invocation total on gateway:8080',
'summary' => 'High invocation total on gateway:8080'
],
'startsAt' => '2017-03-15T15:52:57.805Z',
'endsAt' => '0001-01-01T00:00:00Z',
'generatorURL' => 'http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0'
]
],
'groupLabels' => [
'alertname' => 'APIHighInvocationRate',
'service' => 'gateway'
],
'commonLabels' => [
'alertname' => 'APIHighInvocationRate',
'code' => '200',
'function_name' => 'func_nodeinfo',
'instance' => 'gateway:8080',
'job' => 'gateway',
'monitor' => 'faas-monitor',
'service' => 'gateway',
'severity' => 'major',
'value' => '8.998200359928017'
],
'commonAnnotations' => [
'description' => 'High invocation total on gateway:8080',
'summary' => 'High invocation total on gateway:8080'
],
'externalURL' => 'http://f054879d97db:9093',
'version' => '3',
'groupKey' => 18195285354214865000
]));
$request->setRequestUrl('{{baseUrl}}/system/alert');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/system/alert' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"receiver": "scale-up",
"status": "firing",
"alerts": [
{
"status": "firing",
"labels": {
"alertname": "APIHighInvocationRate",
"code": "200",
"function_name": "func_nodeinfo",
"instance": "gateway:8080",
"job": "gateway",
"monitor": "faas-monitor",
"service": "gateway",
"severity": "major",
"value": "8.998200359928017"
},
"annotations": {
"description": "High invocation total on gateway:8080",
"summary": "High invocation total on gateway:8080"
},
"startsAt": "2017-03-15T15:52:57.805Z",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0"
}
],
"groupLabels": {
"alertname": "APIHighInvocationRate",
"service": "gateway"
},
"commonLabels": {
"alertname": "APIHighInvocationRate",
"code": "200",
"function_name": "func_nodeinfo",
"instance": "gateway:8080",
"job": "gateway",
"monitor": "faas-monitor",
"service": "gateway",
"severity": "major",
"value": "8.998200359928017"
},
"commonAnnotations": {
"description": "High invocation total on gateway:8080",
"summary": "High invocation total on gateway:8080"
},
"externalURL": "http://f054879d97db:9093",
"version": "3",
"groupKey": 18195285354214865000
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/system/alert' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"receiver": "scale-up",
"status": "firing",
"alerts": [
{
"status": "firing",
"labels": {
"alertname": "APIHighInvocationRate",
"code": "200",
"function_name": "func_nodeinfo",
"instance": "gateway:8080",
"job": "gateway",
"monitor": "faas-monitor",
"service": "gateway",
"severity": "major",
"value": "8.998200359928017"
},
"annotations": {
"description": "High invocation total on gateway:8080",
"summary": "High invocation total on gateway:8080"
},
"startsAt": "2017-03-15T15:52:57.805Z",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0"
}
],
"groupLabels": {
"alertname": "APIHighInvocationRate",
"service": "gateway"
},
"commonLabels": {
"alertname": "APIHighInvocationRate",
"code": "200",
"function_name": "func_nodeinfo",
"instance": "gateway:8080",
"job": "gateway",
"monitor": "faas-monitor",
"service": "gateway",
"severity": "major",
"value": "8.998200359928017"
},
"commonAnnotations": {
"description": "High invocation total on gateway:8080",
"summary": "High invocation total on gateway:8080"
},
"externalURL": "http://f054879d97db:9093",
"version": "3",
"groupKey": 18195285354214865000
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"receiver\": \"scale-up\",\n \"status\": \"firing\",\n \"alerts\": [\n {\n \"status\": \"firing\",\n \"labels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"annotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"startsAt\": \"2017-03-15T15:52:57.805Z\",\n \"endsAt\": \"0001-01-01T00:00:00Z\",\n \"generatorURL\": \"http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0\"\n }\n ],\n \"groupLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"service\": \"gateway\"\n },\n \"commonLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"commonAnnotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"externalURL\": \"http://f054879d97db:9093\",\n \"version\": \"3\",\n \"groupKey\": 18195285354214865000\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/system/alert", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/system/alert"
payload = {
"receiver": "scale-up",
"status": "firing",
"alerts": [
{
"status": "firing",
"labels": {
"alertname": "APIHighInvocationRate",
"code": "200",
"function_name": "func_nodeinfo",
"instance": "gateway:8080",
"job": "gateway",
"monitor": "faas-monitor",
"service": "gateway",
"severity": "major",
"value": "8.998200359928017"
},
"annotations": {
"description": "High invocation total on gateway:8080",
"summary": "High invocation total on gateway:8080"
},
"startsAt": "2017-03-15T15:52:57.805Z",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0"
}
],
"groupLabels": {
"alertname": "APIHighInvocationRate",
"service": "gateway"
},
"commonLabels": {
"alertname": "APIHighInvocationRate",
"code": "200",
"function_name": "func_nodeinfo",
"instance": "gateway:8080",
"job": "gateway",
"monitor": "faas-monitor",
"service": "gateway",
"severity": "major",
"value": "8.998200359928017"
},
"commonAnnotations": {
"description": "High invocation total on gateway:8080",
"summary": "High invocation total on gateway:8080"
},
"externalURL": "http://f054879d97db:9093",
"version": "3",
"groupKey": 18195285354214865000
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/system/alert"
payload <- "{\n \"receiver\": \"scale-up\",\n \"status\": \"firing\",\n \"alerts\": [\n {\n \"status\": \"firing\",\n \"labels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"annotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"startsAt\": \"2017-03-15T15:52:57.805Z\",\n \"endsAt\": \"0001-01-01T00:00:00Z\",\n \"generatorURL\": \"http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0\"\n }\n ],\n \"groupLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"service\": \"gateway\"\n },\n \"commonLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"commonAnnotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"externalURL\": \"http://f054879d97db:9093\",\n \"version\": \"3\",\n \"groupKey\": 18195285354214865000\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/system/alert")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"receiver\": \"scale-up\",\n \"status\": \"firing\",\n \"alerts\": [\n {\n \"status\": \"firing\",\n \"labels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"annotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"startsAt\": \"2017-03-15T15:52:57.805Z\",\n \"endsAt\": \"0001-01-01T00:00:00Z\",\n \"generatorURL\": \"http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0\"\n }\n ],\n \"groupLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"service\": \"gateway\"\n },\n \"commonLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"commonAnnotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"externalURL\": \"http://f054879d97db:9093\",\n \"version\": \"3\",\n \"groupKey\": 18195285354214865000\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/system/alert') do |req|
req.body = "{\n \"receiver\": \"scale-up\",\n \"status\": \"firing\",\n \"alerts\": [\n {\n \"status\": \"firing\",\n \"labels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"annotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"startsAt\": \"2017-03-15T15:52:57.805Z\",\n \"endsAt\": \"0001-01-01T00:00:00Z\",\n \"generatorURL\": \"http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0\"\n }\n ],\n \"groupLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"service\": \"gateway\"\n },\n \"commonLabels\": {\n \"alertname\": \"APIHighInvocationRate\",\n \"code\": \"200\",\n \"function_name\": \"func_nodeinfo\",\n \"instance\": \"gateway:8080\",\n \"job\": \"gateway\",\n \"monitor\": \"faas-monitor\",\n \"service\": \"gateway\",\n \"severity\": \"major\",\n \"value\": \"8.998200359928017\"\n },\n \"commonAnnotations\": {\n \"description\": \"High invocation total on gateway:8080\",\n \"summary\": \"High invocation total on gateway:8080\"\n },\n \"externalURL\": \"http://f054879d97db:9093\",\n \"version\": \"3\",\n \"groupKey\": 18195285354214865000\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/system/alert";
let payload = json!({
"receiver": "scale-up",
"status": "firing",
"alerts": (
json!({
"status": "firing",
"labels": json!({
"alertname": "APIHighInvocationRate",
"code": "200",
"function_name": "func_nodeinfo",
"instance": "gateway:8080",
"job": "gateway",
"monitor": "faas-monitor",
"service": "gateway",
"severity": "major",
"value": "8.998200359928017"
}),
"annotations": json!({
"description": "High invocation total on gateway:8080",
"summary": "High invocation total on gateway:8080"
}),
"startsAt": "2017-03-15T15:52:57.805Z",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0"
})
),
"groupLabels": json!({
"alertname": "APIHighInvocationRate",
"service": "gateway"
}),
"commonLabels": json!({
"alertname": "APIHighInvocationRate",
"code": "200",
"function_name": "func_nodeinfo",
"instance": "gateway:8080",
"job": "gateway",
"monitor": "faas-monitor",
"service": "gateway",
"severity": "major",
"value": "8.998200359928017"
}),
"commonAnnotations": json!({
"description": "High invocation total on gateway:8080",
"summary": "High invocation total on gateway:8080"
}),
"externalURL": "http://f054879d97db:9093",
"version": "3",
"groupKey": 18195285354214865000
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/system/alert \
--header 'content-type: application/json' \
--data '{
"receiver": "scale-up",
"status": "firing",
"alerts": [
{
"status": "firing",
"labels": {
"alertname": "APIHighInvocationRate",
"code": "200",
"function_name": "func_nodeinfo",
"instance": "gateway:8080",
"job": "gateway",
"monitor": "faas-monitor",
"service": "gateway",
"severity": "major",
"value": "8.998200359928017"
},
"annotations": {
"description": "High invocation total on gateway:8080",
"summary": "High invocation total on gateway:8080"
},
"startsAt": "2017-03-15T15:52:57.805Z",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0"
}
],
"groupLabels": {
"alertname": "APIHighInvocationRate",
"service": "gateway"
},
"commonLabels": {
"alertname": "APIHighInvocationRate",
"code": "200",
"function_name": "func_nodeinfo",
"instance": "gateway:8080",
"job": "gateway",
"monitor": "faas-monitor",
"service": "gateway",
"severity": "major",
"value": "8.998200359928017"
},
"commonAnnotations": {
"description": "High invocation total on gateway:8080",
"summary": "High invocation total on gateway:8080"
},
"externalURL": "http://f054879d97db:9093",
"version": "3",
"groupKey": 18195285354214865000
}'
echo '{
"receiver": "scale-up",
"status": "firing",
"alerts": [
{
"status": "firing",
"labels": {
"alertname": "APIHighInvocationRate",
"code": "200",
"function_name": "func_nodeinfo",
"instance": "gateway:8080",
"job": "gateway",
"monitor": "faas-monitor",
"service": "gateway",
"severity": "major",
"value": "8.998200359928017"
},
"annotations": {
"description": "High invocation total on gateway:8080",
"summary": "High invocation total on gateway:8080"
},
"startsAt": "2017-03-15T15:52:57.805Z",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0"
}
],
"groupLabels": {
"alertname": "APIHighInvocationRate",
"service": "gateway"
},
"commonLabels": {
"alertname": "APIHighInvocationRate",
"code": "200",
"function_name": "func_nodeinfo",
"instance": "gateway:8080",
"job": "gateway",
"monitor": "faas-monitor",
"service": "gateway",
"severity": "major",
"value": "8.998200359928017"
},
"commonAnnotations": {
"description": "High invocation total on gateway:8080",
"summary": "High invocation total on gateway:8080"
},
"externalURL": "http://f054879d97db:9093",
"version": "3",
"groupKey": 18195285354214865000
}' | \
http POST {{baseUrl}}/system/alert \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "receiver": "scale-up",\n "status": "firing",\n "alerts": [\n {\n "status": "firing",\n "labels": {\n "alertname": "APIHighInvocationRate",\n "code": "200",\n "function_name": "func_nodeinfo",\n "instance": "gateway:8080",\n "job": "gateway",\n "monitor": "faas-monitor",\n "service": "gateway",\n "severity": "major",\n "value": "8.998200359928017"\n },\n "annotations": {\n "description": "High invocation total on gateway:8080",\n "summary": "High invocation total on gateway:8080"\n },\n "startsAt": "2017-03-15T15:52:57.805Z",\n "endsAt": "0001-01-01T00:00:00Z",\n "generatorURL": "http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0"\n }\n ],\n "groupLabels": {\n "alertname": "APIHighInvocationRate",\n "service": "gateway"\n },\n "commonLabels": {\n "alertname": "APIHighInvocationRate",\n "code": "200",\n "function_name": "func_nodeinfo",\n "instance": "gateway:8080",\n "job": "gateway",\n "monitor": "faas-monitor",\n "service": "gateway",\n "severity": "major",\n "value": "8.998200359928017"\n },\n "commonAnnotations": {\n "description": "High invocation total on gateway:8080",\n "summary": "High invocation total on gateway:8080"\n },\n "externalURL": "http://f054879d97db:9093",\n "version": "3",\n "groupKey": 18195285354214865000\n}' \
--output-document \
- {{baseUrl}}/system/alert
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"receiver": "scale-up",
"status": "firing",
"alerts": [
[
"status": "firing",
"labels": [
"alertname": "APIHighInvocationRate",
"code": "200",
"function_name": "func_nodeinfo",
"instance": "gateway:8080",
"job": "gateway",
"monitor": "faas-monitor",
"service": "gateway",
"severity": "major",
"value": "8.998200359928017"
],
"annotations": [
"description": "High invocation total on gateway:8080",
"summary": "High invocation total on gateway:8080"
],
"startsAt": "2017-03-15T15:52:57.805Z",
"endsAt": "0001-01-01T00:00:00Z",
"generatorURL": "http://4156cb797423:9090/graph?g0.expr=rate%28gateway_function_invocation_total%5B10s%5D%29+%3E+5&g0.tab=0"
]
],
"groupLabels": [
"alertname": "APIHighInvocationRate",
"service": "gateway"
],
"commonLabels": [
"alertname": "APIHighInvocationRate",
"code": "200",
"function_name": "func_nodeinfo",
"instance": "gateway:8080",
"job": "gateway",
"monitor": "faas-monitor",
"service": "gateway",
"severity": "major",
"value": "8.998200359928017"
],
"commonAnnotations": [
"description": "High invocation total on gateway:8080",
"summary": "High invocation total on gateway:8080"
],
"externalURL": "http://f054879d97db:9093",
"version": "3",
"groupKey": 18195285354214865000
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/system/alert")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
GET
Healthcheck
{{baseUrl}}/healthz
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/healthz");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/get "{{baseUrl}}/healthz")
require "http/client"
url = "{{baseUrl}}/healthz"
response = HTTP::Client.get url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("{{baseUrl}}/healthz"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/healthz");
var request = new RestRequest("", Method.Get);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/healthz"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
GET /baseUrl/healthz HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "{{baseUrl}}/healthz")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/healthz"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/healthz")
.get()
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.get("{{baseUrl}}/healthz")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('GET', '{{baseUrl}}/healthz');
xhr.send(data);
import axios from 'axios';
const options = {method: 'GET', url: '{{baseUrl}}/healthz'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/healthz';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/healthz',
method: 'GET',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/healthz")
.get()
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'GET',
hostname: 'example.com',
port: null,
path: '/baseUrl/healthz',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {method: 'GET', url: '{{baseUrl}}/healthz'};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('GET', '{{baseUrl}}/healthz');
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {method: 'GET', url: '{{baseUrl}}/healthz'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/healthz';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/healthz"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/healthz" in
Client.call `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/healthz",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('GET', '{{baseUrl}}/healthz');
echo $response->getBody();
setUrl('{{baseUrl}}/healthz');
$request->setMethod(HTTP_METH_GET);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/healthz');
$request->setRequestMethod('GET');
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/healthz' -Method GET
$response = Invoke-RestMethod -Uri '{{baseUrl}}/healthz' -Method GET
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("GET", "/baseUrl/healthz")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/healthz"
response = requests.get(url)
print(response.json())
library(httr)
url <- "{{baseUrl}}/healthz"
response <- VERB("GET", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/healthz")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.get('/baseUrl/healthz') do |req|
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/healthz";
let client = reqwest::Client::new();
let response = client.get(url)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request GET \
--url {{baseUrl}}/healthz
http GET {{baseUrl}}/healthz
wget --quiet \
--method GET \
--output-document \
- {{baseUrl}}/healthz
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/healthz")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
GET
Prometheus metrics
{{baseUrl}}/metrics
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/metrics");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/get "{{baseUrl}}/metrics")
require "http/client"
url = "{{baseUrl}}/metrics"
response = HTTP::Client.get url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("{{baseUrl}}/metrics"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/metrics");
var request = new RestRequest("", Method.Get);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/metrics"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
GET /baseUrl/metrics HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "{{baseUrl}}/metrics")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/metrics"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/metrics")
.get()
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.get("{{baseUrl}}/metrics")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('GET', '{{baseUrl}}/metrics');
xhr.send(data);
import axios from 'axios';
const options = {method: 'GET', url: '{{baseUrl}}/metrics'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/metrics';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/metrics',
method: 'GET',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/metrics")
.get()
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'GET',
hostname: 'example.com',
port: null,
path: '/baseUrl/metrics',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {method: 'GET', url: '{{baseUrl}}/metrics'};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('GET', '{{baseUrl}}/metrics');
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {method: 'GET', url: '{{baseUrl}}/metrics'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/metrics';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/metrics"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/metrics" in
Client.call `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/metrics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('GET', '{{baseUrl}}/metrics');
echo $response->getBody();
setUrl('{{baseUrl}}/metrics');
$request->setMethod(HTTP_METH_GET);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/metrics');
$request->setRequestMethod('GET');
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/metrics' -Method GET
$response = Invoke-RestMethod -Uri '{{baseUrl}}/metrics' -Method GET
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("GET", "/baseUrl/metrics")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/metrics"
response = requests.get(url)
print(response.json())
library(httr)
url <- "{{baseUrl}}/metrics"
response <- VERB("GET", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/metrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.get('/baseUrl/metrics') do |req|
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/metrics";
let client = reqwest::Client::new();
let response = client.get(url)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request GET \
--url {{baseUrl}}/metrics
http GET {{baseUrl}}/metrics
wget --quiet \
--method GET \
--output-document \
- {{baseUrl}}/metrics
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/metrics")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
CreateSecret
{{baseUrl}}/system/secrets
BODY json
{}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/system/secrets");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/system/secrets" {:content-type :json})
require "http/client"
url = "{{baseUrl}}/system/secrets"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/system/secrets"),
Content = new StringContent("{}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/system/secrets");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/system/secrets"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/system/secrets HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 2
{}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/system/secrets")
.setHeader("content-type", "application/json")
.setBody("{}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/system/secrets"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{}");
Request request = new Request.Builder()
.url("{{baseUrl}}/system/secrets")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/system/secrets")
.header("content-type", "application/json")
.body("{}")
.asString();
const data = JSON.stringify({});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/system/secrets');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/system/secrets',
headers: {'content-type': 'application/json'},
data: {}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/system/secrets';
const options = {method: 'POST', headers: {'content-type': 'application/json'}, body: '{}'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/system/secrets',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{}")
val request = Request.Builder()
.url("{{baseUrl}}/system/secrets")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/system/secrets',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/system/secrets',
headers: {'content-type': 'application/json'},
body: {},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/system/secrets');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/system/secrets',
headers: {'content-type': 'application/json'},
data: {}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/system/secrets';
const options = {method: 'POST', headers: {'content-type': 'application/json'}, body: '{}'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/system/secrets"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/system/secrets" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/system/secrets",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/system/secrets', [
'body' => '{}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/system/secrets');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
]));
$request->setRequestUrl('{{baseUrl}}/system/secrets');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/system/secrets' -Method POST -Headers $headers -ContentType 'application/json' -Body '{}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/system/secrets' -Method POST -Headers $headers -ContentType 'application/json' -Body '{}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/system/secrets", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/system/secrets"
payload = {}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/system/secrets"
payload <- "{}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/system/secrets")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/system/secrets') do |req|
req.body = "{}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/system/secrets";
let payload = json!({});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/system/secrets \
--header 'content-type: application/json' \
--data '{}'
echo '{}' | \
http POST {{baseUrl}}/system/secrets \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{}' \
--output-document \
- {{baseUrl}}/system/secrets
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/system/secrets")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
DELETE
DeleteSecret
{{baseUrl}}/system/secrets
BODY json
{
"name": "",
"namespace": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/system/secrets");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"name\": \"aws-key\",\n \"namespace\": \"openfaas-fn\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/delete "{{baseUrl}}/system/secrets" {:content-type :json
:form-params {:name "aws-key"
:namespace "openfaas-fn"}})
require "http/client"
url = "{{baseUrl}}/system/secrets"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"name\": \"aws-key\",\n \"namespace\": \"openfaas-fn\"\n}"
response = HTTP::Client.delete url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Delete,
RequestUri = new Uri("{{baseUrl}}/system/secrets"),
Content = new StringContent("{\n \"name\": \"aws-key\",\n \"namespace\": \"openfaas-fn\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/system/secrets");
var request = new RestRequest("", Method.Delete);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"name\": \"aws-key\",\n \"namespace\": \"openfaas-fn\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/system/secrets"
payload := strings.NewReader("{\n \"name\": \"aws-key\",\n \"namespace\": \"openfaas-fn\"\n}")
req, _ := http.NewRequest("DELETE", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
DELETE /baseUrl/system/secrets HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 53
{
"name": "aws-key",
"namespace": "openfaas-fn"
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("DELETE", "{{baseUrl}}/system/secrets")
.setHeader("content-type", "application/json")
.setBody("{\n \"name\": \"aws-key\",\n \"namespace\": \"openfaas-fn\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/system/secrets"))
.header("content-type", "application/json")
.method("DELETE", HttpRequest.BodyPublishers.ofString("{\n \"name\": \"aws-key\",\n \"namespace\": \"openfaas-fn\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"name\": \"aws-key\",\n \"namespace\": \"openfaas-fn\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/system/secrets")
.delete(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.delete("{{baseUrl}}/system/secrets")
.header("content-type", "application/json")
.body("{\n \"name\": \"aws-key\",\n \"namespace\": \"openfaas-fn\"\n}")
.asString();
const data = JSON.stringify({
name: 'aws-key',
namespace: 'openfaas-fn'
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('DELETE', '{{baseUrl}}/system/secrets');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'DELETE',
url: '{{baseUrl}}/system/secrets',
headers: {'content-type': 'application/json'},
data: {name: 'aws-key', namespace: 'openfaas-fn'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/system/secrets';
const options = {
method: 'DELETE',
headers: {'content-type': 'application/json'},
body: '{"name":"aws-key","namespace":"openfaas-fn"}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/system/secrets',
method: 'DELETE',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "name": "aws-key",\n "namespace": "openfaas-fn"\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"name\": \"aws-key\",\n \"namespace\": \"openfaas-fn\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/system/secrets")
.delete(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'DELETE',
hostname: 'example.com',
port: null,
path: '/baseUrl/system/secrets',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({name: 'aws-key', namespace: 'openfaas-fn'}));
req.end();
const request = require('request');
const options = {
method: 'DELETE',
url: '{{baseUrl}}/system/secrets',
headers: {'content-type': 'application/json'},
body: {name: 'aws-key', namespace: 'openfaas-fn'},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('DELETE', '{{baseUrl}}/system/secrets');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
name: 'aws-key',
namespace: 'openfaas-fn'
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'DELETE',
url: '{{baseUrl}}/system/secrets',
headers: {'content-type': 'application/json'},
data: {name: 'aws-key', namespace: 'openfaas-fn'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/system/secrets';
const options = {
method: 'DELETE',
headers: {'content-type': 'application/json'},
body: '{"name":"aws-key","namespace":"openfaas-fn"}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"name": @"aws-key",
@"namespace": @"openfaas-fn" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/system/secrets"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"DELETE"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/system/secrets" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"name\": \"aws-key\",\n \"namespace\": \"openfaas-fn\"\n}" in
Client.call ~headers ~body `DELETE uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/system/secrets",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'aws-key',
'namespace' => 'openfaas-fn'
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('DELETE', '{{baseUrl}}/system/secrets', [
'body' => '{
"name": "aws-key",
"namespace": "openfaas-fn"
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/system/secrets');
$request->setMethod(HTTP_METH_DELETE);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'name' => 'aws-key',
'namespace' => 'openfaas-fn'
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'name' => 'aws-key',
'namespace' => 'openfaas-fn'
]));
$request->setRequestUrl('{{baseUrl}}/system/secrets');
$request->setRequestMethod('DELETE');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/system/secrets' -Method DELETE -Headers $headers -ContentType 'application/json' -Body '{
"name": "aws-key",
"namespace": "openfaas-fn"
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/system/secrets' -Method DELETE -Headers $headers -ContentType 'application/json' -Body '{
"name": "aws-key",
"namespace": "openfaas-fn"
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"name\": \"aws-key\",\n \"namespace\": \"openfaas-fn\"\n}"
headers = { 'content-type': "application/json" }
conn.request("DELETE", "/baseUrl/system/secrets", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/system/secrets"
payload = {
"name": "aws-key",
"namespace": "openfaas-fn"
}
headers = {"content-type": "application/json"}
response = requests.delete(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/system/secrets"
payload <- "{\n \"name\": \"aws-key\",\n \"namespace\": \"openfaas-fn\"\n}"
encode <- "json"
response <- VERB("DELETE", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/system/secrets")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"name\": \"aws-key\",\n \"namespace\": \"openfaas-fn\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.delete('/baseUrl/system/secrets') do |req|
req.body = "{\n \"name\": \"aws-key\",\n \"namespace\": \"openfaas-fn\"\n}"
end
puts response.status
puts response.body
use std::str::FromStr;
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/system/secrets";
let payload = json!({
"name": "aws-key",
"namespace": "openfaas-fn"
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.request(reqwest::Method::from_str("DELETE").unwrap(), url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request DELETE \
--url {{baseUrl}}/system/secrets \
--header 'content-type: application/json' \
--data '{
"name": "aws-key",
"namespace": "openfaas-fn"
}'
echo '{
"name": "aws-key",
"namespace": "openfaas-fn"
}' | \
http DELETE {{baseUrl}}/system/secrets \
content-type:application/json
wget --quiet \
--method DELETE \
--header 'content-type: application/json' \
--body-data '{\n "name": "aws-key",\n "namespace": "openfaas-fn"\n}' \
--output-document \
- {{baseUrl}}/system/secrets
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"name": "aws-key",
"namespace": "openfaas-fn"
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/system/secrets")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "DELETE"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Deploy a new function.
{{baseUrl}}/system/functions
BODY json
{
"service": "",
"image": "",
"namespace": "",
"envProcess": "",
"constraints": [],
"envVars": {},
"secrets": [],
"labels": {},
"annotations": {},
"limits": "",
"requests": "",
"readOnlyRootFilesystem": false,
"registryAuth": "",
"network": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/system/functions");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/system/functions" {:content-type :json
:form-params {:service "nodeinfo"
:image "functions/nodeinfo:latest"
:namespace "openfaas-fn"
:envProcess "node main.js"
:constraints ["node.platform.os == linux"]
:secrets ["secret-name-1"]
:labels {:foo "bar"}
:annotations {:topics "awesome-kafka-topic"
:foo "bar"}
:registryAuth "dXNlcjpwYXNzd29yZA=="
:network "func_functions"}})
require "http/client"
url = "{{baseUrl}}/system/functions"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/system/functions"),
Content = new StringContent("{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/system/functions");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/system/functions"
payload := strings.NewReader("{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/system/functions HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 412
{
"service": "nodeinfo",
"image": "functions/nodeinfo:latest",
"namespace": "openfaas-fn",
"envProcess": "node main.js",
"constraints": [
"node.platform.os == linux"
],
"secrets": [
"secret-name-1"
],
"labels": {
"foo": "bar"
},
"annotations": {
"topics": "awesome-kafka-topic",
"foo": "bar"
},
"registryAuth": "dXNlcjpwYXNzd29yZA==",
"network": "func_functions"
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/system/functions")
.setHeader("content-type", "application/json")
.setBody("{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/system/functions"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/system/functions")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/system/functions")
.header("content-type", "application/json")
.body("{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}")
.asString();
const data = JSON.stringify({
service: 'nodeinfo',
image: 'functions/nodeinfo:latest',
namespace: 'openfaas-fn',
envProcess: 'node main.js',
constraints: [
'node.platform.os == linux'
],
secrets: [
'secret-name-1'
],
labels: {
foo: 'bar'
},
annotations: {
topics: 'awesome-kafka-topic',
foo: 'bar'
},
registryAuth: 'dXNlcjpwYXNzd29yZA==',
network: 'func_functions'
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/system/functions');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/system/functions',
headers: {'content-type': 'application/json'},
data: {
service: 'nodeinfo',
image: 'functions/nodeinfo:latest',
namespace: 'openfaas-fn',
envProcess: 'node main.js',
constraints: ['node.platform.os == linux'],
secrets: ['secret-name-1'],
labels: {foo: 'bar'},
annotations: {topics: 'awesome-kafka-topic', foo: 'bar'},
registryAuth: 'dXNlcjpwYXNzd29yZA==',
network: 'func_functions'
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/system/functions';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"service":"nodeinfo","image":"functions/nodeinfo:latest","namespace":"openfaas-fn","envProcess":"node main.js","constraints":["node.platform.os == linux"],"secrets":["secret-name-1"],"labels":{"foo":"bar"},"annotations":{"topics":"awesome-kafka-topic","foo":"bar"},"registryAuth":"dXNlcjpwYXNzd29yZA==","network":"func_functions"}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/system/functions',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "service": "nodeinfo",\n "image": "functions/nodeinfo:latest",\n "namespace": "openfaas-fn",\n "envProcess": "node main.js",\n "constraints": [\n "node.platform.os == linux"\n ],\n "secrets": [\n "secret-name-1"\n ],\n "labels": {\n "foo": "bar"\n },\n "annotations": {\n "topics": "awesome-kafka-topic",\n "foo": "bar"\n },\n "registryAuth": "dXNlcjpwYXNzd29yZA==",\n "network": "func_functions"\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/system/functions")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/system/functions',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
service: 'nodeinfo',
image: 'functions/nodeinfo:latest',
namespace: 'openfaas-fn',
envProcess: 'node main.js',
constraints: ['node.platform.os == linux'],
secrets: ['secret-name-1'],
labels: {foo: 'bar'},
annotations: {topics: 'awesome-kafka-topic', foo: 'bar'},
registryAuth: 'dXNlcjpwYXNzd29yZA==',
network: 'func_functions'
}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/system/functions',
headers: {'content-type': 'application/json'},
body: {
service: 'nodeinfo',
image: 'functions/nodeinfo:latest',
namespace: 'openfaas-fn',
envProcess: 'node main.js',
constraints: ['node.platform.os == linux'],
secrets: ['secret-name-1'],
labels: {foo: 'bar'},
annotations: {topics: 'awesome-kafka-topic', foo: 'bar'},
registryAuth: 'dXNlcjpwYXNzd29yZA==',
network: 'func_functions'
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/system/functions');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
service: 'nodeinfo',
image: 'functions/nodeinfo:latest',
namespace: 'openfaas-fn',
envProcess: 'node main.js',
constraints: [
'node.platform.os == linux'
],
secrets: [
'secret-name-1'
],
labels: {
foo: 'bar'
},
annotations: {
topics: 'awesome-kafka-topic',
foo: 'bar'
},
registryAuth: 'dXNlcjpwYXNzd29yZA==',
network: 'func_functions'
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/system/functions',
headers: {'content-type': 'application/json'},
data: {
service: 'nodeinfo',
image: 'functions/nodeinfo:latest',
namespace: 'openfaas-fn',
envProcess: 'node main.js',
constraints: ['node.platform.os == linux'],
secrets: ['secret-name-1'],
labels: {foo: 'bar'},
annotations: {topics: 'awesome-kafka-topic', foo: 'bar'},
registryAuth: 'dXNlcjpwYXNzd29yZA==',
network: 'func_functions'
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/system/functions';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"service":"nodeinfo","image":"functions/nodeinfo:latest","namespace":"openfaas-fn","envProcess":"node main.js","constraints":["node.platform.os == linux"],"secrets":["secret-name-1"],"labels":{"foo":"bar"},"annotations":{"topics":"awesome-kafka-topic","foo":"bar"},"registryAuth":"dXNlcjpwYXNzd29yZA==","network":"func_functions"}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"service": @"nodeinfo",
@"image": @"functions/nodeinfo:latest",
@"namespace": @"openfaas-fn",
@"envProcess": @"node main.js",
@"constraints": @[ @"node.platform.os == linux" ],
@"secrets": @[ @"secret-name-1" ],
@"labels": @{ @"foo": @"bar" },
@"annotations": @{ @"topics": @"awesome-kafka-topic", @"foo": @"bar" },
@"registryAuth": @"dXNlcjpwYXNzd29yZA==",
@"network": @"func_functions" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/system/functions"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/system/functions" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/system/functions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'service' => 'nodeinfo',
'image' => 'functions/nodeinfo:latest',
'namespace' => 'openfaas-fn',
'envProcess' => 'node main.js',
'constraints' => [
'node.platform.os == linux'
],
'secrets' => [
'secret-name-1'
],
'labels' => [
'foo' => 'bar'
],
'annotations' => [
'topics' => 'awesome-kafka-topic',
'foo' => 'bar'
],
'registryAuth' => 'dXNlcjpwYXNzd29yZA==',
'network' => 'func_functions'
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/system/functions', [
'body' => '{
"service": "nodeinfo",
"image": "functions/nodeinfo:latest",
"namespace": "openfaas-fn",
"envProcess": "node main.js",
"constraints": [
"node.platform.os == linux"
],
"secrets": [
"secret-name-1"
],
"labels": {
"foo": "bar"
},
"annotations": {
"topics": "awesome-kafka-topic",
"foo": "bar"
},
"registryAuth": "dXNlcjpwYXNzd29yZA==",
"network": "func_functions"
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/system/functions');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'service' => 'nodeinfo',
'image' => 'functions/nodeinfo:latest',
'namespace' => 'openfaas-fn',
'envProcess' => 'node main.js',
'constraints' => [
'node.platform.os == linux'
],
'secrets' => [
'secret-name-1'
],
'labels' => [
'foo' => 'bar'
],
'annotations' => [
'topics' => 'awesome-kafka-topic',
'foo' => 'bar'
],
'registryAuth' => 'dXNlcjpwYXNzd29yZA==',
'network' => 'func_functions'
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'service' => 'nodeinfo',
'image' => 'functions/nodeinfo:latest',
'namespace' => 'openfaas-fn',
'envProcess' => 'node main.js',
'constraints' => [
'node.platform.os == linux'
],
'secrets' => [
'secret-name-1'
],
'labels' => [
'foo' => 'bar'
],
'annotations' => [
'topics' => 'awesome-kafka-topic',
'foo' => 'bar'
],
'registryAuth' => 'dXNlcjpwYXNzd29yZA==',
'network' => 'func_functions'
]));
$request->setRequestUrl('{{baseUrl}}/system/functions');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/system/functions' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"service": "nodeinfo",
"image": "functions/nodeinfo:latest",
"namespace": "openfaas-fn",
"envProcess": "node main.js",
"constraints": [
"node.platform.os == linux"
],
"secrets": [
"secret-name-1"
],
"labels": {
"foo": "bar"
},
"annotations": {
"topics": "awesome-kafka-topic",
"foo": "bar"
},
"registryAuth": "dXNlcjpwYXNzd29yZA==",
"network": "func_functions"
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/system/functions' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"service": "nodeinfo",
"image": "functions/nodeinfo:latest",
"namespace": "openfaas-fn",
"envProcess": "node main.js",
"constraints": [
"node.platform.os == linux"
],
"secrets": [
"secret-name-1"
],
"labels": {
"foo": "bar"
},
"annotations": {
"topics": "awesome-kafka-topic",
"foo": "bar"
},
"registryAuth": "dXNlcjpwYXNzd29yZA==",
"network": "func_functions"
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/system/functions", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/system/functions"
payload = {
"service": "nodeinfo",
"image": "functions/nodeinfo:latest",
"namespace": "openfaas-fn",
"envProcess": "node main.js",
"constraints": ["node.platform.os == linux"],
"secrets": ["secret-name-1"],
"labels": { "foo": "bar" },
"annotations": {
"topics": "awesome-kafka-topic",
"foo": "bar"
},
"registryAuth": "dXNlcjpwYXNzd29yZA==",
"network": "func_functions"
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/system/functions"
payload <- "{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/system/functions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/system/functions') do |req|
req.body = "{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/system/functions";
let payload = json!({
"service": "nodeinfo",
"image": "functions/nodeinfo:latest",
"namespace": "openfaas-fn",
"envProcess": "node main.js",
"constraints": ("node.platform.os == linux"),
"secrets": ("secret-name-1"),
"labels": json!({"foo": "bar"}),
"annotations": json!({
"topics": "awesome-kafka-topic",
"foo": "bar"
}),
"registryAuth": "dXNlcjpwYXNzd29yZA==",
"network": "func_functions"
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/system/functions \
--header 'content-type: application/json' \
--data '{
"service": "nodeinfo",
"image": "functions/nodeinfo:latest",
"namespace": "openfaas-fn",
"envProcess": "node main.js",
"constraints": [
"node.platform.os == linux"
],
"secrets": [
"secret-name-1"
],
"labels": {
"foo": "bar"
},
"annotations": {
"topics": "awesome-kafka-topic",
"foo": "bar"
},
"registryAuth": "dXNlcjpwYXNzd29yZA==",
"network": "func_functions"
}'
echo '{
"service": "nodeinfo",
"image": "functions/nodeinfo:latest",
"namespace": "openfaas-fn",
"envProcess": "node main.js",
"constraints": [
"node.platform.os == linux"
],
"secrets": [
"secret-name-1"
],
"labels": {
"foo": "bar"
},
"annotations": {
"topics": "awesome-kafka-topic",
"foo": "bar"
},
"registryAuth": "dXNlcjpwYXNzd29yZA==",
"network": "func_functions"
}' | \
http POST {{baseUrl}}/system/functions \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "service": "nodeinfo",\n "image": "functions/nodeinfo:latest",\n "namespace": "openfaas-fn",\n "envProcess": "node main.js",\n "constraints": [\n "node.platform.os == linux"\n ],\n "secrets": [\n "secret-name-1"\n ],\n "labels": {\n "foo": "bar"\n },\n "annotations": {\n "topics": "awesome-kafka-topic",\n "foo": "bar"\n },\n "registryAuth": "dXNlcjpwYXNzd29yZA==",\n "network": "func_functions"\n}' \
--output-document \
- {{baseUrl}}/system/functions
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"service": "nodeinfo",
"image": "functions/nodeinfo:latest",
"namespace": "openfaas-fn",
"envProcess": "node main.js",
"constraints": ["node.platform.os == linux"],
"secrets": ["secret-name-1"],
"labels": ["foo": "bar"],
"annotations": [
"topics": "awesome-kafka-topic",
"foo": "bar"
],
"registryAuth": "dXNlcjpwYXNzd29yZA==",
"network": "func_functions"
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/system/functions")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
GET
Get a list of deployed functions with- stats and image digest
{{baseUrl}}/system/functions
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/system/functions");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/get "{{baseUrl}}/system/functions")
require "http/client"
url = "{{baseUrl}}/system/functions"
response = HTTP::Client.get url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("{{baseUrl}}/system/functions"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/system/functions");
var request = new RestRequest("", Method.Get);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/system/functions"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
GET /baseUrl/system/functions HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "{{baseUrl}}/system/functions")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/system/functions"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/system/functions")
.get()
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.get("{{baseUrl}}/system/functions")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('GET', '{{baseUrl}}/system/functions');
xhr.send(data);
import axios from 'axios';
const options = {method: 'GET', url: '{{baseUrl}}/system/functions'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/system/functions';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/system/functions',
method: 'GET',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/system/functions")
.get()
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'GET',
hostname: 'example.com',
port: null,
path: '/baseUrl/system/functions',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {method: 'GET', url: '{{baseUrl}}/system/functions'};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('GET', '{{baseUrl}}/system/functions');
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {method: 'GET', url: '{{baseUrl}}/system/functions'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/system/functions';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/system/functions"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/system/functions" in
Client.call `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/system/functions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('GET', '{{baseUrl}}/system/functions');
echo $response->getBody();
setUrl('{{baseUrl}}/system/functions');
$request->setMethod(HTTP_METH_GET);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/system/functions');
$request->setRequestMethod('GET');
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/system/functions' -Method GET
$response = Invoke-RestMethod -Uri '{{baseUrl}}/system/functions' -Method GET
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("GET", "/baseUrl/system/functions")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/system/functions"
response = requests.get(url)
print(response.json())
library(httr)
url <- "{{baseUrl}}/system/functions"
response <- VERB("GET", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/system/functions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.get('/baseUrl/system/functions') do |req|
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/system/functions";
let client = reqwest::Client::new();
let response = client.get(url)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request GET \
--url {{baseUrl}}/system/functions
http GET {{baseUrl}}/system/functions
wget --quiet \
--method GET \
--output-document \
- {{baseUrl}}/system/functions
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/system/functions")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
[
{
"name": "nodeinfo",
"image": "functions/nodeinfo:latest",
"namespace": "openfaas-fn",
"envProcess": "node main.js",
"labels": {
"foo": "bar"
},
"annotations": {
"topics": "awesome-kafka-topic",
"foo": "bar"
},
"invocationCount": 1337,
"replicas": 2,
"availableReplicas": 2
}
]
GET
Get a list of secret names and metadata from the provider
{{baseUrl}}/system/secrets
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/system/secrets");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/get "{{baseUrl}}/system/secrets")
require "http/client"
url = "{{baseUrl}}/system/secrets"
response = HTTP::Client.get url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("{{baseUrl}}/system/secrets"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/system/secrets");
var request = new RestRequest("", Method.Get);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/system/secrets"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
GET /baseUrl/system/secrets HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "{{baseUrl}}/system/secrets")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/system/secrets"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/system/secrets")
.get()
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.get("{{baseUrl}}/system/secrets")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('GET', '{{baseUrl}}/system/secrets');
xhr.send(data);
import axios from 'axios';
const options = {method: 'GET', url: '{{baseUrl}}/system/secrets'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/system/secrets';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/system/secrets',
method: 'GET',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/system/secrets")
.get()
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'GET',
hostname: 'example.com',
port: null,
path: '/baseUrl/system/secrets',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {method: 'GET', url: '{{baseUrl}}/system/secrets'};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('GET', '{{baseUrl}}/system/secrets');
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {method: 'GET', url: '{{baseUrl}}/system/secrets'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/system/secrets';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/system/secrets"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/system/secrets" in
Client.call `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/system/secrets",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('GET', '{{baseUrl}}/system/secrets');
echo $response->getBody();
setUrl('{{baseUrl}}/system/secrets');
$request->setMethod(HTTP_METH_GET);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/system/secrets');
$request->setRequestMethod('GET');
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/system/secrets' -Method GET
$response = Invoke-RestMethod -Uri '{{baseUrl}}/system/secrets' -Method GET
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("GET", "/baseUrl/system/secrets")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/system/secrets"
response = requests.get(url)
print(response.json())
library(httr)
url <- "{{baseUrl}}/system/secrets"
response <- VERB("GET", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/system/secrets")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.get('/baseUrl/system/secrets') do |req|
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/system/secrets";
let client = reqwest::Client::new();
let response = client.get(url)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request GET \
--url {{baseUrl}}/system/secrets
http GET {{baseUrl}}/system/secrets
wget --quiet \
--method GET \
--output-document \
- {{baseUrl}}/system/secrets
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/system/secrets")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"name": "aws-key",
"namespace": "openfaas-fn"
}
GET
Get info such as provider version number and provider orchestrator
{{baseUrl}}/system/info
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/system/info");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/get "{{baseUrl}}/system/info")
require "http/client"
url = "{{baseUrl}}/system/info"
response = HTTP::Client.get url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("{{baseUrl}}/system/info"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/system/info");
var request = new RestRequest("", Method.Get);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/system/info"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
GET /baseUrl/system/info HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "{{baseUrl}}/system/info")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/system/info"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/system/info")
.get()
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.get("{{baseUrl}}/system/info")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('GET', '{{baseUrl}}/system/info');
xhr.send(data);
import axios from 'axios';
const options = {method: 'GET', url: '{{baseUrl}}/system/info'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/system/info';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/system/info',
method: 'GET',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/system/info")
.get()
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'GET',
hostname: 'example.com',
port: null,
path: '/baseUrl/system/info',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {method: 'GET', url: '{{baseUrl}}/system/info'};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('GET', '{{baseUrl}}/system/info');
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {method: 'GET', url: '{{baseUrl}}/system/info'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/system/info';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/system/info"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/system/info" in
Client.call `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/system/info",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('GET', '{{baseUrl}}/system/info');
echo $response->getBody();
setUrl('{{baseUrl}}/system/info');
$request->setMethod(HTTP_METH_GET);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/system/info');
$request->setRequestMethod('GET');
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/system/info' -Method GET
$response = Invoke-RestMethod -Uri '{{baseUrl}}/system/info' -Method GET
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("GET", "/baseUrl/system/info")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/system/info"
response = requests.get(url)
print(response.json())
library(httr)
url <- "{{baseUrl}}/system/info"
response <- VERB("GET", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/system/info")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.get('/baseUrl/system/info') do |req|
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/system/info";
let client = reqwest::Client::new();
let response = client.get(url)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request GET \
--url {{baseUrl}}/system/info
http GET {{baseUrl}}/system/info
wget --quiet \
--method GET \
--output-document \
- {{baseUrl}}/system/info
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/system/info")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
{
"arch": "x86_64"
}
GET
GetFunctionLogs
{{baseUrl}}/system/logs
QUERY PARAMS
name
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/system/logs?name=");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/get "{{baseUrl}}/system/logs" {:query-params {:name ""}})
require "http/client"
url = "{{baseUrl}}/system/logs?name="
response = HTTP::Client.get url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("{{baseUrl}}/system/logs?name="),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/system/logs?name=");
var request = new RestRequest("", Method.Get);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/system/logs?name="
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
GET /baseUrl/system/logs?name= HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "{{baseUrl}}/system/logs?name=")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/system/logs?name="))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/system/logs?name=")
.get()
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.get("{{baseUrl}}/system/logs?name=")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('GET', '{{baseUrl}}/system/logs?name=');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'GET',
url: '{{baseUrl}}/system/logs',
params: {name: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/system/logs?name=';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/system/logs?name=',
method: 'GET',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/system/logs?name=")
.get()
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'GET',
hostname: 'example.com',
port: null,
path: '/baseUrl/system/logs?name=',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {method: 'GET', url: '{{baseUrl}}/system/logs', qs: {name: ''}};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('GET', '{{baseUrl}}/system/logs');
req.query({
name: ''
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'GET',
url: '{{baseUrl}}/system/logs',
params: {name: ''}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/system/logs?name=';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/system/logs?name="]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/system/logs?name=" in
Client.call `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/system/logs?name=",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('GET', '{{baseUrl}}/system/logs?name=');
echo $response->getBody();
setUrl('{{baseUrl}}/system/logs');
$request->setMethod(HTTP_METH_GET);
$request->setQueryData([
'name' => ''
]);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/system/logs');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString([
'name' => ''
]));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/system/logs?name=' -Method GET
$response = Invoke-RestMethod -Uri '{{baseUrl}}/system/logs?name=' -Method GET
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("GET", "/baseUrl/system/logs?name=")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/system/logs"
querystring = {"name":""}
response = requests.get(url, params=querystring)
print(response.json())
library(httr)
url <- "{{baseUrl}}/system/logs"
queryString <- list(name = "")
response <- VERB("GET", url, query = queryString, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/system/logs?name=")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.get('/baseUrl/system/logs') do |req|
req.params['name'] = ''
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/system/logs";
let querystring = [
("name", ""),
];
let client = reqwest::Client::new();
let response = client.get(url)
.query(&querystring)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request GET \
--url '{{baseUrl}}/system/logs?name='
http GET '{{baseUrl}}/system/logs?name='
wget --quiet \
--method GET \
--output-document \
- '{{baseUrl}}/system/logs?name='
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/system/logs?name=")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
GET
GetFunctionStatus
{{baseUrl}}/system/function/:functionName
QUERY PARAMS
functionName
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/system/function/:functionName");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/get "{{baseUrl}}/system/function/:functionName")
require "http/client"
url = "{{baseUrl}}/system/function/:functionName"
response = HTTP::Client.get url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("{{baseUrl}}/system/function/:functionName"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/system/function/:functionName");
var request = new RestRequest("", Method.Get);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/system/function/:functionName"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
GET /baseUrl/system/function/:functionName HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "{{baseUrl}}/system/function/:functionName")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/system/function/:functionName"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/system/function/:functionName")
.get()
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.get("{{baseUrl}}/system/function/:functionName")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('GET', '{{baseUrl}}/system/function/:functionName');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'GET',
url: '{{baseUrl}}/system/function/:functionName'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/system/function/:functionName';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/system/function/:functionName',
method: 'GET',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/system/function/:functionName")
.get()
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'GET',
hostname: 'example.com',
port: null,
path: '/baseUrl/system/function/:functionName',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {
method: 'GET',
url: '{{baseUrl}}/system/function/:functionName'
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('GET', '{{baseUrl}}/system/function/:functionName');
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'GET',
url: '{{baseUrl}}/system/function/:functionName'
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/system/function/:functionName';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/system/function/:functionName"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/system/function/:functionName" in
Client.call `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/system/function/:functionName",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('GET', '{{baseUrl}}/system/function/:functionName');
echo $response->getBody();
setUrl('{{baseUrl}}/system/function/:functionName');
$request->setMethod(HTTP_METH_GET);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/system/function/:functionName');
$request->setRequestMethod('GET');
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/system/function/:functionName' -Method GET
$response = Invoke-RestMethod -Uri '{{baseUrl}}/system/function/:functionName' -Method GET
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("GET", "/baseUrl/system/function/:functionName")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/system/function/:functionName"
response = requests.get(url)
print(response.json())
library(httr)
url <- "{{baseUrl}}/system/function/:functionName"
response <- VERB("GET", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/system/function/:functionName")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.get('/baseUrl/system/function/:functionName') do |req|
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/system/function/:functionName";
let client = reqwest::Client::new();
let response = client.get(url)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request GET \
--url {{baseUrl}}/system/function/:functionName
http GET {{baseUrl}}/system/function/:functionName
wget --quiet \
--method GET \
--output-document \
- {{baseUrl}}/system/function/:functionName
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/system/function/:functionName")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
RESPONSE HEADERS
Content-Type
*/*
RESPONSE BODY text
{
"name": "nodeinfo",
"image": "functions/nodeinfo:latest",
"namespace": "openfaas-fn",
"envProcess": "node main.js",
"constraints": [
"node.platform.os == linux"
],
"labels": {
"foo": "bar"
},
"annotations": {
"topics": "awesome-kafka-topic",
"foo": "bar"
},
"invocationCount": 1337,
"replicas": 2,
"availableReplicas": 2
}
GET
ListNamespaces
{{baseUrl}}/system/namespaces
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/system/namespaces");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/get "{{baseUrl}}/system/namespaces")
require "http/client"
url = "{{baseUrl}}/system/namespaces"
response = HTTP::Client.get url
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("{{baseUrl}}/system/namespaces"),
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/system/namespaces");
var request = new RestRequest("", Method.Get);
var response = client.Execute(request);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/system/namespaces"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
GET /baseUrl/system/namespaces HTTP/1.1
Host: example.com
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("GET", "{{baseUrl}}/system/namespaces")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/system/namespaces"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("{{baseUrl}}/system/namespaces")
.get()
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.get("{{baseUrl}}/system/namespaces")
.asString();
const data = null;
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('GET', '{{baseUrl}}/system/namespaces');
xhr.send(data);
import axios from 'axios';
const options = {method: 'GET', url: '{{baseUrl}}/system/namespaces'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/system/namespaces';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/system/namespaces',
method: 'GET',
headers: {}
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val request = Request.Builder()
.url("{{baseUrl}}/system/namespaces")
.get()
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'GET',
hostname: 'example.com',
port: null,
path: '/baseUrl/system/namespaces',
headers: {}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
const request = require('request');
const options = {method: 'GET', url: '{{baseUrl}}/system/namespaces'};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('GET', '{{baseUrl}}/system/namespaces');
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {method: 'GET', url: '{{baseUrl}}/system/namespaces'};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/system/namespaces';
const options = {method: 'GET'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/system/namespaces"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/system/namespaces" in
Client.call `GET uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/system/namespaces",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('GET', '{{baseUrl}}/system/namespaces');
echo $response->getBody();
setUrl('{{baseUrl}}/system/namespaces');
$request->setMethod(HTTP_METH_GET);
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
setRequestUrl('{{baseUrl}}/system/namespaces');
$request->setRequestMethod('GET');
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$response = Invoke-WebRequest -Uri '{{baseUrl}}/system/namespaces' -Method GET
$response = Invoke-RestMethod -Uri '{{baseUrl}}/system/namespaces' -Method GET
import http.client
conn = http.client.HTTPSConnection("example.com")
conn.request("GET", "/baseUrl/system/namespaces")
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/system/namespaces"
response = requests.get(url)
print(response.json())
library(httr)
url <- "{{baseUrl}}/system/namespaces"
response <- VERB("GET", url, content_type("application/octet-stream"))
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/system/namespaces")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
)
response = conn.get('/baseUrl/system/namespaces') do |req|
end
puts response.status
puts response.body
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/system/namespaces";
let client = reqwest::Client::new();
let response = client.get(url)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request GET \
--url {{baseUrl}}/system/namespaces
http GET {{baseUrl}}/system/namespaces
wget --quiet \
--method GET \
--output-document \
- {{baseUrl}}/system/namespaces
import Foundation
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/system/namespaces")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
RESPONSE HEADERS
Content-Type
application/json
RESPONSE BODY json
[
"openfaas-fn"
]
DELETE
Remove a deployed function.
{{baseUrl}}/system/functions
BODY json
{
"functionName": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/system/functions");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"functionName\": \"nodeinfo\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/delete "{{baseUrl}}/system/functions" {:content-type :json
:form-params {:functionName "nodeinfo"}})
require "http/client"
url = "{{baseUrl}}/system/functions"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"functionName\": \"nodeinfo\"\n}"
response = HTTP::Client.delete url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Delete,
RequestUri = new Uri("{{baseUrl}}/system/functions"),
Content = new StringContent("{\n \"functionName\": \"nodeinfo\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/system/functions");
var request = new RestRequest("", Method.Delete);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"functionName\": \"nodeinfo\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/system/functions"
payload := strings.NewReader("{\n \"functionName\": \"nodeinfo\"\n}")
req, _ := http.NewRequest("DELETE", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
DELETE /baseUrl/system/functions HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 32
{
"functionName": "nodeinfo"
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("DELETE", "{{baseUrl}}/system/functions")
.setHeader("content-type", "application/json")
.setBody("{\n \"functionName\": \"nodeinfo\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/system/functions"))
.header("content-type", "application/json")
.method("DELETE", HttpRequest.BodyPublishers.ofString("{\n \"functionName\": \"nodeinfo\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"functionName\": \"nodeinfo\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/system/functions")
.delete(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.delete("{{baseUrl}}/system/functions")
.header("content-type", "application/json")
.body("{\n \"functionName\": \"nodeinfo\"\n}")
.asString();
const data = JSON.stringify({
functionName: 'nodeinfo'
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('DELETE', '{{baseUrl}}/system/functions');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'DELETE',
url: '{{baseUrl}}/system/functions',
headers: {'content-type': 'application/json'},
data: {functionName: 'nodeinfo'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/system/functions';
const options = {
method: 'DELETE',
headers: {'content-type': 'application/json'},
body: '{"functionName":"nodeinfo"}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/system/functions',
method: 'DELETE',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "functionName": "nodeinfo"\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"functionName\": \"nodeinfo\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/system/functions")
.delete(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'DELETE',
hostname: 'example.com',
port: null,
path: '/baseUrl/system/functions',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({functionName: 'nodeinfo'}));
req.end();
const request = require('request');
const options = {
method: 'DELETE',
url: '{{baseUrl}}/system/functions',
headers: {'content-type': 'application/json'},
body: {functionName: 'nodeinfo'},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('DELETE', '{{baseUrl}}/system/functions');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
functionName: 'nodeinfo'
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'DELETE',
url: '{{baseUrl}}/system/functions',
headers: {'content-type': 'application/json'},
data: {functionName: 'nodeinfo'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/system/functions';
const options = {
method: 'DELETE',
headers: {'content-type': 'application/json'},
body: '{"functionName":"nodeinfo"}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"functionName": @"nodeinfo" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/system/functions"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"DELETE"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/system/functions" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"functionName\": \"nodeinfo\"\n}" in
Client.call ~headers ~body `DELETE uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/system/functions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => json_encode([
'functionName' => 'nodeinfo'
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('DELETE', '{{baseUrl}}/system/functions', [
'body' => '{
"functionName": "nodeinfo"
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/system/functions');
$request->setMethod(HTTP_METH_DELETE);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'functionName' => 'nodeinfo'
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'functionName' => 'nodeinfo'
]));
$request->setRequestUrl('{{baseUrl}}/system/functions');
$request->setRequestMethod('DELETE');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/system/functions' -Method DELETE -Headers $headers -ContentType 'application/json' -Body '{
"functionName": "nodeinfo"
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/system/functions' -Method DELETE -Headers $headers -ContentType 'application/json' -Body '{
"functionName": "nodeinfo"
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"functionName\": \"nodeinfo\"\n}"
headers = { 'content-type': "application/json" }
conn.request("DELETE", "/baseUrl/system/functions", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/system/functions"
payload = { "functionName": "nodeinfo" }
headers = {"content-type": "application/json"}
response = requests.delete(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/system/functions"
payload <- "{\n \"functionName\": \"nodeinfo\"\n}"
encode <- "json"
response <- VERB("DELETE", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/system/functions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"functionName\": \"nodeinfo\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.delete('/baseUrl/system/functions') do |req|
req.body = "{\n \"functionName\": \"nodeinfo\"\n}"
end
puts response.status
puts response.body
use std::str::FromStr;
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/system/functions";
let payload = json!({"functionName": "nodeinfo"});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.request(reqwest::Method::from_str("DELETE").unwrap(), url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request DELETE \
--url {{baseUrl}}/system/functions \
--header 'content-type: application/json' \
--data '{
"functionName": "nodeinfo"
}'
echo '{
"functionName": "nodeinfo"
}' | \
http DELETE {{baseUrl}}/system/functions \
content-type:application/json
wget --quiet \
--method DELETE \
--header 'content-type: application/json' \
--body-data '{\n "functionName": "nodeinfo"\n}' \
--output-document \
- {{baseUrl}}/system/functions
import Foundation
let headers = ["content-type": "application/json"]
let parameters = ["functionName": "nodeinfo"] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/system/functions")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "DELETE"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
POST
Scale a function to a specific replica count
{{baseUrl}}/system/scale-function/:functionName
QUERY PARAMS
functionName
BODY json
{
"serviceName": "",
"namespace": "",
"replicas": 0
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/system/scale-function/:functionName");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"serviceName\": \"nodeinfo\",\n \"namespace\": \"openfaas-fn\",\n \"replicas\": 2\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/post "{{baseUrl}}/system/scale-function/:functionName" {:content-type :json
:form-params {:serviceName "nodeinfo"
:namespace "openfaas-fn"
:replicas 2}})
require "http/client"
url = "{{baseUrl}}/system/scale-function/:functionName"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"serviceName\": \"nodeinfo\",\n \"namespace\": \"openfaas-fn\",\n \"replicas\": 2\n}"
response = HTTP::Client.post url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post,
RequestUri = new Uri("{{baseUrl}}/system/scale-function/:functionName"),
Content = new StringContent("{\n \"serviceName\": \"nodeinfo\",\n \"namespace\": \"openfaas-fn\",\n \"replicas\": 2\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/system/scale-function/:functionName");
var request = new RestRequest("", Method.Post);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"serviceName\": \"nodeinfo\",\n \"namespace\": \"openfaas-fn\",\n \"replicas\": 2\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/system/scale-function/:functionName"
payload := strings.NewReader("{\n \"serviceName\": \"nodeinfo\",\n \"namespace\": \"openfaas-fn\",\n \"replicas\": 2\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
POST /baseUrl/system/scale-function/:functionName HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 78
{
"serviceName": "nodeinfo",
"namespace": "openfaas-fn",
"replicas": 2
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("POST", "{{baseUrl}}/system/scale-function/:functionName")
.setHeader("content-type", "application/json")
.setBody("{\n \"serviceName\": \"nodeinfo\",\n \"namespace\": \"openfaas-fn\",\n \"replicas\": 2\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/system/scale-function/:functionName"))
.header("content-type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"serviceName\": \"nodeinfo\",\n \"namespace\": \"openfaas-fn\",\n \"replicas\": 2\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"serviceName\": \"nodeinfo\",\n \"namespace\": \"openfaas-fn\",\n \"replicas\": 2\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/system/scale-function/:functionName")
.post(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.post("{{baseUrl}}/system/scale-function/:functionName")
.header("content-type", "application/json")
.body("{\n \"serviceName\": \"nodeinfo\",\n \"namespace\": \"openfaas-fn\",\n \"replicas\": 2\n}")
.asString();
const data = JSON.stringify({
serviceName: 'nodeinfo',
namespace: 'openfaas-fn',
replicas: 2
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('POST', '{{baseUrl}}/system/scale-function/:functionName');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'POST',
url: '{{baseUrl}}/system/scale-function/:functionName',
headers: {'content-type': 'application/json'},
data: {serviceName: 'nodeinfo', namespace: 'openfaas-fn', replicas: 2}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/system/scale-function/:functionName';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"serviceName":"nodeinfo","namespace":"openfaas-fn","replicas":2}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/system/scale-function/:functionName',
method: 'POST',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "serviceName": "nodeinfo",\n "namespace": "openfaas-fn",\n "replicas": 2\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"serviceName\": \"nodeinfo\",\n \"namespace\": \"openfaas-fn\",\n \"replicas\": 2\n}")
val request = Request.Builder()
.url("{{baseUrl}}/system/scale-function/:functionName")
.post(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'POST',
hostname: 'example.com',
port: null,
path: '/baseUrl/system/scale-function/:functionName',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({serviceName: 'nodeinfo', namespace: 'openfaas-fn', replicas: 2}));
req.end();
const request = require('request');
const options = {
method: 'POST',
url: '{{baseUrl}}/system/scale-function/:functionName',
headers: {'content-type': 'application/json'},
body: {serviceName: 'nodeinfo', namespace: 'openfaas-fn', replicas: 2},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('POST', '{{baseUrl}}/system/scale-function/:functionName');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
serviceName: 'nodeinfo',
namespace: 'openfaas-fn',
replicas: 2
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'POST',
url: '{{baseUrl}}/system/scale-function/:functionName',
headers: {'content-type': 'application/json'},
data: {serviceName: 'nodeinfo', namespace: 'openfaas-fn', replicas: 2}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/system/scale-function/:functionName';
const options = {
method: 'POST',
headers: {'content-type': 'application/json'},
body: '{"serviceName":"nodeinfo","namespace":"openfaas-fn","replicas":2}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"serviceName": @"nodeinfo",
@"namespace": @"openfaas-fn",
@"replicas": @2 };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/system/scale-function/:functionName"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/system/scale-function/:functionName" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"serviceName\": \"nodeinfo\",\n \"namespace\": \"openfaas-fn\",\n \"replicas\": 2\n}" in
Client.call ~headers ~body `POST uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/system/scale-function/:functionName",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'serviceName' => 'nodeinfo',
'namespace' => 'openfaas-fn',
'replicas' => 2
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('POST', '{{baseUrl}}/system/scale-function/:functionName', [
'body' => '{
"serviceName": "nodeinfo",
"namespace": "openfaas-fn",
"replicas": 2
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/system/scale-function/:functionName');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'serviceName' => 'nodeinfo',
'namespace' => 'openfaas-fn',
'replicas' => 2
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'serviceName' => 'nodeinfo',
'namespace' => 'openfaas-fn',
'replicas' => 2
]));
$request->setRequestUrl('{{baseUrl}}/system/scale-function/:functionName');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/system/scale-function/:functionName' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"serviceName": "nodeinfo",
"namespace": "openfaas-fn",
"replicas": 2
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/system/scale-function/:functionName' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"serviceName": "nodeinfo",
"namespace": "openfaas-fn",
"replicas": 2
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"serviceName\": \"nodeinfo\",\n \"namespace\": \"openfaas-fn\",\n \"replicas\": 2\n}"
headers = { 'content-type': "application/json" }
conn.request("POST", "/baseUrl/system/scale-function/:functionName", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/system/scale-function/:functionName"
payload = {
"serviceName": "nodeinfo",
"namespace": "openfaas-fn",
"replicas": 2
}
headers = {"content-type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/system/scale-function/:functionName"
payload <- "{\n \"serviceName\": \"nodeinfo\",\n \"namespace\": \"openfaas-fn\",\n \"replicas\": 2\n}"
encode <- "json"
response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/system/scale-function/:functionName")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"serviceName\": \"nodeinfo\",\n \"namespace\": \"openfaas-fn\",\n \"replicas\": 2\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.post('/baseUrl/system/scale-function/:functionName') do |req|
req.body = "{\n \"serviceName\": \"nodeinfo\",\n \"namespace\": \"openfaas-fn\",\n \"replicas\": 2\n}"
end
puts response.status
puts response.body
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/system/scale-function/:functionName";
let payload = json!({
"serviceName": "nodeinfo",
"namespace": "openfaas-fn",
"replicas": 2
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.post(url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request POST \
--url {{baseUrl}}/system/scale-function/:functionName \
--header 'content-type: application/json' \
--data '{
"serviceName": "nodeinfo",
"namespace": "openfaas-fn",
"replicas": 2
}'
echo '{
"serviceName": "nodeinfo",
"namespace": "openfaas-fn",
"replicas": 2
}' | \
http POST {{baseUrl}}/system/scale-function/:functionName \
content-type:application/json
wget --quiet \
--method POST \
--header 'content-type: application/json' \
--body-data '{\n "serviceName": "nodeinfo",\n "namespace": "openfaas-fn",\n "replicas": 2\n}' \
--output-document \
- {{baseUrl}}/system/scale-function/:functionName
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"serviceName": "nodeinfo",
"namespace": "openfaas-fn",
"replicas": 2
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/system/scale-function/:functionName")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
PUT
Update a function.
{{baseUrl}}/system/functions
BODY json
{
"service": "",
"image": "",
"namespace": "",
"envProcess": "",
"constraints": [],
"envVars": {},
"secrets": [],
"labels": {},
"annotations": {},
"limits": "",
"requests": "",
"readOnlyRootFilesystem": false,
"registryAuth": "",
"network": ""
}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "PUT");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/system/functions");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/put "{{baseUrl}}/system/functions" {:content-type :json
:form-params {:service "nodeinfo"
:image "functions/nodeinfo:latest"
:namespace "openfaas-fn"
:envProcess "node main.js"
:constraints ["node.platform.os == linux"]
:secrets ["secret-name-1"]
:labels {:foo "bar"}
:annotations {:topics "awesome-kafka-topic"
:foo "bar"}
:registryAuth "dXNlcjpwYXNzd29yZA=="
:network "func_functions"}})
require "http/client"
url = "{{baseUrl}}/system/functions"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}"
response = HTTP::Client.put url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Put,
RequestUri = new Uri("{{baseUrl}}/system/functions"),
Content = new StringContent("{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/system/functions");
var request = new RestRequest("", Method.Put);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/system/functions"
payload := strings.NewReader("{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
PUT /baseUrl/system/functions HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 412
{
"service": "nodeinfo",
"image": "functions/nodeinfo:latest",
"namespace": "openfaas-fn",
"envProcess": "node main.js",
"constraints": [
"node.platform.os == linux"
],
"secrets": [
"secret-name-1"
],
"labels": {
"foo": "bar"
},
"annotations": {
"topics": "awesome-kafka-topic",
"foo": "bar"
},
"registryAuth": "dXNlcjpwYXNzd29yZA==",
"network": "func_functions"
}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("PUT", "{{baseUrl}}/system/functions")
.setHeader("content-type", "application/json")
.setBody("{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/system/functions"))
.header("content-type", "application/json")
.method("PUT", HttpRequest.BodyPublishers.ofString("{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}");
Request request = new Request.Builder()
.url("{{baseUrl}}/system/functions")
.put(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.put("{{baseUrl}}/system/functions")
.header("content-type", "application/json")
.body("{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}")
.asString();
const data = JSON.stringify({
service: 'nodeinfo',
image: 'functions/nodeinfo:latest',
namespace: 'openfaas-fn',
envProcess: 'node main.js',
constraints: [
'node.platform.os == linux'
],
secrets: [
'secret-name-1'
],
labels: {
foo: 'bar'
},
annotations: {
topics: 'awesome-kafka-topic',
foo: 'bar'
},
registryAuth: 'dXNlcjpwYXNzd29yZA==',
network: 'func_functions'
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('PUT', '{{baseUrl}}/system/functions');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'PUT',
url: '{{baseUrl}}/system/functions',
headers: {'content-type': 'application/json'},
data: {
service: 'nodeinfo',
image: 'functions/nodeinfo:latest',
namespace: 'openfaas-fn',
envProcess: 'node main.js',
constraints: ['node.platform.os == linux'],
secrets: ['secret-name-1'],
labels: {foo: 'bar'},
annotations: {topics: 'awesome-kafka-topic', foo: 'bar'},
registryAuth: 'dXNlcjpwYXNzd29yZA==',
network: 'func_functions'
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/system/functions';
const options = {
method: 'PUT',
headers: {'content-type': 'application/json'},
body: '{"service":"nodeinfo","image":"functions/nodeinfo:latest","namespace":"openfaas-fn","envProcess":"node main.js","constraints":["node.platform.os == linux"],"secrets":["secret-name-1"],"labels":{"foo":"bar"},"annotations":{"topics":"awesome-kafka-topic","foo":"bar"},"registryAuth":"dXNlcjpwYXNzd29yZA==","network":"func_functions"}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/system/functions',
method: 'PUT',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{\n "service": "nodeinfo",\n "image": "functions/nodeinfo:latest",\n "namespace": "openfaas-fn",\n "envProcess": "node main.js",\n "constraints": [\n "node.platform.os == linux"\n ],\n "secrets": [\n "secret-name-1"\n ],\n "labels": {\n "foo": "bar"\n },\n "annotations": {\n "topics": "awesome-kafka-topic",\n "foo": "bar"\n },\n "registryAuth": "dXNlcjpwYXNzd29yZA==",\n "network": "func_functions"\n}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}")
val request = Request.Builder()
.url("{{baseUrl}}/system/functions")
.put(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'PUT',
hostname: 'example.com',
port: null,
path: '/baseUrl/system/functions',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({
service: 'nodeinfo',
image: 'functions/nodeinfo:latest',
namespace: 'openfaas-fn',
envProcess: 'node main.js',
constraints: ['node.platform.os == linux'],
secrets: ['secret-name-1'],
labels: {foo: 'bar'},
annotations: {topics: 'awesome-kafka-topic', foo: 'bar'},
registryAuth: 'dXNlcjpwYXNzd29yZA==',
network: 'func_functions'
}));
req.end();
const request = require('request');
const options = {
method: 'PUT',
url: '{{baseUrl}}/system/functions',
headers: {'content-type': 'application/json'},
body: {
service: 'nodeinfo',
image: 'functions/nodeinfo:latest',
namespace: 'openfaas-fn',
envProcess: 'node main.js',
constraints: ['node.platform.os == linux'],
secrets: ['secret-name-1'],
labels: {foo: 'bar'},
annotations: {topics: 'awesome-kafka-topic', foo: 'bar'},
registryAuth: 'dXNlcjpwYXNzd29yZA==',
network: 'func_functions'
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('PUT', '{{baseUrl}}/system/functions');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({
service: 'nodeinfo',
image: 'functions/nodeinfo:latest',
namespace: 'openfaas-fn',
envProcess: 'node main.js',
constraints: [
'node.platform.os == linux'
],
secrets: [
'secret-name-1'
],
labels: {
foo: 'bar'
},
annotations: {
topics: 'awesome-kafka-topic',
foo: 'bar'
},
registryAuth: 'dXNlcjpwYXNzd29yZA==',
network: 'func_functions'
});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'PUT',
url: '{{baseUrl}}/system/functions',
headers: {'content-type': 'application/json'},
data: {
service: 'nodeinfo',
image: 'functions/nodeinfo:latest',
namespace: 'openfaas-fn',
envProcess: 'node main.js',
constraints: ['node.platform.os == linux'],
secrets: ['secret-name-1'],
labels: {foo: 'bar'},
annotations: {topics: 'awesome-kafka-topic', foo: 'bar'},
registryAuth: 'dXNlcjpwYXNzd29yZA==',
network: 'func_functions'
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/system/functions';
const options = {
method: 'PUT',
headers: {'content-type': 'application/json'},
body: '{"service":"nodeinfo","image":"functions/nodeinfo:latest","namespace":"openfaas-fn","envProcess":"node main.js","constraints":["node.platform.os == linux"],"secrets":["secret-name-1"],"labels":{"foo":"bar"},"annotations":{"topics":"awesome-kafka-topic","foo":"bar"},"registryAuth":"dXNlcjpwYXNzd29yZA==","network":"func_functions"}'
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ @"service": @"nodeinfo",
@"image": @"functions/nodeinfo:latest",
@"namespace": @"openfaas-fn",
@"envProcess": @"node main.js",
@"constraints": @[ @"node.platform.os == linux" ],
@"secrets": @[ @"secret-name-1" ],
@"labels": @{ @"foo": @"bar" },
@"annotations": @{ @"topics": @"awesome-kafka-topic", @"foo": @"bar" },
@"registryAuth": @"dXNlcjpwYXNzd29yZA==",
@"network": @"func_functions" };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/system/functions"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"PUT"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/system/functions" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}" in
Client.call ~headers ~body `PUT uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/system/functions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'service' => 'nodeinfo',
'image' => 'functions/nodeinfo:latest',
'namespace' => 'openfaas-fn',
'envProcess' => 'node main.js',
'constraints' => [
'node.platform.os == linux'
],
'secrets' => [
'secret-name-1'
],
'labels' => [
'foo' => 'bar'
],
'annotations' => [
'topics' => 'awesome-kafka-topic',
'foo' => 'bar'
],
'registryAuth' => 'dXNlcjpwYXNzd29yZA==',
'network' => 'func_functions'
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('PUT', '{{baseUrl}}/system/functions', [
'body' => '{
"service": "nodeinfo",
"image": "functions/nodeinfo:latest",
"namespace": "openfaas-fn",
"envProcess": "node main.js",
"constraints": [
"node.platform.os == linux"
],
"secrets": [
"secret-name-1"
],
"labels": {
"foo": "bar"
},
"annotations": {
"topics": "awesome-kafka-topic",
"foo": "bar"
},
"registryAuth": "dXNlcjpwYXNzd29yZA==",
"network": "func_functions"
}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/system/functions');
$request->setMethod(HTTP_METH_PUT);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
'service' => 'nodeinfo',
'image' => 'functions/nodeinfo:latest',
'namespace' => 'openfaas-fn',
'envProcess' => 'node main.js',
'constraints' => [
'node.platform.os == linux'
],
'secrets' => [
'secret-name-1'
],
'labels' => [
'foo' => 'bar'
],
'annotations' => [
'topics' => 'awesome-kafka-topic',
'foo' => 'bar'
],
'registryAuth' => 'dXNlcjpwYXNzd29yZA==',
'network' => 'func_functions'
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
'service' => 'nodeinfo',
'image' => 'functions/nodeinfo:latest',
'namespace' => 'openfaas-fn',
'envProcess' => 'node main.js',
'constraints' => [
'node.platform.os == linux'
],
'secrets' => [
'secret-name-1'
],
'labels' => [
'foo' => 'bar'
],
'annotations' => [
'topics' => 'awesome-kafka-topic',
'foo' => 'bar'
],
'registryAuth' => 'dXNlcjpwYXNzd29yZA==',
'network' => 'func_functions'
]));
$request->setRequestUrl('{{baseUrl}}/system/functions');
$request->setRequestMethod('PUT');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/system/functions' -Method PUT -Headers $headers -ContentType 'application/json' -Body '{
"service": "nodeinfo",
"image": "functions/nodeinfo:latest",
"namespace": "openfaas-fn",
"envProcess": "node main.js",
"constraints": [
"node.platform.os == linux"
],
"secrets": [
"secret-name-1"
],
"labels": {
"foo": "bar"
},
"annotations": {
"topics": "awesome-kafka-topic",
"foo": "bar"
},
"registryAuth": "dXNlcjpwYXNzd29yZA==",
"network": "func_functions"
}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/system/functions' -Method PUT -Headers $headers -ContentType 'application/json' -Body '{
"service": "nodeinfo",
"image": "functions/nodeinfo:latest",
"namespace": "openfaas-fn",
"envProcess": "node main.js",
"constraints": [
"node.platform.os == linux"
],
"secrets": [
"secret-name-1"
],
"labels": {
"foo": "bar"
},
"annotations": {
"topics": "awesome-kafka-topic",
"foo": "bar"
},
"registryAuth": "dXNlcjpwYXNzd29yZA==",
"network": "func_functions"
}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}"
headers = { 'content-type': "application/json" }
conn.request("PUT", "/baseUrl/system/functions", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/system/functions"
payload = {
"service": "nodeinfo",
"image": "functions/nodeinfo:latest",
"namespace": "openfaas-fn",
"envProcess": "node main.js",
"constraints": ["node.platform.os == linux"],
"secrets": ["secret-name-1"],
"labels": { "foo": "bar" },
"annotations": {
"topics": "awesome-kafka-topic",
"foo": "bar"
},
"registryAuth": "dXNlcjpwYXNzd29yZA==",
"network": "func_functions"
}
headers = {"content-type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/system/functions"
payload <- "{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}"
encode <- "json"
response <- VERB("PUT", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/system/functions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["content-type"] = 'application/json'
request.body = "{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.put('/baseUrl/system/functions') do |req|
req.body = "{\n \"service\": \"nodeinfo\",\n \"image\": \"functions/nodeinfo:latest\",\n \"namespace\": \"openfaas-fn\",\n \"envProcess\": \"node main.js\",\n \"constraints\": [\n \"node.platform.os == linux\"\n ],\n \"secrets\": [\n \"secret-name-1\"\n ],\n \"labels\": {\n \"foo\": \"bar\"\n },\n \"annotations\": {\n \"topics\": \"awesome-kafka-topic\",\n \"foo\": \"bar\"\n },\n \"registryAuth\": \"dXNlcjpwYXNzd29yZA==\",\n \"network\": \"func_functions\"\n}"
end
puts response.status
puts response.body
use std::str::FromStr;
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/system/functions";
let payload = json!({
"service": "nodeinfo",
"image": "functions/nodeinfo:latest",
"namespace": "openfaas-fn",
"envProcess": "node main.js",
"constraints": ("node.platform.os == linux"),
"secrets": ("secret-name-1"),
"labels": json!({"foo": "bar"}),
"annotations": json!({
"topics": "awesome-kafka-topic",
"foo": "bar"
}),
"registryAuth": "dXNlcjpwYXNzd29yZA==",
"network": "func_functions"
});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.request(reqwest::Method::from_str("PUT").unwrap(), url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request PUT \
--url {{baseUrl}}/system/functions \
--header 'content-type: application/json' \
--data '{
"service": "nodeinfo",
"image": "functions/nodeinfo:latest",
"namespace": "openfaas-fn",
"envProcess": "node main.js",
"constraints": [
"node.platform.os == linux"
],
"secrets": [
"secret-name-1"
],
"labels": {
"foo": "bar"
},
"annotations": {
"topics": "awesome-kafka-topic",
"foo": "bar"
},
"registryAuth": "dXNlcjpwYXNzd29yZA==",
"network": "func_functions"
}'
echo '{
"service": "nodeinfo",
"image": "functions/nodeinfo:latest",
"namespace": "openfaas-fn",
"envProcess": "node main.js",
"constraints": [
"node.platform.os == linux"
],
"secrets": [
"secret-name-1"
],
"labels": {
"foo": "bar"
},
"annotations": {
"topics": "awesome-kafka-topic",
"foo": "bar"
},
"registryAuth": "dXNlcjpwYXNzd29yZA==",
"network": "func_functions"
}' | \
http PUT {{baseUrl}}/system/functions \
content-type:application/json
wget --quiet \
--method PUT \
--header 'content-type: application/json' \
--body-data '{\n "service": "nodeinfo",\n "image": "functions/nodeinfo:latest",\n "namespace": "openfaas-fn",\n "envProcess": "node main.js",\n "constraints": [\n "node.platform.os == linux"\n ],\n "secrets": [\n "secret-name-1"\n ],\n "labels": {\n "foo": "bar"\n },\n "annotations": {\n "topics": "awesome-kafka-topic",\n "foo": "bar"\n },\n "registryAuth": "dXNlcjpwYXNzd29yZA==",\n "network": "func_functions"\n}' \
--output-document \
- {{baseUrl}}/system/functions
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [
"service": "nodeinfo",
"image": "functions/nodeinfo:latest",
"namespace": "openfaas-fn",
"envProcess": "node main.js",
"constraints": ["node.platform.os == linux"],
"secrets": ["secret-name-1"],
"labels": ["foo": "bar"],
"annotations": [
"topics": "awesome-kafka-topic",
"foo": "bar"
],
"registryAuth": "dXNlcjpwYXNzd29yZA==",
"network": "func_functions"
] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/system/functions")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()
PUT
Update a secret, the value is replaced.
{{baseUrl}}/system/secrets
BODY json
{}
Examples
REQUEST
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "PUT");
curl_easy_setopt(hnd, CURLOPT_URL, "{{baseUrl}}/system/secrets");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "content-type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{}");
CURLcode ret = curl_easy_perform(hnd);
(require '[clj-http.client :as client])
(client/put "{{baseUrl}}/system/secrets" {:content-type :json})
require "http/client"
url = "{{baseUrl}}/system/secrets"
headers = HTTP::Headers{
"content-type" => "application/json"
}
reqBody = "{}"
response = HTTP::Client.put url, headers: headers, body: reqBody
puts response.body
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Put,
RequestUri = new Uri("{{baseUrl}}/system/secrets"),
Content = new StringContent("{}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}
var client = new RestClient("{{baseUrl}}/system/secrets");
var request = new RestRequest("", Method.Put);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
var response = client.Execute(request);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{baseUrl}}/system/secrets"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("content-type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
PUT /baseUrl/system/secrets HTTP/1.1
Content-Type: application/json
Host: example.com
Content-Length: 2
{}
AsyncHttpClient client = new DefaultAsyncHttpClient();
client.prepare("PUT", "{{baseUrl}}/system/secrets")
.setHeader("content-type", "application/json")
.setBody("{}")
.execute()
.toCompletableFuture()
.thenAccept(System.out::println)
.join();
client.close();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("{{baseUrl}}/system/secrets"))
.header("content-type", "application/json")
.method("PUT", HttpRequest.BodyPublishers.ofString("{}"))
.build();
HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{}");
Request request = new Request.Builder()
.url("{{baseUrl}}/system/secrets")
.put(body)
.addHeader("content-type", "application/json")
.build();
Response response = client.newCall(request).execute();
HttpResponse response = Unirest.put("{{baseUrl}}/system/secrets")
.header("content-type", "application/json")
.body("{}")
.asString();
const data = JSON.stringify({});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open('PUT', '{{baseUrl}}/system/secrets');
xhr.setRequestHeader('content-type', 'application/json');
xhr.send(data);
import axios from 'axios';
const options = {
method: 'PUT',
url: '{{baseUrl}}/system/secrets',
headers: {'content-type': 'application/json'},
data: {}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const url = '{{baseUrl}}/system/secrets';
const options = {method: 'PUT', headers: {'content-type': 'application/json'}, body: '{}'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
const settings = {
async: true,
crossDomain: true,
url: '{{baseUrl}}/system/secrets',
method: 'PUT',
headers: {
'content-type': 'application/json'
},
processData: false,
data: '{}'
};
$.ajax(settings).done(function (response) {
console.log(response);
});
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{}")
val request = Request.Builder()
.url("{{baseUrl}}/system/secrets")
.put(body)
.addHeader("content-type", "application/json")
.build()
val response = client.newCall(request).execute()
const http = require('https');
const options = {
method: 'PUT',
hostname: 'example.com',
port: null,
path: '/baseUrl/system/secrets',
headers: {
'content-type': 'application/json'
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on('data', function (chunk) {
chunks.push(chunk);
});
res.on('end', function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({}));
req.end();
const request = require('request');
const options = {
method: 'PUT',
url: '{{baseUrl}}/system/secrets',
headers: {'content-type': 'application/json'},
body: {},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
const unirest = require('unirest');
const req = unirest('PUT', '{{baseUrl}}/system/secrets');
req.headers({
'content-type': 'application/json'
});
req.type('json');
req.send({});
req.end(function (res) {
if (res.error) throw new Error(res.error);
console.log(res.body);
});
const axios = require('axios').default;
const options = {
method: 'PUT',
url: '{{baseUrl}}/system/secrets',
headers: {'content-type': 'application/json'},
data: {}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
const fetch = require('node-fetch');
const url = '{{baseUrl}}/system/secrets';
const options = {method: 'PUT', headers: {'content-type': 'application/json'}, body: '{}'};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
#import
NSDictionary *headers = @{ @"content-type": @"application/json" };
NSDictionary *parameters = @{ };
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"{{baseUrl}}/system/secrets"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"PUT"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
open Cohttp_lwt_unix
open Cohttp
open Lwt
let uri = Uri.of_string "{{baseUrl}}/system/secrets" in
let headers = Header.add (Header.init ()) "content-type" "application/json" in
let body = Cohttp_lwt_body.of_string "{}" in
Client.call ~headers ~body `PUT uri
>>= fun (res, body_stream) ->
(* Do stuff with the result *)
"{{baseUrl}}/system/secrets",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
]),
CURLOPT_HTTPHEADER => [
"content-type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
request('PUT', '{{baseUrl}}/system/secrets', [
'body' => '{}',
'headers' => [
'content-type' => 'application/json',
],
]);
echo $response->getBody();
setUrl('{{baseUrl}}/system/secrets');
$request->setMethod(HTTP_METH_PUT);
$request->setHeaders([
'content-type' => 'application/json'
]);
$request->setContentType('application/json');
$request->setBody(json_encode([
]));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
append(json_encode([
]));
$request->setRequestUrl('{{baseUrl}}/system/secrets');
$request->setRequestMethod('PUT');
$request->setBody($body);
$request->setHeaders([
'content-type' => 'application/json'
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-WebRequest -Uri '{{baseUrl}}/system/secrets' -Method PUT -Headers $headers -ContentType 'application/json' -Body '{}'
$headers=@{}
$headers.Add("content-type", "application/json")
$response = Invoke-RestMethod -Uri '{{baseUrl}}/system/secrets' -Method PUT -Headers $headers -ContentType 'application/json' -Body '{}'
import http.client
conn = http.client.HTTPSConnection("example.com")
payload = "{}"
headers = { 'content-type': "application/json" }
conn.request("PUT", "/baseUrl/system/secrets", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import requests
url = "{{baseUrl}}/system/secrets"
payload = {}
headers = {"content-type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.json())
library(httr)
url <- "{{baseUrl}}/system/secrets"
payload <- "{}"
encode <- "json"
response <- VERB("PUT", url, body = payload, content_type("application/json"), encode = encode)
content(response, "text")
require 'uri'
require 'net/http'
url = URI("{{baseUrl}}/system/secrets")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["content-type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_body
require 'faraday'
conn = Faraday.new(
url: 'https://example.com',
headers: {'Content-Type' => 'application/json'}
)
response = conn.put('/baseUrl/system/secrets') do |req|
req.body = "{}"
end
puts response.status
puts response.body
use std::str::FromStr;
use serde_json::json;
use reqwest;
#[tokio::main]
pub async fn main() {
let url = "{{baseUrl}}/system/secrets";
let payload = json!({});
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("content-type", "application/json".parse().unwrap());
let client = reqwest::Client::new();
let response = client.request(reqwest::Method::from_str("PUT").unwrap(), url)
.headers(headers)
.json(&payload)
.send()
.await;
let results = response.unwrap()
.json::()
.await
.unwrap();
dbg!(results);
}
curl --request PUT \
--url {{baseUrl}}/system/secrets \
--header 'content-type: application/json' \
--data '{}'
echo '{}' | \
http PUT {{baseUrl}}/system/secrets \
content-type:application/json
wget --quiet \
--method PUT \
--header 'content-type: application/json' \
--body-data '{}' \
--output-document \
- {{baseUrl}}/system/secrets
import Foundation
let headers = ["content-type": "application/json"]
let parameters = [] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "{{baseUrl}}/system/secrets")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()