# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: test-extension
version: 0.0.1
specVersion: v1beta

displayName: Test Extension
description: This extension is a test

license: Apache-2.0

sourceUrl: (TODO)
releaseNotesUrl: (TODO)

author:
  authorName: (TODO)
  url: (TODO)

contributors:
  - authorName: Jacob Cable
    email: jacob@invertase.io
    url: https://github.com/chrisbianca
  - authorName: Invertase
    email: oss@invertase.io
    url: https://github.com/invertase

billingRequired: true

roles:
  - role: datastore.user
    reason: Test extension for distributed tasks with Cloud Tasks and Cloud Firestore.

resources:
  - name: backfillTrigger
    type: firebaseextensions.v1beta.function
    description: >-
      Queues the backfill tasks
    properties:
      availableMemoryMb: 512
      location: ${LOCATION}
      runtime: nodejs18
      timeout: 540s
      taskQueueTrigger: {}

  - name: backfillTask
    type: firebaseextensions.v1beta.function
    description: >-
      Performs the process for backfill
    properties:
      availableMemoryMb: 1024
      location: ${LOCATION}
      runtime: nodejs18
      timeout: 540s
      taskQueueTrigger:
        retryConfig:
          maxAttempts: 50
params:
  - param: LOCATION
    label: Cloud Functions location
    description: >-
      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).
    type: select
    options:
      - label: Iowa (us-central1)
        value: us-central1
      - label: South Carolina (us-east1)
        value: us-east1
      - label: Northern Virginia (us-east4)
        value: us-east4
      - label: Los Angeles (us-west2)
        value: us-west2
      - label: Salt Lake City (us-west3)
        value: us-west3
      - label: Las Vegas (us-west4)
        value: us-west4
      - label: Warsaw (europe-central2)
        value: europe-central2
      - label: Belgium (europe-west1)
        value: europe-west1
      - label: London (europe-west2)
        value: europe-west2
      - label: Frankfurt (europe-west3)
        value: europe-west3
      - label: Zurich (europe-west6)
        value: europe-west6
      - label: Hong Kong (asia-east2)
        value: asia-east2
      - label: Tokyo (asia-northeast1)
        value: asia-northeast1
      - label: Osaka (asia-northeast2)
        value: asia-northeast2
      - label: Seoul (asia-northeast3)
        value: asia-northeast3
      - label: Mumbai (asia-south1)
        value: asia-south1
      - label: Jakarta (asia-southeast2)
        value: asia-southeast2
      - label: Montreal (northamerica-northeast1)
        value: northamerica-northeast1
      - label: Sao Paulo (southamerica-east1)
        value: southamerica-east1
      - label: Sydney (australia-southeast1)
        value: australia-southeast1
    required: true
    immutable: true

lifecycleEvents:
  onInstall:
    function: backfillTrigger
    processingMessage: Process existing documents
  onConfigure:
    function: backfillTrigger
    processingMessage: Process existing documents
