Skip to content

Commit

Permalink
feat(rc): Add Remote Config Version Management API (#920)
Browse files Browse the repository at this point in the history
* Get remote config template by version number (#874)

* Get remote config template by version number

* Refactor unit tests for Remote Config (#884)

* Refactor unit tests

* Add Remote Config Rollback operation (#885)

* Add Remote Config Rollback operation

* Update docs and move etag validation to a helper function

* Update docs

* Introduce a util to create a template from API response

* PR fixes

* Remote Config Add list versions operation (#896)

* Remote Config: Add list versions operation

* Add version Impl and other PR fixes

* PR fixes

* Imrpoved unit tests and some code clean up

* Fix code formatting

* Add a separate function to get a Template with version (#902)

* Add version meta data to RC templates (#906)

* Add version meta data to RC templates

* PR fixes

* Use assertion to unwrap template.version

* Update Remote Config Docstrings in index.d.ts
  • Loading branch information
lahirumaramba committed Jun 25, 2020
1 parent 98b4788 commit eec3660
Show file tree
Hide file tree
Showing 5 changed files with 1,353 additions and 598 deletions.
160 changes: 159 additions & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,11 @@ declare namespace admin.remoteConfig {
* ETag of the current Remote Config template (readonly).
*/
readonly etag: string;

/**
* Version information for the current Remote Config template.
*/
version?: Version;
}

/**
Expand Down Expand Up @@ -984,6 +989,123 @@ declare namespace admin.remoteConfig {
*/
type RemoteConfigParameterValue = ExplicitParameterValue | InAppDefaultValue;

/**
* Interface representing a Remote Config template version.
* Output only, except for the version description. Contains metadata about a particular
* version of the Remote Config template. All fields are set at the time the specified Remote
* Config template is published. A version's description field may be specified in
* `publishTemplate` calls.
*/
export interface Version {
/**
* The version number of a Remote Config template.
*/
versionNumber?: string;

/**
* The timestamp of when this version of the Remote Config template was written to the
* Remote Config backend.
*/
updateTime?: string;

/**
* The origin of the template update action.
*/
updateOrigin?: ('REMOTE_CONFIG_UPDATE_ORIGIN_UNSPECIFIED' | 'CONSOLE' |
'REST_API' | 'ADMIN_SDK_NODE');

/**
* The type of the template update action.
*/
updateType?: ('REMOTE_CONFIG_UPDATE_TYPE_UNSPECIFIED' |
'INCREMENTAL_UPDATE' | 'FORCED_UPDATE' | 'ROLLBACK');

/**
* Aggregation of all metadata fields about the account that performed the update.
*/
updateUser?: RemoteConfigUser;

/**
* The user-provided description of the corresponding Remote Config template.
*/
description?: string;

/**
* The version number of the Remote Config template that has become the current version
* due to a rollback. Only present if this version is the result of a rollback.
*/
rollbackSource?: string;

/**
* Indicates whether this Remote Config template was published before version history was
* supported.
*/
isLegacy?: boolean;
}

/** Interface representing a list of Remote Config template versions. */
export interface ListVersionsResult {
/**
* A list of version metadata objects, sorted in reverse chronological order.
*/
versions: Version[];

/**
* Token to retrieve the next page of results, or empty if there are no more results
* in the list.
*/
nextPageToken?: string;
}

/** Interface representing options for Remote Config list versions operation. */
export interface ListVersionsOptions {
/**
* The maximum number of items to return per page.
*/
pageSize?: number;

/**
* The `nextPageToken` value returned from a previous list versions request, if any.
*/
pageToken?: string;

/**
* Specifies the newest version number to include in the results.
* If specified, must be greater than zero. Defaults to the newest version.
*/
endVersionNumber?: string | number;

/**
* Specifies the earliest update time to include in the results. Any entries updated before this
* time are omitted.
*/
startTime?: Date | string;

/**
* Specifies the latest update time to include in the results. Any entries updated on or after
* this time are omitted.
*/
endTime?: Date | string;
}

/** Interface representing a Remote Config user.*/
export interface RemoteConfigUser {
/**
* Email address. Output only.
*/
email: string;

/**
* Display name. Output only.
*/
name?: string;

/**
* Image URL. Output only.
*/
imageUrl?: string;
}

/**
* The Firebase `RemoteConfig` service interface.
*
Expand All @@ -1001,6 +1123,16 @@ declare namespace admin.remoteConfig {
*/
getTemplate(): Promise<RemoteConfigTemplate>;

/**
* Gets the requested version of the {@link admin.remoteConfig.RemoteConfigTemplate
* `RemoteConfigTemplate`} of the project.
*
* @param versionNumber Version number of the Remote Config template to look up.
*
* @return A promise that fulfills with a `RemoteConfigTemplate`.
*/
getTemplateAtVersion(versionNumber: number | string): Promise<RemoteConfigTemplate>;

/**
* Validates a {@link admin.remoteConfig.RemoteConfigTemplate `RemoteConfigTemplate`}.
*
Expand All @@ -1025,6 +1157,32 @@ declare namespace admin.remoteConfig {
*/
publishTemplate(template: RemoteConfigTemplate, options?: { force: boolean }): Promise<RemoteConfigTemplate>;

/**
* Rolls back a project's published Remote Config template to the specified version.
* A rollback is equivalent to getting a previously published Remote Config
* template and re-publishing it using a force update.
*
* @param versionNumber The version number of the Remote Config template to roll back to.
* The specified version number must be lower than the current version number, and not have
* been deleted due to staleness. Only the last 300 versions are stored.
* All versions that correspond to non-active Remote Config templates (that is, all except the
* template that is being fetched by clients) are also deleted if they are more than 90 days old.
* @return A promise that fulfills with the published `RemoteConfigTemplate`.
*/
rollback(versionNumber: string | number): Promise<RemoteConfigTemplate>;

/**
* Gets a list of Remote Config template versions that have been published, sorted in reverse
* chronological order. Only the last 300 versions are stored.
* All versions that correspond to non-active Remote Config templates (that is, all except the
* template that is being fetched by clients) are also deleted if they are more than 90 days old.
*
* @param options Optional {@link admin.remoteConfig.ListVersionsOptions `ListVersionsOptions`}
* object for getting a list of template versions.
* @return A promise that fulfills with a `ListVersionsResult`.
*/
listVersions(options?: ListVersionsOptions): Promise<ListVersionsResult>;

/**
* Creates and returns a new Remote Config template from a JSON string.
*
Expand Down Expand Up @@ -1110,7 +1268,7 @@ declare namespace admin.machineLearning {
*
* Example: `tfliteModel: { gcsTfliteUri: 'gs://your-bucket/your-model.tflite' }`
*/
tfliteModel?: {gcsTfliteUri: string};
tfliteModel?: { gcsTfliteUri: string };
}

/**
Expand Down

0 comments on commit eec3660

Please sign in to comment.