# ---------------------------------------------------------------------------
# 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-calendar-source
  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,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjE4NiAzOCA3NiA3NiI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTI0NCA1NmgtNDB2NDBoNDBWNTZ6Ii8+PHBhdGggZmlsbD0iI0VBNDMzNSIgZD0iTTI0NCAxMTRsMTgtMThoLTE4djE4eiIvPjxwYXRoIGZpbGw9IiNGQkJDMDQiIGQ9Ik0yNjIgNTZoLTE4djQwaDE4VjU2eiIvPjxwYXRoIGZpbGw9IiMzNEE4NTMiIGQ9Ik0yNDQgOTZoLTQwdjE4aDQwVjk2eiIvPjxwYXRoIGZpbGw9IiMxODgwMzgiIGQ9Ik0xODYgOTZ2MTJjMCAzLjMxNSAyLjY4NSA2IDYgNmgxMlY5NmgtMTh6Ii8+PHBhdGggZmlsbD0iIzE5NjdEMiIgZD0iTTI2MiA1NlY0NGMwLTMuMzE1LTIuNjg1LTYtNi02aC0xMnYxOGgxOHoiLz48cGF0aCBmaWxsPSIjNDI4NUY0IiBkPSJNMjQ0IDM4aC01MmMtMy4zMTUgMCAtNiAyLjY4NS02IDZ2NTJ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1LjkyLTEuNzU1LjAwNS0zLjM3NS0uNS00Ljg3LTEuNTF6TTIzMy41MiA2OS44MWwtMy44MSAyLjc1NS0xLjkwNS0yLjg5IDYuODM1LTQuOTNoMi42MlY4OGgtMy43NFY2OS44MXoiLz48L3N2Zz4="
    camel.apache.org/provider: "Apache Software Foundation"
    camel.apache.org/kamelet.group: "Google Calendar"
    camel.apache.org/kamelet.namespace: "GCP"
  labels:
    camel.apache.org/kamelet.type: "source"
spec:
  definition:
    title: "Google Calendar Source"
    description: |-
      Receive event data from Google Calendar.
    required:
      - index
      - calendarId
      - clientId
      - accessToken
      - refreshToken
      - clientSecret
      - applicationName
    type: object
    properties:
      index:
        title: Index
        description: An index for the Google Calendar endpoint.
        type: string
      calendarId:
        title: Calendar ID
        description: The calendar ID to use as the source of event data.
        type: string
      clientId:
        title: Client Id
        description: The Client ID of the Google Calendar application.
        type: string
        format: password
        x-descriptors:
        - urn:camel:group:credentials
      clientSecret:
        title: Client Secret
        description: The Client secret of the Google Calendar application.
        type: string
        format: password
        x-descriptors:
        - urn:camel:group:credentials
      accessToken:
        title: Access Token
        description: The OAuth 2 access token for the Google Calendar application. This token typically expires after an hour. For long term usage, set the `refreshToken` property.
        type: string
        format: password
        x-descriptors:
        - urn:camel:group:credentials
      refreshToken:
        title: Refresh Token
        description: The OAuth 2 refresh token for the Google Calendar application. The Google Calendar component can obtain a new `accessToken` whenever the current one expires. Set this value for long term usage.
        type: string
        format: password
        x-descriptors:
        - urn:camel:group:credentials
      delay:
        title: Delay
        description: The number of milliseconds before the next poll.
        type: integer
        default: 500
      applicationName:
        title: Application name
        description: The Google Calendar application name.
        type: string
      syncFlow:
        title: Sync Flow
        description: Specifies to sync events for incremental synchronization.
        type: boolean
        default: false
      consumeFromNow:
        title: Consume from now
        description: Specfies to consume events in the calendar from now on.
        type: boolean
        default: true
  dataTypes:
    out:
      default: json
      headers:
        CamelGoogleCalendarEventId:
          title: Camel Google Calendar Event Id
          description: The calendar event id
          type: string
      types:
        json:
          format: "application-json"
          description: |-
            Json representation of a Google Calendar event object.
          mediaType: application/json
        cloudevents:
          format: "google-calendar-stream:application-cloudevents"
          description: |-
            Output data type represents Google Calendar Stream response as CloudEvent V1. The data type sets Camel specific CloudEvent headers on the exchange with
            respective data from the Calendar Events and its derived object.
          headers:
            CamelCloudEventID:
              title: CloudEvent ID
              description: The Camel exchange id set as event id
              type: string
            CamelCloudEventType:
              title: CloudEvent Type
              description: The event type
              default: "org.apache.camel.event.google.calendar.stream.consume"
              type: string
            CamelCloudEventSource:
              title: CloudEvent Source
              description: The event source. By default, the Calendar Event Id with prefix "google.calendar.stream.".
              type: string
            CamelCloudEventSubject:
              title: CloudEvent Subject
              description: The event subject. The Calendar event type.
              type: string
            CamelCloudEventTime:
              title: CloudEvent Time
              description: The exchange creation timestamp as event time.
              type: string
  dependencies:
  - "camel:jackson"
  - "camel:google-calendar"
  - "camel:kamelet"
  template:
    from:
      uri: "google-calendar-stream://{{index}}"
      parameters:
        clientId: "{{clientId}}"
        calendarId: "{{calendarId}}"
        accessToken: "{{accessToken}}"
        refreshToken: "{{refreshToken}}"
        clientSecret: "{{clientSecret}}"
        delay: "{{delay}}"
        applicationName: "{{applicationName}}"
        syncFlow: "{{syncFlow}}"
        consumeFromNow: "{{consumeFromNow}}"
      steps:
      - marshal:
          json: {}
      - to: "kamelet:sink"