cognite_cdf_sdk library
The cognite_cdf_sdk is a read-only SDK to interact with Cognite CDF.
The API is documented at https://docs.cognite.com/api/v1/ The current version is primarily targeted towards read-only data exploration type of Flutter apps.
NOTE!!! You need to supply an HttpClientAdapter()
implementation as either found
in dio/adapter.dart (DefaultHttpClientAdapter()
) or dio/adapter_browser.dart
(BrowserHttpClientAdapter()
).
Instantiate a client to be used by the APIs, e.g. TimeSeriesAPI:
var apiClient = CDFApiClient(
project: 'project_name',
apikey: 'myapi_key',
baseUrl: 'https://api.cognitedata.com/',
httpAdapter: DefaultHttpClientAdapter())
As an alternative for testing, you can use CDFMockApiClient that allows you to use setMock() to specify the reponse.
To use the API, you inject the client and call the method, like this:
var res = await TimeSeriesAPI(apiClient).getAllTimeSeries();
After this, you will have as List<> of HistoryModel's available to you in
apiClient.history
to access the request and reponse history of the client.
The library uses the logger package to allow logging at different levels. Choose the log level with the logLevel parameter to CDFApiClient.
The library follows the following:
- Log errors on Level.error
- Log important warnings on Level.warning (default)
- Log request on Level.info
- Log response on Level.debug
- Log extra headers on Level.verbose
The CDFApiClient has a history (List
Classes
- CDFApiClient
- Main API client class to set up and hold a CDF API connection.
- CDFMockApiClient
- Use the CDFMockApiClient as a replacement for CDFApiClient to mock http responses.
- DatapointModel
- Each datapoint or aggregate is represented by DatapointModel
- DatapointsFilterModel
- Used to create filter for TimeSeriesAPI.getDatapoints.
- DatapointsModel
- Represents the datapoints of a timeseries.
- HistoryModel
- Keeps each request/response as part of client .history.
- MockHttpClientAdapter
- StatusModel
- Returned data from CDFApiClient.getStatus.
- TimeSeriesAPI
- This API covers the timeseries API.
- TimeSeriesModel
- Model holding returned timeseries.
Exceptions / Errors
- CDFApiClientDatapointFilterException
- The filter is not valid for timeseries datapoints retrieval.
- CDFApiClientHttpAdapterException
- An instance of an HttpClientAdapter is required.
- CDFApiClientParameterException
- Parameter combination is not accepted by the API.