Code Monkey home page Code Monkey logo

sdk-java's Introduction

CDEvents Java SDK

Java SDK to produce CDEvents.

The SDK can be used to create CDEvents and render as CloudEvents to send them to a specific CloudEvents broker

Add dependency module

<dependency>
  <groupId>dev.cdevents</groupId>
  <artifactId>cdevents-sdk-java</artifactId>
  <version>${cdevents.version}</version>
</dependency>

Create your first CDEvent

Below is the example of creating a new PipelineRun-finished event,

public class CDEventsExample {

    public static void main(String args[]){
        /*when creating new object of any CDEvent type, the event will be initialized with
        context.id, context.type, context.version, context.timestamp
        and subject.type */
        PipelinerunFinishedCDEvent pipelinerunFinishedCDEvent =  new PipelinerunFinishedCDEvent();

        /* set the required context fields to the pipelineRunFinishedCDEvent */
        pipelinerunFinishedCDEvent.setSource(URI.create("http://dev.cdevents"));

        /* set the required subject fields to the pipelineRunFinishedCDEvent */
        pipelinerunFinishedCDEvent.setSubjectId("/dev/pipeline/run/1");
        pipelinerunFinishedCDEvent.setSubjectSource(URI.create("http://dev.pipeline.run/source"));
        pipelinerunFinishedCDEvent.setSubjectUrl("http://dev.pipeline.run/url");
        pipelinerunFinishedCDEvent.setSubjectOutcome(CDEventConstants.Outcome.SUCCESS.getOutcome());
        pipelinerunFinishedCDEvent.setSubjectPipelineName("testPipeline");
        pipelinerunFinishedCDEvent.setSubjectErrors("pipelineErrors");

        /* Create a CloudEvent from a pipelineRunFinishedCDEvent */
        CloudEvent ceEvent = CDEvents.cdEventAsCloudEvent(pipelinerunFinishedCDEvent);

        /* This CDEvent can be sent as CloudEvent using HTTP Protocol Binding,
            Refer : https://cloudevents.github.io/sdk-java/http-basic.html
         */

    }
}

Now the CDEvent can be sent as CloudEvent using Generic HTTP Protocol Binding

Contributing

If you would like to contribute, see our development guide.

References

sdk-java's People

Contributors

rjalander avatar cdevents-bot avatar aalmiray avatar afrittoli avatar adamkenihan avatar zaza avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.