Astarte device API for C++ 0.8.1
Astarte device SDK for C++
Loading...
Searching...
No Matches
astarte::device::mqtt::PairingApi Class Reference

Class providing the methods to perform the Astarte pairing operations. More...

#include <pairing.hpp>

Public Member Functions

auto register_device (std::string_view pairing_token, std::chrono::milliseconds timeout_ms=0ms) const -> astarte_tl::expected< std::string, Error >
 Registers a device.
 
auto get_broker_url (std::string_view credential_secret, int timeout_ms=0) const -> astarte_tl::expected< std::string, Error >
 Retrieves the URL of the Astarte MQTT broker.
 
auto get_device_key_and_certificate (std::string_view credential_secret, int timeout_ms=0) const -> astarte_tl::expected< std::tuple< std::string, std::string >, Error >
 Retrieves the Astarte device certificate and relative private key.
 
auto device_cert_valid (std::string_view certificate, std::string_view credential_secret, int timeout_ms=0) const -> astarte_tl::expected< bool, Error >
 Checks if the Astarte device certificate is valid.
 

Static Public Member Functions

static auto create (std::string_view realm, std::string_view device_id, std::string_view astarte_base_url) -> astarte_tl::expected< PairingApi, Error >
 Creates an instance of the PairingApi class.
 

Detailed Description

Class providing the methods to perform the Astarte pairing operations.

This class handles interactions with the Astarte Pairing API, including device registration and fetching MQTT broker credentials or certificates.

Member Function Documentation

◆ create()

static auto astarte::device::mqtt::PairingApi::create ( std::string_view realm,
std::string_view device_id,
std::string_view astarte_base_url ) -> astarte_tl::expected< PairingApi, Error >
static

Creates an instance of the PairingApi class.

Parameters
[in]realmThe Astarte realm name.
[in]device_idThe Astarte device id.
[in]astarte_base_urlstring containing the Astarte pairing API URL.
Returns
An expected containing the class instance on success or Error on failure.

◆ device_cert_valid()

auto astarte::device::mqtt::PairingApi::device_cert_valid ( std::string_view certificate,
std::string_view credential_secret,
int timeout_ms = 0 ) const -> astarte_tl::expected< bool, Error >
nodiscard

Checks if the Astarte device certificate is valid.

Parameters
[in]certificateThe Astarte device certificate.
[in]credential_secretThe Astarte device credential necessary to authenticate to the broker.
[in]timeout_msA timeout value to perform the HTTP request.
Returns
An expected containing the certificate validity on success or Error on failure.

◆ get_broker_url()

auto astarte::device::mqtt::PairingApi::get_broker_url ( std::string_view credential_secret,
int timeout_ms = 0 ) const -> astarte_tl::expected< std::string, Error >
nodiscard

Retrieves the URL of the Astarte MQTT broker.

Parameters
[in]credential_secretThe Astarte device credential necessary to authenticate to the broker.
[in]timeout_msA timeout value to perform the HTTP request.
Returns
An expected containing the broker URL on success or Error on failure.

◆ get_device_key_and_certificate()

auto astarte::device::mqtt::PairingApi::get_device_key_and_certificate ( std::string_view credential_secret,
int timeout_ms = 0 ) const -> astarte_tl::expected< std::tuple< std::string, std::string >, Error >
nodiscard

Retrieves the Astarte device certificate and relative private key.

Parameters
[in]credential_secretThe Astarte device credential necessary to authenticate to the broker.
[in]timeout_msA timeout value to perform the HTTP request.
Returns
An expected containing the tuple of key and certificate on success or Error on failure.

◆ register_device()

auto astarte::device::mqtt::PairingApi::register_device ( std::string_view pairing_token,
std::chrono::milliseconds timeout_ms = 0ms ) const -> astarte_tl::expected< std::string, Error >
nodiscard

Registers a device.

Parameters
[in]pairing_tokenThe Astarte pairing token.
[in]timeout_msA timeout value to perform the HTTP request.
Returns
An expected containing the credentials secret on success or Error on failure.

The documentation for this class was generated from the following file: