generated from kestra-io/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 13
feat(calendar): add EventCreated trigger for Google Calendar monitoring #285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Shadterra
wants to merge
6
commits into
kestra-io:main
Choose a base branch
from
Shadterra:googlecalendar-event-trigger
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+971
−0
Open
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
332223d
Adding Google Calendar "Event Created" Trigger - First Push
Shadterra 3e6bc9f
Merge branch 'main' into googlecalendar-event-trigger
fdelbrayelle 80468ee
Fixed EventCreated Trigger, EventCreatedTriggerTest, AbstractCalendar…
Shadterra 5b5b6ab
Updated EventCreatedTriggerTest with better tests
Shadterra 3c76578
Update src/main/java/io/kestra/plugin/googleworkspace/calendar/Abstra…
Shadterra e331fd5
Fixed AbstractCalendarTrigger and EventCreatedTrigger to return all e…
Shadterra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/main/java/io/kestra/plugin/googleworkspace/calendar/AbstractCalendarTrigger.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package io.kestra.plugin.googleworkspace.calendar; | ||
|
|
||
| import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; | ||
| import com.google.api.client.json.gson.GsonFactory; | ||
| import com.google.api.services.calendar.Calendar; | ||
| import com.google.auth.http.HttpCredentialsAdapter; | ||
| import com.google.auth.oauth2.GoogleCredentials; | ||
| import io.kestra.core.models.property.Property; | ||
| import io.kestra.core.models.triggers.AbstractTrigger; | ||
| import io.kestra.core.runners.RunContext; | ||
| import io.kestra.plugin.googleworkspace.GcpInterface; | ||
| import io.swagger.v3.oas.annotations.media.Schema; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import lombok.EqualsAndHashCode; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import lombok.ToString; | ||
| import lombok.experimental.SuperBuilder; | ||
|
|
||
| import java.io.ByteArrayInputStream; | ||
| import java.nio.charset.StandardCharsets; | ||
|
|
||
| @SuperBuilder | ||
| @ToString | ||
| @EqualsAndHashCode | ||
| @Getter | ||
| @NoArgsConstructor | ||
| public abstract class AbstractCalendarTrigger extends AbstractTrigger implements GcpInterface { | ||
| private static final String APPLICATION_NAME = "Kestra"; | ||
|
|
||
| @Schema( | ||
| title = "The Google Cloud service account key", | ||
| description = "Service account JSON key with access to Google Calendar API. " + | ||
| "The service account must have read access to the calendars you want to monitor. " + | ||
| "Share calendars with the service account's email address (found in the JSON key)." | ||
| ) | ||
| @NotNull | ||
| protected Property<String> serviceAccount; | ||
|
|
||
| protected Calendar connection(RunContext runContext) throws Exception { | ||
| String renderedServiceAccount = runContext.render(this.serviceAccount).as(String.class).orElseThrow(); | ||
| var renderedScopes = runContext.render(this.getScopes()).asList(String.class); | ||
|
|
||
| GoogleCredentials credentials = GoogleCredentials | ||
| .fromStream(new ByteArrayInputStream(renderedServiceAccount.getBytes(StandardCharsets.UTF_8))) | ||
| .createScoped(renderedScopes); | ||
|
|
||
| return new Calendar.Builder( | ||
| GoogleNetHttpTransport.newTrustedTransport(), | ||
| GsonFactory.getDefaultInstance(), | ||
| new HttpCredentialsAdapter(credentials) | ||
| ) | ||
| .setApplicationName(APPLICATION_NAME) | ||
| .build(); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.