Provides key-value storage for apps so that app developers can persist and get small chunks of state in the context of their app.
States can either be stored in the context of an app (= app states) or in the context of an app and user (= user app states).
- States stored per app can be read by every user of the app.
- States stored per app and user can only be read and updated by the user who originally set that state. Please visit the Dynatrace Developer to learn more about app states and user app states.
npm install @dynatrace-sdk/client-state
- Visit SDK for Typescript guide in the Dynatrace Developer
- Ask a question in the Dynatrace Community
This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.
Full API reference for the latest version of the SDK is also available at the Dynatrace Developer.
import { stateClient } from '@dynatrace-sdk/client-state';
Deletes app state
Required scope: state:app-states:delete
Name | Type | Description |
---|---|---|
config.key*required | string | Specify the key of the state |
Error Type | Error Message |
---|---|
Unauthorized | Unauthorized |
Forbidden | Forbidden |
NotFound | Not found |
InternalServerError | Internal server error |
Code example
import { stateClient } from "@dynatrace-sdk/client-state";
const data = await stateClient.deleteAppState({
key: "some-key",
});
Delete all app states
Required scope: state:app-states:delete
Deletes all app states for an app to reset the app into a clean state.
Code example
import { stateClient } from "@dynatrace-sdk/client-state";
const data = await stateClient.deleteAppStates();
Delete user app state
Required scope: state:user-app-states:delete
Name | Type | Description |
---|---|---|
config.key*required | string | Specify the key of the state |
Error Type | Error Message |
---|---|
Unauthorized | Unauthorized |
Forbidden | Forbidden |
NotFound | Not found |
InternalServerError | Internal server error |
Code example
import { stateClient } from "@dynatrace-sdk/client-state";
const data = await stateClient.deleteUserAppState({
key: "some-key",
});
Delete all user app states
Required scope: state:user-app-states:delete
Deletes all user app states for the calling user and app.
Code example
import { stateClient } from "@dynatrace-sdk/client-state";
const data = await stateClient.deleteUserAppStates();
Gets app state
Required scope: state:app-states:read
Name | Type | Description |
---|---|---|
config.key*required | string | Specify the key of the state |
The app state
Error Type | Error Message |
---|---|
Unauthorized | Unauthorized |
Forbidden | Forbidden |
NotFound | Not found |
InternalServerError | Internal server error |
Code example
import { stateClient } from "@dynatrace-sdk/client-state";
const data = await stateClient.getAppState({
key: "some-key",
});
List app states
Required scope: state:app-states:read
Lists app states. By default, only provides property key per state. Use add-fields parameter to include more fields and the filter parameter to narrow down the returned states.
Name | Type | Description |
---|---|---|
config.addFields | string | Provide a comma separated list of additional properties to be included in the response. |
config.filter | string |
The filter parameter for filtering the set of returned resources If this parameter is omitted, no filtering is applied and all states will be returned. Filtering by string type parameters When using the operators The following fields are legal filtering parameters - any other field names will result in a HTTP 400 response:
The following constraints apply:
Examples:
|
The list of app states
Error Type | Error Message |
---|---|
Unauthorized | Unauthorized |
Forbidden | Forbidden |
InternalServerError | Internal server error |
Code example
import { stateClient } from "@dynatrace-sdk/client-state";
const data = await stateClient.getAppStates();
Get user app state
Required scope: state:user-app-states:read
Name | Type | Description |
---|---|---|
config.key*required | string | Specify the key of the state |
The user app state
Error Type | Error Message |
---|---|
Unauthorized | Unauthorized |
Forbidden | Forbidden |
NotFound | Not found |
InternalServerError | Internal server error |
Code example
import { stateClient } from "@dynatrace-sdk/client-state";
const data = await stateClient.getUserAppState({
key: "some-key",
});
List user app states
Required scope: state:user-app-states:read
Lists user app states. By default, only provides property key per state. Use add-fields parameter to include more fields and the filter parameter to narrow down the returned states
Name | Type | Description |
---|---|---|
config.addFields | string | Provide a comma separated list of additional properties to be included in the response. |
config.filter | string |
The filter parameter for filtering the set of returned resources If this parameter is omitted, no filtering is applied and all states will be returned. Filtering by string type parameters When using the operators The following fields are legal filtering parameters - any other field names will result in a HTTP 400 response:
The following constraints apply:
Examples:
|
The list of user app states
Error Type | Error Message |
---|---|
Unauthorized | Unauthorized |
Forbidden | Forbidden |
InternalServerError | Internal server error |
Code example
import { stateClient } from "@dynatrace-sdk/client-state";
const data = await stateClient.getUserAppStates();
Updates app state
Required scope: state:app-states:write
Updates the cross-user app state for the given key. Be aware that other users will be able to read the value. Use the user-scoped user-app-state to only store values for the authenticated user.
Certain limits apply when updating app states.
Name | Type | Description |
---|---|---|
config.body*required | AppState | |
config.key*required | string | Specify the key of the state |
Error Type | Error Message |
---|---|
AppStateLimitsExceeded | Exceeded size limit for combined size of app states of this app |
Unauthorized | Unauthorized |
Forbidden | Forbidden |
InternalServerError | Internal server error |
Code example
import { stateClient } from "@dynatrace-sdk/client-state";
const data = await stateClient.setAppState({
key: "some-key",
body: { value: "some-state", validUntilTime: "now+2d" },
});
Updates user app state
Required scope: state:user-app-states:write
Updates the user specific app state for the given key and calling user.
Certain limits apply when updating user app states.
Name | Type | Description |
---|---|---|
config.body*required | UserAppState | |
config.key*required | string | Specify the key of the state |
Error Type | Error Message |
---|---|
UserAppStateLimitsExceeded | Exceeded limit for number of user app states to be stored for this user and app |
Unauthorized | Unauthorized |
Forbidden | Forbidden |
InternalServerError | Internal server error |
Code example
import { stateClient } from "@dynatrace-sdk/client-state";
const data = await stateClient.setUserAppState({
key: "some-key",
body: { value: "some-state", validUntilTime: "now+2d" },
});
Base error for all client SDKs. All other errors extend this class.
Name | Type | Description |
---|---|---|
cause | any | |
errorType*required | ErrorType | |
isApiClientError*required | true | |
message*required | string | |
name*required | string | |
stack | string | |
prepareStackTrace | Object | Optional override for formatting stack traces |
stackTraceLimit*required | number |
Dedicated error response class for errors thrown by API Gateway. Autogenerated SDK Clients have built-in handler for API Gateway errors that throws this error.
Name | Type | Description |
---|---|---|
body*required | ApiGatewayErrorResponseBody | |
cause | any | |
code*required | number | |
errorType*required | ErrorType | |
isApiClientError*required | true | |
isApiGatewayError*required | true | |
isClientRequestError*required | true | |
message*required | string | |
name*required | string | |
response*required | HttpClientResponse | |
retryAfterSeconds*required | undefined | number | |
stack | string | |
prepareStackTrace | Object | Optional override for formatting stack traces |
stackTraceLimit*required | number |
Name | Type | Description |
---|---|---|
|
ErrorResponse | |
|
any | |
|
ErrorType | |
|
true | |
|
true | |
|
true | |
|
true | |
|
string | |
|
"AppStateLimitsExceeded" | |
|
HttpClientResponse | |
|
string | |
|
Object | Optional override for formatting stack traces |
|
number |
Generic error class for service errors, used to handle both expected and unexpected service-level errors.
Name | Type | Description |
---|---|---|
body*required | DTO | |
cause | any | |
errorType*required | ErrorType | |
isApiClientError*required | true | |
isClientRequestError*required | true | |
message*required | string | |
name*required | string | |
response*required | HttpClientResponse | |
stack | string | |
prepareStackTrace | Object | Optional override for formatting stack traces |
stackTraceLimit*required | number |
Name | Type | Description |
---|---|---|
|
ErrorResponse | |
|
any | |
|
ErrorType | |
|
true | |
|
true | |
|
true | |
|
string | |
|
string | |
|
HttpClientResponse | |
|
string | |
|
Object | Optional override for formatting stack traces |
|
number |
Name | Type | Description |
---|---|---|
|
ErrorResponse | |
|
any | |
|
ErrorType | |
|
true | |
|
true | |
|
true | |
|
true | |
|
string | |
|
"Forbidden" | |
|
HttpClientResponse | |
|
string | |
|
Object | Optional override for formatting stack traces |
|
number |
Name | Type | Description |
---|---|---|
|
ErrorResponse | |
|
any | |
|
ErrorType | |
|
true | |
|
true | |
|
true | |
|
true | |
|
string | |
|
"InternalServerError" | |
|
HttpClientResponse | |
|
string | |
|
Object | Optional override for formatting stack traces |
|
number |
Dedicated error class for errors related to response serialization. Thrown when received service response can't be deserialized.
Name | Type | Description |
---|---|---|
cause | any | |
errorType*required | ErrorType | |
expectedType | string | |
isApiClientError*required | true | |
isInvalidResponseError*required | true | |
message*required | string | |
name*required | string | |
nestedError | Error | |
response*required | any | |
responseBody*required | any | |
stack | string | |
prepareStackTrace | Object | Optional override for formatting stack traces |
stackTraceLimit*required | number |
Name | Type | Description |
---|---|---|
|
ErrorResponse | |
|
any | |
|
ErrorType | |
|
true | |
|
true | |
|
true | |
|
true | |
|
string | |
|
"NotFound" | |
|
HttpClientResponse | |
|
string | |
|
Object | Optional override for formatting stack traces |
|
number |
Name | Type | Description |
---|---|---|
|
ErrorResponse | |
|
any | |
|
ErrorType | |
|
true | |
|
true | |
|
true | |
|
true | |
|
string | |
|
"Unauthorized" | |
|
HttpClientResponse | |
|
string | |
|
Object | Optional override for formatting stack traces |
|
number |
Name | Type | Description |
---|---|---|
|
ErrorResponse | |
|
any | |
|
ErrorType | |
|
true | |
|
true | |
|
true | |
|
true | |
|
string | |
|
"UserAppStateLimitsExceeded" | |
|
HttpClientResponse | |
|
string | |
|
Object | Optional override for formatting stack traces |
|
number |
Name | Type | Description |
---|---|---|
modificationInfo | ModificationInfo | |
validUntilTime | null | string | Specify the date until the state is persisted. Allowed are values from now+1m to now+90d! Returned validUntilTimes are always a string formatted in ISO 8601 |
value*required | string |
extends Array<ListAppState>
Name | Type | Description |
---|---|---|
[unscopables]*required | Object | Is an object whose properties have the value 'true' when they will be absent when used in a 'with' statement. |
length*required | number | Gets or sets the length of the array. This is a number one higher than the highest index in the array. |
Name | Type |
---|---|
code*required | number |
details | ErrorDetails |
message*required | string |
Name | Type | Description |
---|---|---|
errorCode | ErrorDetailsErrorCode |
Error code indicating the reason why the request failed
|
Name | Type |
---|---|
error*required | Error |
Name | Type | Description |
---|---|---|
key*required | string | |
modificationInfo | ModificationInfo | |
validUntilTime | null | string | Specify the date until the state is persisted. Allowed are values from now+1m to now+90d! Returned validUntilTimes are always a string formatted in ISO 8601 |
value | string |
Name | Type | Description |
---|---|---|
key*required | string | |
modificationInfo | ModificationInfo | |
validUntilTime | null | string | Specify the date until the state is persisted. Allowed are values from now+1m to now+90d! Returned validUntilTimes are always a string formatted in ISO 8601 |
value | string |
Name | Type |
---|---|
lastModifiedBy*required | string |
lastModifiedTime*required | Date |
Name | Type | Description |
---|---|---|
modificationInfo | ModificationInfo | |
validUntilTime | null | string | Specify the date until the state is persisted. Allowed are values from now+1m to now+90d! Returned validUntilTimes are always a string formatted in ISO 8601 |
value | string |
Name | Type | Description |
---|---|---|
modificationInfo | ModificationInfo | |
validUntilTime | null | string | Specify the date until the state is persisted. Allowed are values from now+1m to now+90d! Returned validUntilTimes are always a string formatted in ISO 8601 |
value*required | string |
extends Array<ListUserAppState>
Name | Type | Description |
---|---|---|
[unscopables]*required | Object | Is an object whose properties have the value 'true' when they will be absent when used in a 'with' statement. |
length*required | number | Gets or sets the length of the array. This is a number one higher than the highest index in the array. |
Error code indicating the reason why the request failed
-
AppStateOverallSizeLimitExceeded
- The overall size limit for the combined size of app states of this app was exceeded -
UserAppStateSizeLimitExceeded
- The user app state content exceeded the size limit for a single user app state -
UserAppStateCountLimitExceeded
- The maximum number of user app states for this user and app was exceeded
AppStateOverallSizeLimitExceeded
| UserAppStateCountLimitExceeded
| UserAppStateSizeLimitExceeded