Skip to content

Commit

Permalink
Add EventBridge Scheduler Java examples (awsdocs#6973)
Browse files Browse the repository at this point in the history
  • Loading branch information
scmacdon authored Oct 22, 2024
1 parent 6dc1b78 commit ab72182
Show file tree
Hide file tree
Showing 12 changed files with 1,586 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .doc_gen/metadata/scheduler_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ scheduler_hello:
synopsis: get started using &EVS;.
category: Hello
languages:
Java:
versions:
- sdk_version: 2
github: javav2/example_code/scheduler
excerpts:
- description:
snippet_tags:
- scheduler.javav2.hello.main
.NET:
versions:
- sdk_version: 3
Expand All @@ -17,6 +25,14 @@ scheduler_hello:
scheduler: {ListSchedules}
scheduler_CreateSchedule:
languages:
Java:
versions:
- sdk_version: 2
github: javav2/example_code/scheduler
excerpts:
- description:
snippet_tags:
- scheduler.javav2.create.schedule.main
.NET:
versions:
- sdk_version: 3
Expand All @@ -30,6 +46,14 @@ scheduler_CreateSchedule:
scheduler: {CreateSchedule}
scheduler_CreateScheduleGroup:
languages:
Java:
versions:
- sdk_version: 2
github: javav2/example_code/scheduler
excerpts:
- description:
snippet_tags:
- scheduler.javav2.create.schedule.group.main
.NET:
versions:
- sdk_version: 3
Expand All @@ -52,10 +76,26 @@ scheduler_DeleteSchedule:
genai: most
snippet_tags:
- Scheduler.dotnetv3.DeleteSchedule
Java:
versions:
- sdk_version: 2
github: javav2/example_code/scheduler
excerpts:
- description:
snippet_tags:
- scheduler.javav2.delete.schedule.main
services:
scheduler: {DeleteSchedule}
scheduler_DeleteScheduleGroup:
languages:
Java:
versions:
- sdk_version: 2
github: javav2/example_code/scheduler
excerpts:
- description:
snippet_tags:
- scheduler.javav2.delete.schedule.group.main
.NET:
versions:
- sdk_version: 3
Expand All @@ -79,6 +119,19 @@ scheduler_ScheduledEventsWorkflow:
- Clean up resources and delete the stack.
category: Scenarios
languages:
Java:
versions:
- sdk_version: 2
github: javav2/example_code/scheduler
excerpts:
- description: Run the workflow.
genai: most
snippet_tags:
- scheduler.javav2.scenario.main
- description: Wrapper for service operations.
genai: most
snippet_tags:
- scheduler.javav2.actions.main
.NET:
versions:
- sdk_version: 3
Expand Down
38 changes: 38 additions & 0 deletions javav2/example_code/scheduler/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
115 changes: 115 additions & 0 deletions javav2/example_code/scheduler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# EventBridge Scheduler code examples for the SDK for Java 2.x

## Overview

Shows how to use the AWS SDK for Java 2.x to work with Amazon EventBridge Scheduler.

<!--custom.overview.start-->
<!--custom.overview.end-->

_EventBridge Scheduler allows you to create, run, and manage tasks on a schedule from one central, managed service._

## ⚠ Important

* Running this code might result in charges to your AWS account. For more details, see [AWS Pricing](https://aws.amazon.com/pricing/) and [Free Tier](https://aws.amazon.com/free/).
* Running the tests might result in charges to your AWS account.
* We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege).
* This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services).

<!--custom.important.start-->
<!--custom.important.end-->

## Code examples

### Prerequisites

For prerequisites, see the [README](../../README.md#Prerequisites) in the `javav2` folder.


<!--custom.prerequisites.start-->
<!--custom.prerequisites.end-->

### Get started

- [Hello EventBridge Scheduler](src/main/java/com/example/eventbrideschedule/HelloScheduler.java#L6) (`ListSchedules`)


### Single actions

Code excerpts that show you how to call individual service functions.

- [CreateSchedule](src/main/java/com/example/eventbrideschedule/scenario/EventbridgeSchedulerActions.java#L104)
- [CreateScheduleGroup](src/main/java/com/example/eventbrideschedule/scenario/EventbridgeSchedulerActions.java#L70)
- [DeleteSchedule](src/main/java/com/example/eventbrideschedule/scenario/EventbridgeSchedulerActions.java#L212)
- [DeleteScheduleGroup](src/main/java/com/example/eventbrideschedule/scenario/EventbridgeSchedulerActions.java#L182)

### Scenarios

Code examples that show you how to accomplish a specific task by calling multiple
functions within the same service.

- [Scheduled Events workflow](src/main/java/com/example/eventbrideschedule/scenario/EventbridgeSchedulerScenario.java)


<!--custom.examples.start-->
<!--custom.examples.end-->

## Run the examples

### Instructions


<!--custom.instructions.start-->
<!--custom.instructions.end-->

#### Hello EventBridge Scheduler

This example shows you how to get started using EventBridge Scheduler.



#### Scheduled Events workflow

This example shows you how to do the following:

- Deploy a CloudFormation stack with required resources.
- Create a EventBridge Scheduler schedule group.
- Create a one-time EventBridge Scheduler schedule with a flexible time window.
- Create a recurring EventBridge Scheduler schedule with a specified rate.
- Delete EventBridge Scheduler the schedule and schedule group.
- Clean up resources and delete the stack.

<!--custom.scenario_prereqs.scheduler_ScheduledEventsWorkflow.start-->
<!--custom.scenario_prereqs.scheduler_ScheduledEventsWorkflow.end-->


<!--custom.scenarios.scheduler_ScheduledEventsWorkflow.start-->
<!--custom.scenarios.scheduler_ScheduledEventsWorkflow.end-->

### Tests

⚠ Running tests might result in charges to your AWS account.


To find instructions for running these tests, see the [README](../../README.md#Tests)
in the `javav2` folder.



<!--custom.tests.start-->
<!--custom.tests.end-->

## Additional resources

- [EventBridge Scheduler User Guide](https://docs.aws.amazon.com/scheduler/latest/userguide/intro.html)
- [EventBridge Scheduler API Reference](https://docs.aws.amazon.com/scheduler/latest/apireference/Welcome.html)
- [SDK for Java 2.x EventBridge Scheduler reference](https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/firehose/package-summary.html)

<!--custom.resources.start-->
<!--custom.resources.end-->

---

Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
Loading

0 comments on commit ab72182

Please sign in to comment.