Skip to content

Commit

Permalink
feat(client-sagemaker-featurestore-runtime): Introducing TTL for onli…
Browse files Browse the repository at this point in the history
…ne store records for feature groups.
  • Loading branch information
awstools committed Jun 27, 2023
1 parent e6fbf50 commit 60c5c6a
Show file tree
Hide file tree
Showing 7 changed files with 265 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface BatchGetRecordCommandOutput extends BatchGetRecordResponse, __M
* ],
* },
* ],
* ExpirationTimeResponse: "Enabled" || "Disabled",
* };
* const command = new BatchGetRecordCommand(input);
* const response = await client.send(command);
Expand All @@ -73,6 +74,7 @@ export interface BatchGetRecordCommandOutput extends BatchGetRecordResponse, __M
* // ValueAsString: "STRING_VALUE", // required
* // },
* // ],
* // ExpiresAt: "STRING_VALUE",
* // },
* // ],
* // Errors: [ // BatchGetRecordErrors // required
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ export interface DeleteRecordCommandOutput extends __MetadataBearer {}
/**
* @public
* <p>Deletes a <code>Record</code> from a <code>FeatureGroup</code> in the
* <code>OnlineStore</code>. Feature Store supports both <code>SOFT_DELETE</code> and
* <code>HARD_DELETE</code>. For <code>SOFT_DELETE</code> (default), feature columns are
* <code>OnlineStore</code>. Feature Store supports both <code>SoftDelete</code> and
* <code>HardDelete</code>. For <code>SoftDelete</code> (default), feature columns are
* set to <code>null</code> and the record is no longer retrievable by <code>GetRecord</code>
* or <code>BatchGetRecord</code>. For<code> HARD_DELETE</code>, the complete
* or <code>BatchGetRecord</code>. For <code>HardDelete</code>, the complete
* <code>Record</code> is removed from the <code>OnlineStore</code>. In both cases, Feature
* Store appends the deleted record marker to the <code>OfflineStore</code> with feature
* values set to <code>null</code>, <code>is_deleted</code> value set to <code>True</code>,
Expand All @@ -55,13 +55,13 @@ export interface DeleteRecordCommandOutput extends __MetadataBearer {}
* deletion does not occur:</p>
* <ul>
* <li>
* <p>For <code>SOFT_DELETE</code>, the existing (undeleted) record remains in the
* <p>For <code>SoftDelete</code>, the existing (undeleted) record remains in the
* <code>OnlineStore</code>, though the delete record marker is still written to the
* <code>OfflineStore</code>.</p>
* </li>
* <li>
* <p>
* <code>HARD_DELETE</code> returns <code>EventTime</code>: <code>400
* <code>HardDelete</code> returns <code>EventTime</code>: <code>400
* ValidationException</code> to indicate that the delete operation failed. No delete
* record marker is written to the <code>OfflineStore</code>.</p>
* </li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export interface GetRecordCommandOutput extends GetRecordResponse, __MetadataBea
* FeatureNames: [ // FeatureNames
* "STRING_VALUE",
* ],
* ExpirationTimeResponse: "Enabled" || "Disabled",
* };
* const command = new GetRecordCommand(input);
* const response = await client.send(command);
Expand All @@ -65,6 +66,7 @@ export interface GetRecordCommandOutput extends GetRecordResponse, __MetadataBea
* // ValueAsString: "STRING_VALUE", // required
* // },
* // ],
* // ExpiresAt: "STRING_VALUE",
* // };
*
* ```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ export interface PutRecordCommandOutput extends __MetadataBearer {}
* TargetStores: [ // TargetStores
* "OnlineStore" || "OfflineStore",
* ],
* TtlDuration: { // TtlDuration
* Unit: "Seconds" || "Minutes" || "Hours" || "Days" || "Weeks", // required
* Value: Number("int"), // required
* },
* };
* const command = new PutRecordCommand(input);
* const response = await client.send(command);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ export class AccessForbidden extends __BaseException {
}
}

/**
* @public
* @enum
*/
export const ExpirationTimeResponse = {
DISABLED: "Disabled",
ENABLED: "Enabled",
} as const;

/**
* @public
*/
export type ExpirationTimeResponse = (typeof ExpirationTimeResponse)[keyof typeof ExpirationTimeResponse];

/**
* @public
* <p>The identifier that identifies the batch of Records you are retrieving in a
Expand Down Expand Up @@ -58,6 +72,14 @@ export interface BatchGetRecordRequest {
* retrieved in batch.</p>
*/
Identifiers: BatchGetRecordIdentifier[] | undefined;

/**
* <p>Parameter to request <code>ExpiresAt</code> in response. If <code>Enabled</code>,
* <code>BatchGetRecord</code> will return the value of <code>ExpiresAt</code>, if it is
* not null. If <code>Disabled</code> and null, <code>BatchGetRecord</code> will return
* null.</p>
*/
ExpirationTimeResponse?: ExpirationTimeResponse | string;
}

/**
Expand Down Expand Up @@ -126,6 +148,11 @@ export interface BatchGetRecordResultDetail {
* <p>The <code>Record</code> retrieved.</p>
*/
Record: FeatureValue[] | undefined;

/**
* <p>The <code>ExpiresAt</code> ISO string of the requested record.</p>
*/
ExpiresAt?: string;
}

/**
Expand Down Expand Up @@ -299,6 +326,14 @@ export interface GetRecordRequest {
* the Features are returned.</p>
*/
FeatureNames?: string[];

/**
* <p>Parameter to request <code>ExpiresAt</code> in response. If <code>Enabled</code>,
* <code>BatchGetRecord</code> will return the value of <code>ExpiresAt</code>, if it is
* not null. If <code>Disabled</code> and null, <code>BatchGetRecord</code> will return
* null.</p>
*/
ExpirationTimeResponse?: ExpirationTimeResponse | string;
}

/**
Expand All @@ -309,6 +344,11 @@ export interface GetRecordResponse {
* <p>The record you requested. A list of <code>FeatureValues</code>.</p>
*/
Record?: FeatureValue[];

/**
* <p>The <code>ExpiresAt</code> ISO string of the requested record.</p>
*/
ExpiresAt?: string;
}

/**
Expand All @@ -333,6 +373,43 @@ export class ResourceNotFound extends __BaseException {
}
}

/**
* @public
* @enum
*/
export const TtlDurationUnit = {
DAYS: "Days",
HOURS: "Hours",
MINUTES: "Minutes",
SECONDS: "Seconds",
WEEKS: "Weeks",
} as const;

/**
* @public
*/
export type TtlDurationUnit = (typeof TtlDurationUnit)[keyof typeof TtlDurationUnit];

/**
* @public
* <p>Time to live duration, where the record is hard deleted after the expiration time is
* reached; <code>ExpiresAt</code> = <code>EventTime</code> + <code>TtlDuration</code>. For
* information on HardDelete, see the <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_feature_store_DeleteRecord.html">DeleteRecord</a> API in the Amazon SageMaker API Reference guide.</p>
*/
export interface TtlDuration {
/**
* <p>
* <code>TtlDuration</code> time unit.</p>
*/
Unit: TtlDurationUnit | string | undefined;

/**
* <p>
* <code>TtlDuration</code> time value.</p>
*/
Value: number | undefined;
}

/**
* @public
*/
Expand Down Expand Up @@ -364,4 +441,11 @@ export interface PutRecordRequest {
* record to all of the stores that you're using for the <code>FeatureGroup</code>.</p>
*/
TargetStores?: (TargetStore | string)[];

/**
* <p>Time to live duration, where the record is hard deleted after the expiration time is
* reached; <code>ExpiresAt</code> = <code>EventTime</code> + <code>TtlDuration</code>. For
* information on HardDelete, see the <a href="https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_feature_store_DeleteRecord.html">DeleteRecord</a> API in the Amazon SageMaker API Reference guide.</p>
*/
TtlDuration?: TtlDuration;
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
ResourceNotFound,
ServiceUnavailable,
TargetStore,
TtlDuration,
ValidationError,
} from "../models/models_0";
import { SageMakerFeatureStoreRuntimeServiceException as __BaseException } from "../models/SageMakerFeatureStoreRuntimeServiceException";
Expand All @@ -47,6 +48,7 @@ export const se_BatchGetRecordCommand = async (
let body: any;
body = JSON.stringify(
take(input, {
ExpirationTimeResponse: [],
Identifiers: (_) => _json(_),
})
);
Expand Down Expand Up @@ -133,6 +135,7 @@ export const se_GetRecordCommand = async (
() => input.FeatureNames !== void 0,
() => (input.FeatureNames! || []).map((_entry) => _entry as any),
],
ExpirationTimeResponse: [, input.ExpirationTimeResponse!],
});
let body: any;
return new __HttpRequest({
Expand Down Expand Up @@ -173,6 +176,7 @@ export const se_PutRecordCommand = async (
take(input, {
Record: (_) => _json(_),
TargetStores: (_) => _json(_),
TtlDuration: (_) => _json(_),
})
);
return new __HttpRequest({
Expand Down Expand Up @@ -311,6 +315,7 @@ export const de_GetRecordCommand = async (
});
const data: Record<string, any> = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
const doc = take(data, {
ExpiresAt: __expectString,
Record: _json,
});
Object.assign(contents, doc);
Expand Down Expand Up @@ -507,6 +512,8 @@ const de_ValidationErrorRes = async (parsedOutput: any, context: __SerdeContext)

// se_TargetStores omitted.

// se_TtlDuration omitted.

// de_BatchGetRecordError omitted.

// de_BatchGetRecordErrors omitted.
Expand Down
Loading

0 comments on commit 60c5c6a

Please sign in to comment.