cesium-native
0.41.0
|
A connection to Cesium ion that can be used to interact with it via its REST API. More...
#include <CesiumIonClient/Connection.h>
Public Member Functions | |
Connection (const CesiumAsync::AsyncSystem &asyncSystem, const std::shared_ptr< CesiumAsync::IAssetAccessor > &pAssetAccessor, const std::string &accessToken, const CesiumIonClient::ApplicationData &appData, const std::string &apiUrl="https://api.cesium.com") | |
Creates a connection to Cesium ion using the provided access token. More... | |
const CesiumAsync::AsyncSystem & | getAsyncSystem () const noexcept |
Gets the async system used by this connection to do work in threads. | |
const std::shared_ptr< CesiumAsync::IAssetAccessor > & | getAssetAccessor () const noexcept |
Gets the interface used by this connection to interact with the Cesium ion REST API. | |
const std::string & | getAccessToken () const noexcept |
Gets the access token used by this connection. | |
const std::string & | getApiUrl () const noexcept |
Gets the Cesium ion API base URL. | |
CesiumAsync::Future< Response< Profile > > | me () const |
Retrieves profile information for the access token currently being used to make API calls. More... | |
CesiumAsync::Future< Response< Defaults > > | defaults () const |
Retrieves default imagery, terrain and building assets along with quick add assets that can be useful to use within other applications. More... | |
CesiumAsync::Future< Response< Assets > > | assets () const |
Gets the list of available assets. More... | |
CesiumAsync::Future< Response< TokenList > > | tokens (const ListTokensOptions &options={}) const |
Invokes the "List tokens" service to get the list of available tokens. More... | |
CesiumAsync::Future< Response< Asset > > | asset (int64_t assetID) const |
Gets details of the asset with the given ID. More... | |
CesiumAsync::Future< Response< Token > > | token (const std::string &tokenID) const |
Gets details of the token with the given ID. More... | |
CesiumAsync::Future< Response< TokenList > > | nextPage (const Response< TokenList > ¤tPage) const |
Gets the next page of results from the "List tokens" service. More... | |
CesiumAsync::Future< Response< TokenList > > | previousPage (const Response< TokenList > ¤tPage) const |
Gets the previous page of results from the "List tokens" service. More... | |
CesiumAsync::Future< Response< Token > > | createToken (const std::string &name, const std::vector< std::string > &scopes, const std::optional< std::vector< int64_t >> &assetIds=std::nullopt, const std::optional< std::vector< std::string >> &allowedUrls=std::nullopt) const |
Creates a new token. More... | |
CesiumAsync::Future< Response< NoValue > > | modifyToken (const std::string &tokenID, const std::string &newName, const std::optional< std::vector< int64_t >> &newAssetIDs, const std::vector< std::string > &newScopes, const std::optional< std::vector< std::string >> &newAllowedUrls) const |
Modifies a token. More... | |
Static Public Member Functions | |
static CesiumAsync::Future< Connection > | authorize (const CesiumAsync::AsyncSystem &asyncSystem, const std::shared_ptr< CesiumAsync::IAssetAccessor > &pAssetAccessor, const std::string &friendlyApplicationName, int64_t clientID, const std::string &redirectPath, const std::vector< std::string > &scopes, std::function< void(const std::string &)> &&openUrlCallback, const CesiumIonClient::ApplicationData &appData, const std::string &ionApiUrl="https://api.cesium.com/", const std::string &ionAuthorizeUrl="https://ion.cesium.com/oauth") |
Authorizes access to Cesium ion on behalf of a user, and returns a Connection that can be used to interact with ion. More... | |
static CesiumAsync::Future< Response< ApplicationData > > | appData (const CesiumAsync::AsyncSystem &asyncSystem, const std::shared_ptr< CesiumAsync::IAssetAccessor > &pAssetAccessor, const std::string &apiUrl="https://api.cesium.com") |
Retrieves information about the ion API server. More... | |
static CesiumAsync::Future< std::optional< std::string > > | getApiUrl (const CesiumAsync::AsyncSystem &asyncSystem, const std::shared_ptr< CesiumAsync::IAssetAccessor > &pAssetAccessor, const std::string &ionUrl) |
static std::optional< std::string > | getIdFromToken (const std::string &token) |
Decodes a token ID from a token. More... | |
A connection to Cesium ion that can be used to interact with it via its REST API.
Definition at line 66 of file Connection.h.
CesiumIonClient::Connection::Connection | ( | const CesiumAsync::AsyncSystem & | asyncSystem, |
const std::shared_ptr< CesiumAsync::IAssetAccessor > & | pAssetAccessor, | ||
const std::string & | accessToken, | ||
const CesiumIonClient::ApplicationData & | appData, | ||
const std::string & | apiUrl = "https://api.cesium.com" |
||
) |
Creates a connection to Cesium ion using the provided access token.
asyncSystem | The async system used to do work in threads. |
pAssetAccessor | The interface used to interact with the Cesium ion REST API. |
accessToken | The access token |
appData | The app data retrieved from the Cesium ion server. |
apiUrl | The base URL of the Cesium ion API. |
|
static |
Retrieves information about the ion API server.
CesiumAsync::Future<Response<Asset> > CesiumIonClient::Connection::asset | ( | int64_t | assetID | ) | const |
Gets details of the asset with the given ID.
assetID | The asset ID. |
CesiumAsync::Future<Response<Assets> > CesiumIonClient::Connection::assets | ( | ) | const |
Gets the list of available assets.
|
static |
Authorizes access to Cesium ion on behalf of a user, and returns a Connection that can be used to interact with ion.
Uses the "Authorization Code with PKCE" OAuth2 flow.
See Connecting to Cesium ion with OAuth2 for a description of the authorization process.
asyncSystem | The async system used to do work in threads. |
pAssetAccessor | The interface used to interact with the Cesium ion REST API. |
friendlyApplicationName | A friendly name for the application requesting access. It will be displayed to the user when authorization is complete, informing them that they can return to the original application. |
clientID | The client ID that was assigned to your application when you registered it. |
redirectPath | The path on http://127.0.0.1 that a user will be redirected to once they authorize your application. This must match the URI provided when you registered your application, without the protocol, hostname, or port. |
scopes | The list of scopes that the eventually-granted token should allow access to. |
openUrlCallback | A function that is invoked to launch the user's web browser with a given URL so that they can authorize access. |
appData | The app data retrieved from the Cesium ion server. |
ionApiUrl | The base URL of the Cesium ion API. |
ionAuthorizeUrl | The URL of the Cesium ion OAuth authorization page. |
CesiumAsync::Future<Response<Token> > CesiumIonClient::Connection::createToken | ( | const std::string & | name, |
const std::vector< std::string > & | scopes, | ||
const std::optional< std::vector< int64_t >> & | assetIds = std::nullopt , |
||
const std::optional< std::vector< std::string >> & | allowedUrls = std::nullopt |
||
) | const |
Creates a new token.
name | The name of the new token. |
scopes | The scopes allowed by this token. |
assetIds | The assets that may be accessed by this token. If std::nullopt , access to all assets is allowed. |
allowedUrls | The URLs from which this token can be accessed. If std::nullopt , the token can be accessed from any URL. |
CesiumAsync::Future<Response<Defaults> > CesiumIonClient::Connection::defaults | ( | ) | const |
Retrieves default imagery, terrain and building assets along with quick add assets that can be useful to use within other applications.
This route will always return data, but will return user specific information with any valid token.
|
static |
Decodes a token ID from a token.
token | The token to decode. |
CesiumAsync::Future<Response<Profile> > CesiumIonClient::Connection::me | ( | ) | const |
Retrieves profile information for the access token currently being used to make API calls.
This route works with any valid token, but additional information is returned if the token uses the profile:read
scope.
CesiumAsync::Future<Response<NoValue> > CesiumIonClient::Connection::modifyToken | ( | const std::string & | tokenID, |
const std::string & | newName, | ||
const std::optional< std::vector< int64_t >> & | newAssetIDs, | ||
const std::vector< std::string > & | newScopes, | ||
const std::optional< std::vector< std::string >> & | newAllowedUrls | ||
) | const |
Modifies a token.
tokenID | The ID of the token to modify. |
newName | The new name of the token. |
newAssetIDs | The assets that may be accessed by this token. If std::nullopt , access to all assets is allowed. |
newScopes | The new OAuth scopes allowed by this token. |
newAllowedUrls | The new URLs from which this token can be accessed. If std::nullopt , the token can be accessed from any URL. |
CesiumAsync::Future<Response<TokenList> > CesiumIonClient::Connection::nextPage | ( | const Response< TokenList > & | currentPage | ) | const |
Gets the next page of results from the "List tokens" service.
To get the first page, use Connection::tokens.
currentPage | The current page from which to get the next page. |
CesiumAsync::Future<Response<TokenList> > CesiumIonClient::Connection::previousPage | ( | const Response< TokenList > & | currentPage | ) | const |
Gets the previous page of results from the "List tokens" service.
To get the first page (or a particular page), use Connection::tokens.
currentPage | The current page from which to get the previous page. |
CesiumAsync::Future<Response<Token> > CesiumIonClient::Connection::token | ( | const std::string & | tokenID | ) | const |
Gets details of the token with the given ID.
tokenID | The token ID. |
CesiumAsync::Future<Response<TokenList> > CesiumIonClient::Connection::tokens | ( | const ListTokensOptions & | options = {} | ) | const |
Invokes the "List tokens" service to get the list of available tokens.
Only a single page is returned. To obtain additional pages, use Connection::nextPage and Connection::previousPage.
options | Options to include in the "List tokens" request. |