# ---------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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
#
#      http://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.
# ---------------------------------------------------------------------------
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
  name: google-bigquery-sink
  annotations:
    camel.apache.org/kamelet.support.level: "Stable"
    camel.apache.org/catalog.version: "4.10.2"
    camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjI1MDAiIHdpZHRoPSIyNTAwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgICAgdmlld0JveD0iLTEuNjMzMjM1NDMzMzI4MjU2IDcuMDMyNjA5MzMwMzE1NjU2NSAxMzEuMjY1NzQ2ODI0MTY4NzYgMTE0LjYzNDM5MDY2OTY4NDM1IiB2ZXJzaW9uPSIxLjAiPgogICAgPGxpbmVhckdyYWRpZW50IGlkPSJhIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjY0IiB4Mj0iNjQiIHkxPSI3LjAzNCIgeTI9IjEyMC43ODkiPgogICAgICAgIDxzdG9wIG9mZnNldD0iMCIgc3RvcC1jb2xvcj0iIzQzODdmZCIvPgogICAgICAgIDxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzQ2ODNlYSIvPgogICAgPC9saW5lYXJHcmFkaWVudD4KICAgIDxwYXRoIGQ9Ik0yNy43OSAxMTUuMjE3TDEuNTQgNjkuNzQ5YTExLjQ5OSAxMS40OTkgMCAwIDEgMC0xMS40OTlsMjYuM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NiA2Ni4xdjguNTYyYTEyLjc4NiAxMi43ODYgMCAwIDAgNC4zODItNC43di0zLjg2MXpNODAuNjkxIDc4LjI4N2wtMi40MDMgMi40MDVhMS4wODggMS4wODggMCAwIDAgMCAxLjUzN2w5LjExNSA5LjExMmExLjA4OCAxLjA4OCAwIDAgMCAxLjUzNyAwbDIuNDAzLTIuNDAyYTEuMDkyIDEuMDkyIDAgMCAwIDAtMS41MzZsLTkuMTE2LTkuMTE2YTEuMDkgMS4wOSAwIDAgMC0xLjUzNiAwIi8+CiAgICA8L2c+Cjwvc3ZnPg=="
    camel.apache.org/provider: "Apache Software Foundation"
    camel.apache.org/kamelet.group: "Google Big Query"
    camel.apache.org/kamelet.namespace: "GCP"
  labels:
    camel.apache.org/kamelet.type: "sink"
spec:
  definition:
    title: "Google Big Query Sink"
    description: |-
      Send data to a Google Big Query table.

      The data must be JSON format to represent an object or an array of objects.
    required:
      - projectId
      - dataset
      - table
      - serviceAccountKey
    type: object
    properties:
      projectId:
        title: Google Cloud Project Id
        description: The Google Cloud Project ID.
        type: string
      dataset:
        title: Big Query Dataset Id
        description: The Big Query Dataset ID.
        type: string
      table:
        title: Big Query Table Id
        description: The Big Query Table ID.
        type: string
      serviceAccountKey:
        title: Service Account Key
        description: The service account key to use as credentials for the BigQuery Service. You must encode this value in base64.
        type: binary
        x-descriptors:
        - urn:camel:group:credentials
  types:
    in:
      mediaType: application/json
  dependencies:
    - "camel:core"
    - "camel:kamelet"
    - "camel:google-bigquery"
    - "camel:jackson"
  template:
    from:
      uri: "kamelet:source"
      steps:
      - unmarshal:
          json:
              library: Jackson
      - to:
          uri: "google-bigquery:{{projectId}}:{{dataset}}:{{table}}"
          parameters:
            serviceAccountKey: "base64:{{serviceAccountKey}}"