👈
Callback
Get and receive data from outside Naas network, usefull for OAuth and other need who need light and fast response.
In local you need to run the callback machine to make it work. refer to the doc to install it.

Create

Create callback URL
1
url, uuid = naas.callback.add()
Copied!

Without self destroy

1
url, uuid = naas.callback.add(auto_delete=False)
Copied!

With custom response

1
url, uuid = naas.callback.add(response={"toto": "tata"})
Copied!

With custom response headers

1
url, uuid = naas.callback.add(response_headers={"toto": "tata"})
Copied!

With default result

1
url, uuid = naas.callback.add(default_result={"toto": "tata"})
Copied!

Disable override response

If URL is called multiple time, only the first response will be kept
1
url, uuid = naas.callback.add(no_override=True)
Copied!

For specifics user (Admin)

1
url, uuid = naas.callback.add(user="[email protected]")
Copied!

Force UUID (Admin)

1
url, uuid = naas.callback.add(user="[email protected]", uuid="test")
Copied!

List

You can list all callback you have created
1
df = naas.callback.list()
Copied!

For specifics user (Admin)

1
df = naas.callback.list(user="[email protected]")
Copied!

Get

You can get a callback result.
if a callback didn't been called yet, the result will be None
1
data, headers = naas.callback.get(uuid)
Copied!

Wait until data present

It will wait a maximum of 3000 sec
1
data, headers = naas.callback.get(uuid, True)
Copied!

Wait until data present with Timeout

timeout is in seconds
1
data, headers = naas.callback.get(uuid, True, 10)
Copied!

Get the full data

1
data = naas.callback.get(uuid, raw=True)
Copied!

For specifics user (Admin)

1
url, uuid = naas.callback.get(uuid, user="[email protected]")
Copied!

Delete

You can remove any callback by UUID.
1
naas.callback.delete(uuid)
Copied!

For specifics user (Admin)

1
naas.callback.delete(user="[email protected]")
Copied!

List all (Admin)

Allows retrieving all callback made by all users as admin.
1
import naas
2
naas.callback.list_all()
Copied!