Skip to content

Commit

Permalink
Merge pull request #18 from htsuruo/feature/htsuruo/select-resource-f…
Browse files Browse the repository at this point in the history
…or-buckets-parameter

Add `selectResource` type for buckets parameter
  • Loading branch information
htsuruo authored Sep 5, 2023
2 parents 9f970d3 + 9dc0956 commit 5895273
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 48 deletions.
19 changes: 1 addition & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,2 @@
# firebase-extensions

This is a collection of Firebase Extensions build by [htsuruo](https://github.com/htsuruo), designed to help you build better apps faster.

## List of Extensions

- [back-up-firestore-to-storage](https://github.com/htsuruo/firebase-extensions/tree/main/back-up-firestore-to-storage)
- Exports Firestore documents to Cloud Storage at any scheduled time.
- [Install in Firebase Console](https://extensions.dev/extensions/htsuruo/back-up-firestore-to-storage)
- [trigger-github-issues-from-crashlytics](https://github.com/htsuruo/firebase-extensions/tree/main/trigger-github-issues-from-crashlytics)
- Automatically creates GitHub Issues triggered by Crashlytics alerts.
- [Install in Firebase Console](https://extensions.dev/extensions/htsuruo/trigger-github-issues-from-crashlytics)

## References

- [firebase/extensions](https://github.com/firebase/extensions)
- [invertase/firebase-extensions](https://github.com/invertase/firebase-extensions)
- [rowyio/firebase-extensions](https://github.com/rowyio/firebase-extensions)
- [yamankatby/firebase-extensions](https://github.com/yamankatby/firebase-extensions)
Error: Could not find "/Users/tsuruoka/github/firebase-extensions/extension.yaml""
4 changes: 4 additions & 0 deletions back-up-firestore-to-storage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Version 0.1.0

- Change buckets parameter type to `selectResource`

## Version 0.0.6

- Fix setting the default value of the `TIME_ZONE` parameter to UTC.
Expand Down
36 changes: 11 additions & 25 deletions back-up-firestore-to-storage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

**Description**: Exports Firestore documents to Cloud Storage at any scheduled time.



**Details**: By using this extension, export selected Firestore documents to Cloud Storage at any scheduled time. It depends on Google API's [exportDocuments](https://cloud.google.com/firestore/docs/reference/rest/v1/projects.databases/exportDocuments).

This extension streamlines the creation of content outlined in the Schedule data exports section of [the official Firebase documentation](https://firebase.google.com/docs/firestore/solutions/schedule-export).It eliminates the need to manually create service accounts or configure Cloud Functions. Just install the extension, and with a single click, you're all set up.
Expand Down Expand Up @@ -37,48 +35,36 @@ This extension uses other Firebase or Google Cloud Platform services which may h

When you use Firebase Extensions, you're only charged for the underlying resources that you use. A paid-tier billing plan is only required if the extension uses a service that requires a paid-tier plan, for example calling to a Google Cloud Platform API or making outbound network requests to non-Google services. All Firebase services offer a free tier of usage. [Learn more about Firebase billing.](https://firebase.google.com/pricing)




**Configuration Parameters:**

* Cloud Storage bucket: If not set, `[project-id].appspot.com` is set as the default. If set, the bucket must exist before using this extension. Be sure to consider Google Cloud Storage naming guidelines: [Bucket names](https://cloud.google.com/storage/docs/buckets#naming)
- Cloud Storage bucket: Which resource do you want to use?

* Cloud Storage prefix path (not including heading slash, filename): This is an optional Google Cloud Storage namespace path.
- Cloud Storage prefix path (not including heading slash, filename): This is an optional Google Cloud Storage namespace path.

* Firestore collection ids (separated by ','): Which collection ids to export. Unspecified means all collections.
- Firestore collection ids (separated by ','): Which collection ids to export. Unspecified means all collections.

* The frequency at which you want to execute the backup: - This field can accept strings that use either syntax:
- The frequency at which you want to execute the backup: - This field can accept strings that use either syntax:
- unix-cron syntax (for example, `5 11 * * *`)
- App Engine syntax (for example, `every 5 minutes`)

* The timestamp format for path name to export: If not set, **YYYY-MM-DDTHH\:mm:ss_SSS** is set as the default. This is same to the default folder name of `exportDocuments` API.


* The time zone in which the schedule will run: Refer to [this document](https://cloud.google.com/looker/docs/reference/param-view-timezone-values).

* Cloud Functions location: Where do you want to deploy the functions created for this extension? For help selecting a location, refer to the [location selection guide](https://firebase.google.com/docs/functions/locations).
- The timestamp format for path name to export: If not set, **YYYY-MM-DDTHH\:mm:ss_SSS** is set as the default. This is same to the default folder name of `exportDocuments` API.

- The time zone in which the schedule will run: Refer to [this document](https://cloud.google.com/looker/docs/reference/param-view-timezone-values).

- Cloud Functions location: Where do you want to deploy the functions created for this extension? For help selecting a location, refer to the [location selection guide](https://firebase.google.com/docs/functions/locations).

**Cloud Functions:**

* **backupTransaction:** Schedule triggered function that executes backup Firestore to Cloud Storage


- **backupTransaction:** Schedule triggered function that executes backup Firestore to Cloud Storage

**APIs Used**:

* firestore.googleapis.com (Reason: Exports Firestore documents in a restorable format)


- firestore.googleapis.com (Reason: Exports Firestore documents in a restorable format)

**Access Required**:



This extension will operate with the following project IAM roles:

* datastore.importExportAdmin (Reason: Allows the extension to export Firestore documents data.)
- datastore.importExportAdmin (Reason: Allows the extension to export Firestore documents data.)

* storage.objectAdmin (Reason: Allows the extension to upload exported Firestore documents data to Cloud Storage.)
- storage.objectAdmin (Reason: Allows the extension to upload exported Firestore documents data to Cloud Storage.)
9 changes: 5 additions & 4 deletions back-up-firestore-to-storage/extension.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# https://firebase.google.com/docs/extensions/reference/extension-yaml

name: back-up-firestore-to-storage
version: 0.0.6
version: 0.1.0
specVersion: v1beta
license: Apache-2.0
billingRequired: true
Expand Down Expand Up @@ -50,9 +50,10 @@ params:
- param: BUCKET_NAME
label: Cloud Storage bucket
description: >-
If not set, `[project-id].appspot.com` is set as the default. If set, the bucket must exist before using this extension. Be sure to consider Google Cloud Storage naming guidelines: [Bucket names](https://cloud.google.com/storage/docs/buckets#naming)
type: string
required: false
Which resource do you want to use?
type: selectResource
resourceType: storage.googleapis.com/Bucket
required: true

- param: PREFIX_PATH
label: Cloud Storage prefix path (not including heading slash, filename)
Expand Down
2 changes: 1 addition & 1 deletion back-up-firestore-to-storage/functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const client = new v1.FirestoreAdminClient()
// const storage = new Storage()
const projectId = process.env.PROJECT_ID!
const databaseName = client.databasePath(projectId, '(default)')
const bucketName = process.env.BUCKET_NAME ?? process.env.STORAGE_BUCKET
const bucketName = process.env.BUCKET_NAME!

// ref. https://firebase.google.com/docs/firestore/solutions/schedule-export?hl=en
exports.backupTransaction = pubsub
Expand Down

0 comments on commit 5895273

Please sign in to comment.