Skip to content

Commit b878eb2

Browse files
authored
Implement project-scoped operations for the SDK (#552)
* Added AppMetadata type * listAppMetadata: implement listAppMetadata in ProjectManagement class * Implement setDisplayName() for ProjectManagement class * Update CHANGELOG.MD * Update documentation
1 parent 564cbe5 commit b878eb2

12 files changed

+488
-104
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Unreleased
22

3-
-
3+
- [added] `admin.projectManagement().listAppMetadata()` method to list the app summary of up to 100
4+
apps in a Firebase project
5+
- [added] `admin.projectManagement().setDisplayName()` method to update the display name of a
6+
Firebase project
47

58
# v8.0.0
69

src/index.d.ts

Lines changed: 88 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -4829,55 +4829,94 @@ declare namespace admin.projectManagement {
48294829
}
48304830

48314831
/**
4832-
* Metadata about a Firebase Android app.
4832+
* Metadata about a Firebase app.
48334833
*/
4834-
interface AndroidAppMetadata {
4834+
interface AppMetadata {
48354835

48364836
/**
4837-
* The fully-qualified resource name that identifies this app.
4838-
*
4839-
* This is useful when manually constructing requests for Firebase's public API.
4837+
* The globally unique, Firebase-assigned identifier of the app.
48404838
*
48414839
* @example
48424840
* ```javascript
4843-
* var resourceName = androidAppMetadata.resourceName;
4841+
* var appId = appMetadata.appId;
48444842
* ```
48454843
*/
4846-
resourceName: string;
4844+
appId: string;
48474845

48484846
/**
4849-
* The globally unique, Firebase-assigned identifier of the app.
4847+
* The optional user-assigned display name of the app.
48504848
*
48514849
* @example
48524850
* ```javascript
4853-
* var appId = androidAppMetadata.appId;
4851+
* var displayName = appMetadata.displayName;
48544852
* ```
48554853
*/
4856-
appId: string;
4854+
displayName?: string;
48574855

48584856
/**
4859-
* The optional user-assigned display name of the app.
4857+
* The development platform of the app. Supporting Android and iOS app platforms.
48604858
*
48614859
* @example
48624860
* ```javascript
4863-
* var displayName = androidAppMetadata.displayName;
4861+
* var platform = AppPlatform.ANDROID;
48644862
* ```
48654863
*/
4866-
displayName: string | null;
4864+
platform: AppPlatform;
48674865

48684866
/**
48694867
* The globally unique, user-assigned ID of the parent project for the app.
48704868
*
48714869
* @example
48724870
* ```javascript
4873-
* var projectId = androidAppMetadata.projectId;
4871+
* var projectId = appMetadata.projectId;
48744872
* ```
48754873
*/
48764874
projectId: string;
48774875

48784876
/**
4879-
* The canonical package name of the Android App, as would appear in the Google
4880-
* Play Developer Console.
4877+
* The fully-qualified resource name that identifies this app.
4878+
*
4879+
* This is useful when manually constructing requests for Firebase's public API.
4880+
*
4881+
* @example
4882+
* ```javascript
4883+
* var resourceName = androidAppMetadata.resourceName;
4884+
* ```
4885+
*/
4886+
resourceName: string;
4887+
}
4888+
4889+
/**
4890+
* Platforms with which a Firebase App can be associated.
4891+
*/
4892+
enum AppPlatform {
4893+
4894+
/**
4895+
* Unknown state. This is only used for distinguishing unset values.
4896+
*/
4897+
PLATFORM_UNKNOWN = 'PLATFORM_UNKNOWN',
4898+
4899+
/**
4900+
* The Firebase App is associated with iOS.
4901+
*/
4902+
IOS = 'IOS',
4903+
4904+
/**
4905+
* The Firebase App is associated with Android.
4906+
*/
4907+
ANDROID = 'ANDROID',
4908+
}
4909+
4910+
/**
4911+
* Metadata about a Firebase Android App.
4912+
*/
4913+
interface AndroidAppMetadata extends AppMetadata {
4914+
4915+
platform: AppPlatform.ANDROID;
4916+
4917+
/**
4918+
* The canonical package name of the Android App, as would appear in the Google Play Developer
4919+
* Console.
48814920
*
48824921
* @example
48834922
* ```javascript
@@ -4887,6 +4926,23 @@ declare namespace admin.projectManagement {
48874926
packageName: string;
48884927
}
48894928

4929+
/**
4930+
* Metadata about a Firebase iOS App.
4931+
*/
4932+
interface IosAppMetadata extends AppMetadata {
4933+
platform: AppPlatform.IOS;
4934+
4935+
/**
4936+
* The canonical bundle ID of the iOS App as it would appear in the iOS App Store.
4937+
*
4938+
* @example
4939+
* ```javascript
4940+
* var bundleId = iosAppMetadata.bundleId;
4941+
*```
4942+
*/
4943+
bundleId: string;
4944+
}
4945+
48904946
/**
48914947
* A reference to a Firebase Android app.
48924948
*
@@ -4951,65 +5007,6 @@ declare namespace admin.projectManagement {
49515007
getConfig(): Promise<string>;
49525008
}
49535009

4954-
/**
4955-
* Metadata about a Firebase iOS app.
4956-
*/
4957-
interface IosAppMetadata {
4958-
4959-
/**
4960-
* The fully-qualified resource name that identifies this app.
4961-
*
4962-
* This is useful when manually constructing requests for Firebase's public API.
4963-
*
4964-
* @example
4965-
* ```javascript
4966-
* var resourceName = iOSAppMetadata.resourceName;
4967-
* ```
4968-
*/
4969-
resourceName: string;
4970-
4971-
/**
4972-
* The globally unique, Firebase-assigned identifier of the app.
4973-
*
4974-
* @example
4975-
* ```javascript
4976-
* var appId = androidAppMetadata.appId;
4977-
* ``
4978-
*/
4979-
appId: string;
4980-
4981-
/**
4982-
* The optional user-assigned display name of the app.
4983-
*
4984-
* @example
4985-
* ```javascript
4986-
* var displayName = iOSAppMetadata.displayName;
4987-
* ```
4988-
*/
4989-
displayName: string;
4990-
4991-
/**
4992-
* The globally unique, user-assigned ID of the parent project for the app.
4993-
*
4994-
* @example
4995-
* ```javascript
4996-
* var projectId = iOSAppMetadata.projectId;
4997-
* ```
4998-
*/
4999-
projectId: string;
5000-
5001-
/**
5002-
* The canonical bundle ID of the iOS App as it would appear in the iOS App
5003-
* Store.
5004-
*
5005-
* @example
5006-
* ```javascript
5007-
* var bundleId = iosAppMetadata.bundleId;
5008-
*```
5009-
*/
5010-
bundleId: string;
5011-
}
5012-
50135010
/**
50145011
* A reference to a Firebase iOS app.
50155012
*
@@ -5056,6 +5053,13 @@ declare namespace admin.projectManagement {
50565053
interface ProjectManagement {
50575054
app: admin.app.App;
50585055

5056+
/**
5057+
* Lists up to 100 Firebase apps associated with this Firebase project.
5058+
*
5059+
* @return A promise that resolves to the metadata list of the apps.
5060+
*/
5061+
listAppMetadata(): Promise<admin.projectManagement.AppMetadata[]>;
5062+
50595063
/**
50605064
* Lists up to 100 Firebase Android apps associated with this Firebase project.
50615065
*
@@ -5082,6 +5086,15 @@ declare namespace admin.projectManagement {
50825086
*/
50835087
androidApp(appId: string): admin.projectManagement.AndroidApp;
50845088

5089+
/**
5090+
* Update the display name of this Firebase project.
5091+
*
5092+
* @param newDisplayName The new display name to be updated.
5093+
*
5094+
* @return A promise that resolves when the project display name has been updated.
5095+
*/
5096+
setDisplayName(newDisplayName: string): Promise<void>;
5097+
50855098
/**
50865099
* Creates an `iOSApp` object, referencing the specified iOS app within
50875100
* this Firebase project.

src/project-management/android-app.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import { FirebaseProjectManagementError } from '../utils/error';
1818
import * as validator from '../utils/validator';
1919
import { ProjectManagementRequestHandler, assertServerResponse } from './project-management-api-request';
20+
import { AndroidAppMetadata, AppPlatform } from './app-metadata';
2021

2122
export class AndroidApp {
2223
private readonly resourceName: string;
@@ -49,6 +50,7 @@ export class AndroidApp {
4950
});
5051

5152
const metadata: AndroidAppMetadata = {
53+
platform: AppPlatform.ANDROID,
5254
resourceName: responseData.name,
5355
appId: responseData.appId,
5456
displayName: responseData.displayName || null,
@@ -127,14 +129,6 @@ export class AndroidApp {
127129
}
128130
}
129131

130-
export interface AndroidAppMetadata {
131-
readonly resourceName: string;
132-
readonly appId: string;
133-
readonly displayName: string | null;
134-
readonly projectId: string;
135-
readonly packageName: string;
136-
}
137-
138132
export class ShaCertificate {
139133
public readonly certType: ('sha1' | 'sha256');
140134

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*!
2+
* Copyright 2019 Google Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
export enum AppPlatform {
18+
PLATFORM_UNKNOWN = 'PLATFORM_UNKNOWN',
19+
IOS = 'IOS',
20+
ANDROID = 'ANDROID',
21+
}
22+
23+
export interface AppMetadata {
24+
appId: string;
25+
displayName?: string;
26+
platform: AppPlatform;
27+
projectId: string;
28+
resourceName: string;
29+
}
30+
31+
export interface AndroidAppMetadata extends AppMetadata {
32+
platform: AppPlatform.ANDROID;
33+
packageName: string;
34+
}
35+
36+
export interface IosAppMetadata extends AppMetadata {
37+
platform: AppPlatform.IOS;
38+
bundleId: string;
39+
}

src/project-management/ios-app.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import { FirebaseProjectManagementError } from '../utils/error';
1818
import * as validator from '../utils/validator';
1919
import { ProjectManagementRequestHandler, assertServerResponse } from './project-management-api-request';
20+
import { IosAppMetadata, AppPlatform } from './app-metadata';
2021

2122
export class IosApp {
2223
private readonly resourceName: string;
@@ -49,6 +50,7 @@ export class IosApp {
4950
});
5051

5152
const metadata: IosAppMetadata = {
53+
platform: AppPlatform.IOS,
5254
resourceName: responseData.name,
5355
appId: responseData.appId,
5456
displayName: responseData.displayName || null,
@@ -85,11 +87,3 @@ export class IosApp {
8587
});
8688
}
8789
}
88-
89-
export interface IosAppMetadata {
90-
readonly resourceName: string;
91-
readonly appId: string;
92-
readonly displayName: string;
93-
readonly projectId: string;
94-
readonly bundleId: string;
95-
}

src/project-management/project-management-api-request.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ export class ProjectManagementRequestHandler {
139139
'v1beta1');
140140
}
141141

142+
/**
143+
* @param {string} parentResourceName Fully-qualified resource name of the project whose iOS apps
144+
* you want to list.
145+
*/
146+
public listAppMetadata(parentResourceName: string): Promise<object> {
147+
return this.invokeRequestHandler(
148+
'GET',
149+
`${parentResourceName}:searchApps?page_size=${LIST_APPS_MAX_PAGE_SIZE}`,
150+
/* requestData */ null,
151+
'v1beta1');
152+
}
153+
142154
/**
143155
* @param {string} parentResourceName Fully-qualified resource name of the project that you want
144156
* to create the Android app within.

0 commit comments

Comments
 (0)