cesium-native  0.41.0
CesiumIonClient::Connection Class Reference

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::AsyncSystemgetAsyncSystem () 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 > &currentPage) const
 Gets the next page of results from the "List tokens" service. More...
 
CesiumAsync::Future< Response< TokenList > > previousPage (const Response< TokenList > &currentPage) 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< Connectionauthorize (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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Connection()

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.

Parameters
asyncSystemThe async system used to do work in threads.
pAssetAccessorThe interface used to interact with the Cesium ion REST API.
accessTokenThe access token
appDataThe app data retrieved from the Cesium ion server.
apiUrlThe base URL of the Cesium ion API.

Member Function Documentation

◆ appData()

static CesiumAsync::Future<Response<ApplicationData> > CesiumIonClient::Connection::appData ( const CesiumAsync::AsyncSystem asyncSystem,
const std::shared_ptr< CesiumAsync::IAssetAccessor > &  pAssetAccessor,
const std::string &  apiUrl = "https://api.cesium.com" 
)
static

Retrieves information about the ion API server.

Returns
A future that resolves to the application information.

◆ asset()

CesiumAsync::Future<Response<Asset> > CesiumIonClient::Connection::asset ( int64_t  assetID) const

Gets details of the asset with the given ID.

Parameters
assetIDThe asset ID.
Returns
A future that resolves to the asset details.

◆ assets()

CesiumAsync::Future<Response<Assets> > CesiumIonClient::Connection::assets ( ) const

Gets the list of available assets.

Returns
A future that resolves to the asset information.

◆ authorize()

static CesiumAsync::Future<Connection> CesiumIonClient::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" 
)
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.

Parameters
asyncSystemThe async system used to do work in threads.
pAssetAccessorThe interface used to interact with the Cesium ion REST API.
friendlyApplicationNameA 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.
clientIDThe client ID that was assigned to your application when you registered it.
redirectPathThe 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.
scopesThe list of scopes that the eventually-granted token should allow access to.
openUrlCallbackA function that is invoked to launch the user's web browser with a given URL so that they can authorize access.
appDataThe app data retrieved from the Cesium ion server.
ionApiUrlThe base URL of the Cesium ion API.
ionAuthorizeUrlThe URL of the Cesium ion OAuth authorization page.
Returns
A future that resolves to a Cesium ion Connection once the user authorizes the application and the token handshake completes.

◆ createToken()

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.

Parameters
nameThe name of the new token.
scopesThe scopes allowed by this token.
assetIdsThe assets that may be accessed by this token. If std::nullopt, access to all assets is allowed.
allowedUrlsThe URLs from which this token can be accessed. If std::nullopt, the token can be accessed from any URL.
Returns
The new token.

◆ defaults()

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.

Returns
A future that resolves to the default information.

◆ getIdFromToken()

static std::optional<std::string> CesiumIonClient::Connection::getIdFromToken ( const std::string &  token)
static

Decodes a token ID from a token.

Parameters
tokenThe token to decode.
Returns
The token ID, or std::nullopt if the token ID cannot be determined from the token.

◆ me()

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.

Returns
A future that resolves to the profile information.

◆ modifyToken()

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.

Parameters
tokenIDThe ID of the token to modify.
newNameThe new name of the token.
newAssetIDsThe assets that may be accessed by this token. If std::nullopt, access to all assets is allowed.
newScopesThe new OAuth scopes allowed by this token.
newAllowedUrlsThe new URLs from which this token can be accessed. If std::nullopt, the token can be accessed from any URL.
Returns
A value-less response. If the response is successful, the token has been modified.

◆ nextPage()

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.

Parameters
currentPageThe current page from which to get the next page.
Returns
A future that resolves to the next page of tokens, or to a response with an Response::errorCode of "NoMorePages" if the currentPage is the last one.

◆ previousPage()

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.

Parameters
currentPageThe current page from which to get the previous page.
Returns
A future that resolves to the previous page of tokens, or to a response with an Response::errorCode of "NoMorePages" if the currentPage is the first one.

◆ token()

CesiumAsync::Future<Response<Token> > CesiumIonClient::Connection::token ( const std::string &  tokenID) const

Gets details of the token with the given ID.

Parameters
tokenIDThe token ID.
Returns
A future that resolves to the token details.

◆ tokens()

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.

Parameters
optionsOptions to include in the "List tokens" request.
Returns
A future that resolves to a page of token information.

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