or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

app-management.mdauthentication.mdfirestore.mdfunctions.mdindex.mdmachine-learning.mdmessaging.mdproject-management.mdrealtime-database.mdremote-config.mdstorage.mdtenant-management.md

project-management.mddocs/

0

# Project Management

1

2

Firebase project management for creating and managing Android and iOS app configurations within Firebase projects. Provides comprehensive app lifecycle management and configuration capabilities.

3

4

## Capabilities

5

6

### App Instance Management

7

8

Create and retrieve Android and iOS app instances within Firebase projects with complete configuration management.

9

10

```python { .api }

11

def android_app(app_id, app=None):

12

"""

13

Get an AndroidApp instance for the specified app ID.

14

15

Args:

16

app_id: Android app ID string

17

app: Firebase app instance (optional)

18

19

Returns:

20

AndroidApp: Android app instance for management operations

21

22

Raises:

23

NotFoundError: If the app doesn't exist

24

"""

25

26

def ios_app(app_id, app=None):

27

"""

28

Get an IOSApp instance for the specified app ID.

29

30

Args:

31

app_id: iOS app ID string

32

app: Firebase app instance (optional)

33

34

Returns:

35

IOSApp: iOS app instance for management operations

36

37

Raises:

38

NotFoundError: If the app doesn't exist

39

"""

40

```

41

42

### App Creation

43

44

Create new Android and iOS applications in Firebase projects with initial configuration.

45

46

```python { .api }

47

def create_android_app(package_name, display_name=None, app=None):

48

"""

49

Create a new Android app in the Firebase project.

50

51

Args:

52

package_name: Android package name (e.g., 'com.example.app')

53

display_name: Human-readable app name (optional)

54

app: Firebase app instance (optional)

55

56

Returns:

57

AndroidApp: Newly created Android app instance

58

59

Raises:

60

AlreadyExistsError: If an app with the package name already exists

61

InvalidArgumentError: If the package name is invalid

62

"""

63

64

def create_ios_app(bundle_id, display_name=None, app=None):

65

"""

66

Create a new iOS app in the Firebase project.

67

68

Args:

69

bundle_id: iOS bundle identifier (e.g., 'com.example.app')

70

display_name: Human-readable app name (optional)

71

app: Firebase app instance (optional)

72

73

Returns:

74

IOSApp: Newly created iOS app instance

75

76

Raises:

77

AlreadyExistsError: If an app with the bundle ID already exists

78

InvalidArgumentError: If the bundle ID is invalid

79

"""

80

```

81

82

### App Listing

83

84

List all Android and iOS applications in the Firebase project.

85

86

```python { .api }

87

def list_android_apps(app=None):

88

"""

89

List all Android apps in the project.

90

91

Args:

92

app: Firebase app instance (optional)

93

94

Returns:

95

list[AndroidApp]: List of AndroidApp instances in the project

96

"""

97

98

def list_ios_apps(app=None):

99

"""

100

List all iOS apps in the project.

101

102

Args:

103

app: Firebase app instance (optional)

104

105

Returns:

106

list[IOSApp]: List of IOSApp instances in the project

107

"""

108

```

109

110

## Android App Management

111

112

### AndroidApp Class

113

114

```python { .api }

115

class AndroidApp:

116

"""Represents an Android app in a Firebase project."""

117

118

@property

119

def app_id(self):

120

"""The Firebase app ID."""

121

122

@property

123

def display_name(self):

124

"""The human-readable display name."""

125

126

@property

127

def project_id(self):

128

"""The Firebase project ID."""

129

130

@property

131

def package_name(self):

132

"""The Android package name."""

133

134

def get_metadata(self):

135

"""

136

Get the app's metadata.

137

138

Returns:

139

AndroidAppMetadata: Metadata for the Android app

140

"""

141

142

def set_display_name(self, new_display_name):

143

"""

144

Set the display name for the app.

145

146

Args:

147

new_display_name: New display name string

148

"""

149

150

def get_config(self):

151

"""

152

Get the configuration file content for the app.

153

154

Returns:

155

bytes: Content of the google-services.json file

156

"""

157

158

def get_sha_certificates(self):

159

"""

160

Get the SHA certificates for the app.

161

162

Returns:

163

list[SHACertificate]: List of SHA certificates

164

"""

165

166

def add_sha_certificate(self, certificate):

167

"""

168

Add a SHA certificate to the app.

169

170

Args:

171

certificate: SHACertificate instance to add

172

173

Returns:

174

SHACertificate: The added certificate with server-assigned name

175

"""

176

177

def delete_sha_certificate(self, certificate_name):

178

"""

179

Delete a SHA certificate from the app.

180

181

Args:

182

certificate_name: Name of the certificate to delete

183

"""

184

185

class AndroidAppMetadata:

186

"""Metadata for an Android app."""

187

188

@property

189

def display_name(self):

190

"""The display name of the app."""

191

192

@property

193

def app_id(self):

194

"""The Firebase app ID."""

195

196

@property

197

def package_name(self):

198

"""The Android package name."""

199

200

@property

201

def project_id(self):

202

"""The Firebase project ID."""

203

204

class SHACertificate:

205

"""SHA certificate for Android app signing."""

206

207

def __init__(self, sha_hash, cert_type=None):

208

"""

209

Initialize SHA certificate.

210

211

Args:

212

sha_hash: SHA fingerprint string

213

cert_type: Certificate type ('SHA_1' or 'SHA_256')

214

"""

215

216

@property

217

def name(self):

218

"""The server-assigned certificate name."""

219

220

@property

221

def sha_hash(self):

222

"""The SHA fingerprint."""

223

224

@property

225

def cert_type(self):

226

"""The certificate type."""

227

```

228

229

## iOS App Management

230

231

### IOSApp Class

232

233

```python { .api }

234

class IOSApp:

235

"""Represents an iOS app in a Firebase project."""

236

237

@property

238

def app_id(self):

239

"""The Firebase app ID."""

240

241

@property

242

def display_name(self):

243

"""The human-readable display name."""

244

245

@property

246

def project_id(self):

247

"""The Firebase project ID."""

248

249

@property

250

def bundle_id(self):

251

"""The iOS bundle identifier."""

252

253

def get_metadata(self):

254

"""

255

Get the app's metadata.

256

257

Returns:

258

IOSAppMetadata: Metadata for the iOS app

259

"""

260

261

def set_display_name(self, new_display_name):

262

"""

263

Set the display name for the app.

264

265

Args:

266

new_display_name: New display name string

267

"""

268

269

def get_config(self):

270

"""

271

Get the configuration file content for the app.

272

273

Returns:

274

bytes: Content of the GoogleService-Info.plist file

275

"""

276

277

class IOSAppMetadata:

278

"""Metadata for an iOS app."""

279

280

@property

281

def display_name(self):

282

"""The display name of the app."""

283

284

@property

285

def app_id(self):

286

"""The Firebase app ID."""

287

288

@property

289

def bundle_id(self):

290

"""The iOS bundle identifier."""

291

292

@property

293

def project_id(self):

294

"""The Firebase project ID."""

295

```

296

297

## Usage Examples

298

299

### Creating and Managing Android Apps

300

301

```python

302

from firebase_admin import project_management

303

304

# Create a new Android app

305

android_app = project_management.create_android_app(

306

package_name='com.example.myapp',

307

display_name='My Android App'

308

)

309

310

print(f'Created Android app: {android_app.app_id}')

311

print(f'Package name: {android_app.package_name}')

312

313

# Get app metadata

314

metadata = android_app.get_metadata()

315

print(f'Display name: {metadata.display_name}')

316

print(f'Project ID: {metadata.project_id}')

317

318

# Update display name

319

android_app.set_display_name('My Updated Android App')

320

321

# Download configuration file

322

config_data = android_app.get_config()

323

with open('google-services.json', 'wb') as f:

324

f.write(config_data)

325

```

326

327

### Managing SHA Certificates

328

329

```python

330

# Add SHA certificate for app signing

331

sha_cert = project_management.SHACertificate(

332

sha_hash='AA:BB:CC:DD:EE:FF:00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD',

333

cert_type='SHA_1'

334

)

335

336

added_cert = android_app.add_sha_certificate(sha_cert)

337

print(f'Added certificate: {added_cert.name}')

338

339

# List all SHA certificates

340

certificates = android_app.get_sha_certificates()

341

for cert in certificates:

342

print(f'Certificate: {cert.sha_hash} ({cert.cert_type})')

343

344

# Delete a certificate

345

android_app.delete_sha_certificate(added_cert.name)

346

```

347

348

### Creating and Managing iOS Apps

349

350

```python

351

# Create a new iOS app

352

ios_app = project_management.create_ios_app(

353

bundle_id='com.example.myapp',

354

display_name='My iOS App'

355

)

356

357

print(f'Created iOS app: {ios_app.app_id}')

358

print(f'Bundle ID: {ios_app.bundle_id}')

359

360

# Get app metadata

361

metadata = ios_app.get_metadata()

362

print(f'Display name: {metadata.display_name}')

363

364

# Update display name

365

ios_app.set_display_name('My Updated iOS App')

366

367

# Download configuration file

368

config_data = ios_app.get_config()

369

with open('GoogleService-Info.plist', 'wb') as f:

370

f.write(config_data)

371

```

372

373

### Listing All Apps

374

375

```python

376

# List all Android apps in the project

377

android_apps = project_management.list_android_apps()

378

print(f'Android apps in project: {len(android_apps)}')

379

380

for app in android_apps:

381

print(f' {app.display_name} (ID: {app.app_id})')

382

print(f' Package: {app.package_name}')

383

384

# List all iOS apps in the project

385

ios_apps = project_management.list_ios_apps()

386

print(f'iOS apps in project: {len(ios_apps)}')

387

388

for app in ios_apps:

389

print(f' {app.display_name} (ID: {app.app_id})')

390

print(f' Bundle ID: {app.bundle_id}')

391

```

392

393

### Retrieving Existing Apps

394

395

```python

396

# Get existing apps by ID

397

existing_android = project_management.android_app('1:123456789:android:abcdef123456')

398

existing_ios = project_management.ios_app('1:123456789:ios:abcdef123456')

399

400

print(f'Android app: {existing_android.display_name}')

401

print(f'iOS app: {existing_ios.display_name}')

402

```

403

404

### Batch App Management

405

406

```python

407

# Create multiple apps

408

android_apps_to_create = [

409

{'package': 'com.example.app1', 'name': 'App One'},

410

{'package': 'com.example.app2', 'name': 'App Two'},

411

{'package': 'com.example.app3', 'name': 'App Three'}

412

]

413

414

created_android_apps = []

415

for app_config in android_apps_to_create:

416

try:

417

app = project_management.create_android_app(

418

package_name=app_config['package'],

419

display_name=app_config['name']

420

)

421

created_android_apps.append(app)

422

print(f'Created: {app.display_name}')

423

except Exception as e:

424

print(f'Failed to create {app_config["name"]}: {e}')

425

426

# Download configuration files for all apps

427

for i, app in enumerate(created_android_apps):

428

config_data = app.get_config()

429

filename = f'google-services-{i+1}.json'

430

with open(filename, 'wb') as f:

431

f.write(config_data)

432

print(f'Downloaded config for {app.display_name} to {filename}')

433

```

434

435

### Certificate Management for Multiple Apps

436

437

```python

438

# Add the same certificate to multiple Android apps

439

sha_certificate = project_management.SHACertificate(

440

sha_hash='11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33:44',

441

cert_type='SHA_256'

442

)

443

444

android_apps = project_management.list_android_apps()

445

for app in android_apps:

446

try:

447

app.add_sha_certificate(sha_certificate)

448

print(f'Added certificate to {app.display_name}')

449

except Exception as e:

450

print(f'Failed to add certificate to {app.display_name}: {e}')

451

```

452

453

### Configuration File Management

454

455

```python

456

import os

457

from datetime import datetime

458

459

def backup_config_files():

460

"""Backup all app configuration files."""

461

timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')

462

backup_dir = f'firebase_configs_{timestamp}'

463

os.makedirs(backup_dir, exist_ok=True)

464

465

# Backup Android configs

466

android_apps = project_management.list_android_apps()

467

for i, app in enumerate(android_apps):

468

config_data = app.get_config()

469

filename = f'{backup_dir}/android_{app.app_id}_google-services.json'

470

with open(filename, 'wb') as f:

471

f.write(config_data)

472

473

# Backup iOS configs

474

ios_apps = project_management.list_ios_apps()

475

for i, app in enumerate(ios_apps):

476

config_data = app.get_config()

477

filename = f'{backup_dir}/ios_{app.app_id}_GoogleService-Info.plist'

478

with open(filename, 'wb') as f:

479

f.write(config_data)

480

481

print(f'Backed up configs to {backup_dir}')

482

483

backup_config_files()

484

```

485

486

### Error Handling

487

488

```python

489

from firebase_admin.exceptions import NotFoundError, AlreadyExistsError, InvalidArgumentError

490

491

try:

492

# Attempt to create app with existing package name

493

app = project_management.create_android_app(

494

package_name='com.existing.app',

495

display_name='Duplicate App'

496

)

497

except AlreadyExistsError:

498

print('App with this package name already exists')

499

# Get existing app instead

500

existing_apps = project_management.list_android_apps()

501

for existing_app in existing_apps:

502

if existing_app.package_name == 'com.existing.app':

503

app = existing_app

504

break

505

506

try:

507

# Attempt to get non-existent app

508

app = project_management.android_app('invalid-app-id')

509

except NotFoundError:

510

print('App not found')

511

512

try:

513

# Invalid package name

514

app = project_management.create_android_app(

515

package_name='invalid-package-name',

516

display_name='Invalid App'

517

)

518

except InvalidArgumentError as e:

519

print(f'Invalid package name: {e}')

520

```

521

522

## Best Practices

523

524

### App Organization

525

526

- **Naming Conventions**: Use consistent naming for display names

527

- **Package/Bundle IDs**: Follow platform conventions for identifiers

528

- **Documentation**: Maintain documentation of app purposes and configurations

529

- **Environment Separation**: Use different projects for dev/staging/production

530

531

### Security Management

532

533

- **Certificate Management**: Regularly rotate and manage SHA certificates

534

- **Access Control**: Use IAM roles to control project management permissions

535

- **Configuration Security**: Securely store and distribute configuration files

536

- **Audit Logging**: Monitor app creation and modification activities

537

538

### Automation and CI/CD

539

540

- **Automated Setup**: Script app creation for new environments

541

- **Configuration Management**: Automate configuration file distribution

542

- **Certificate Updates**: Automate certificate management in CI/CD pipelines

543

- **Validation**: Validate app configurations before deployment

544

545

## Types

546

547

```python { .api }

548

class AndroidApp:

549

"""Represents an Android app in a Firebase project."""

550

551

@property

552

def app_id(self):

553

"""The Firebase app ID."""

554

555

@property

556

def display_name(self):

557

"""The human-readable display name."""

558

559

@property

560

def package_name(self):

561

"""The Android package name."""

562

563

class IOSApp:

564

"""Represents an iOS app in a Firebase project."""

565

566

@property

567

def app_id(self):

568

"""The Firebase app ID."""

569

570

@property

571

def display_name(self):

572

"""The human-readable display name."""

573

574

@property

575

def bundle_id(self):

576

"""The iOS bundle identifier."""

577

578

class AndroidAppMetadata:

579

"""Metadata for an Android app."""

580

581

@property

582

def display_name(self):

583

"""The display name of the app."""

584

585

@property

586

def app_id(self):

587

"""The Firebase app ID."""

588

589

@property

590

def package_name(self):

591

"""The Android package name."""

592

593

class IOSAppMetadata:

594

"""Metadata for an iOS app."""

595

596

@property

597

def display_name(self):

598

"""The display name of the app."""

599

600

@property

601

def app_id(self):

602

"""The Firebase app ID."""

603

604

@property

605

def bundle_id(self):

606

"""The iOS bundle identifier."""

607

608

class SHACertificate:

609

"""SHA certificate for Android app signing."""

610

611

def __init__(self, sha_hash, cert_type=None):

612

"""Initialize SHA certificate."""

613

614

@property

615

def name(self):

616

"""The server-assigned certificate name."""

617

618

@property

619

def sha_hash(self):

620

"""The SHA fingerprint."""

621

622

@property

623

def cert_type(self):

624

"""The certificate type ('SHA_1' or 'SHA_256')."""

625

```