252 строки
28 KiB
YAML
252 строки
28 KiB
YAML
### YamlMime:JavaType
|
|
uid: "com.azure.core.models.CloudEvent"
|
|
fullName: "com.azure.core.models.CloudEvent"
|
|
name: "CloudEvent"
|
|
nameWithType: "CloudEvent"
|
|
summary: "Represents the Cloud<wbr>Event conforming to the 1.0 schema defined by the [Cloud Native Computing Foundation][].\n\n\n[Cloud Native Computing Foundation]: https://github.com/cloudevents/spec/blob/v1.0.1/spec.md"
|
|
inheritances:
|
|
- "<xref href=\"java.lang.Object?displayProperty=fullName\" data-throw-if-not-resolved=\"False\" />"
|
|
inheritedClassMethods:
|
|
- classRef: "java.lang.<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html\">Object</a>"
|
|
methodsRef:
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--\">clone</a>"
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-\">equals</a>"
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--\">finalize</a>"
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--\">getClass</a>"
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--\">hashCode</a>"
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--\">notify</a>"
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--\">notifyAll</a>"
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--\">toString</a>"
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--\">wait</a>"
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-\">wait</a>"
|
|
- "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-\">wait</a>"
|
|
syntax: "public final class **CloudEvent**"
|
|
constructors:
|
|
- uid: "com.azure.core.models.CloudEvent.CloudEvent(java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.models.CloudEventDataFormat,java.lang.String)"
|
|
fullName: "com.azure.core.models.CloudEvent.CloudEvent(String source, String type, BinaryData data, CloudEventDataFormat format, String dataContentType)"
|
|
name: "CloudEvent(String source, String type, BinaryData data, CloudEventDataFormat format, String dataContentType)"
|
|
nameWithType: "CloudEvent.CloudEvent(String source, String type, BinaryData data, CloudEventDataFormat format, String dataContentType)"
|
|
summary: "Create an instance of <xref uid=\"com.azure.core.models.CloudEvent\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CloudEvent\"></xref>."
|
|
parameters:
|
|
- description: "Identifies the context in which an event happened. The combination of id and source must be unique\n for each distinct event."
|
|
name: "source"
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
- description: "Type of event related to the originating occurrence."
|
|
name: "type"
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
- description: "A <xref uid=\"com.azure.core.util.BinaryData\" data-throw-if-not-resolved=\"false\" data-raw-source=\"BinaryData\"></xref> that wraps the original data, which can be a String, byte[], or model class."
|
|
name: "data"
|
|
type: "<xref href=\"com.azure.core.util.BinaryData?alt=com.azure.core.util.BinaryData&text=BinaryData\" data-throw-if-not-resolved=\"False\" />"
|
|
- description: "Set to <xref uid=\"com.azure.core.models.CloudEventDataFormat.BYTES\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CloudEventDataFormat#BYTES\"></xref> to serialize the data to base64 format, or\n <xref uid=\"com.azure.core.models.CloudEventDataFormat.JSON\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CloudEventDataFormat#JSON\"></xref> to serialize the data to JSON value."
|
|
name: "format"
|
|
type: "<xref href=\"com.azure.core.models.CloudEventDataFormat?alt=com.azure.core.models.CloudEventDataFormat&text=CloudEventDataFormat\" data-throw-if-not-resolved=\"False\" />"
|
|
- description: "The content type of the data. It has no impact on how the data is serialized but tells\n the event subscriber how to use the data. Typically the value is of MIME types such as\n \"application/json\", \"text/plain\", \"text/xml\", \"avro/binary\", etc. It can be null."
|
|
name: "dataContentType"
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
syntax: "public CloudEvent(String source, String type, BinaryData data, CloudEventDataFormat format, String dataContentType)"
|
|
desc: "Create an instance of <xref uid=\"com.azure.core.models.CloudEvent\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CloudEvent\"></xref>.\n\n`source`, `type`, `id`, and `specversion` are required attributes according to the [CNCF CloudEvent spec][]. You must set the `source` and `type` when using this constructor. For convenience, `id` and `specversion` are automatically assigned. You can change the `id` by using <xref uid=\"com.azure.core.models.CloudEvent.setId(java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#setId(String)\"></xref> after you create a CloudEvent. But you can not change `specversion` because this class is specifically for CloudEvent 1.0 schema.\n\nFor the CloudEvent data payload, this constructor accepts `data` of <xref uid=\"com.azure.core.util.BinaryData\" data-throw-if-not-resolved=\"false\" data-raw-source=\"BinaryData\"></xref> as the CloudEvent payload. The `data` can be created from objects of type String, bytes, boolean, null, array or other types. A CloudEvent will be serialized to its Json String representation to be sent out. Use param `format` to indicate whether the `data` will be serialized as bytes, or Json. When <xref uid=\"com.azure.core.models.CloudEventDataFormat.BYTES\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CloudEventDataFormat#BYTES\"></xref> is used, the data payload will be serialized to base64 bytes and stored in attribute *data\\_base64* of the CloudEvent's Json representation. When <xref uid=\"com.azure.core.models.CloudEventDataFormat.JSON\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CloudEventDataFormat#JSON\"></xref> is used, the data payload will be serialized as Json data and stored in attribute *data* of the CloudEvent's Json representation.\n\n**Create CloudEvent Samples**\n\n```java\n// Use BinaryData.fromBytes() to create data in format CloudEventDataFormat.BYTES\n byte[] exampleBytes = \"Hello World\".getBytes(StandardCharsets.UTF_8);\n CloudEvent cloudEvent = new CloudEvent(\"/cloudevents/example/source\", \"Example.EventType\",\n BinaryData.fromBytes(exampleBytes), CloudEventDataFormat.BYTES, \"application/octet-stream\");\n\n // Use BinaryData.fromObject() to create CloudEvent data in format CloudEventDataFormat.JSON\n // From a model class\n User user = new User(\"Stephen\", \"James\");\n CloudEvent cloudEventDataObject = new CloudEvent(\"/cloudevents/example/source\", \"Example.EventType\",\n BinaryData.fromObject(user), CloudEventDataFormat.JSON, \"application/json\");\n\n // From a String\n CloudEvent cloudEventDataStr = new CloudEvent(\"/cloudevents/example/source\", \"Example.EventType\",\n BinaryData.fromObject(\"Hello World\"), CloudEventDataFormat.JSON, \"text/plain\");\n\n // From an Integer\n CloudEvent cloudEventDataInt = new CloudEvent(\"/cloudevents/example/source\", \"Example.EventType\",\n BinaryData.fromObject(1), CloudEventDataFormat.JSON, \"int\");\n\n // From a Boolean\n CloudEvent cloudEventDataBool = new CloudEvent(\"/cloudevents/example/source\", \"Example.EventType\",\n BinaryData.fromObject(true), CloudEventDataFormat.JSON, \"bool\");\n\n // From null\n CloudEvent cloudEventDataNull = new CloudEvent(\"/cloudevents/example/source\", \"Example.EventType\",\n BinaryData.fromObject(null), CloudEventDataFormat.JSON, \"null\");\n\n // Use BinaryData.fromString() if you have a Json String for the CloudEvent data.\n String jsonStringForData = \"\\\"Hello World\\\"\"; // A json String.\n CloudEvent cloudEventDataJsonStr = new CloudEvent(\"/cloudevents/example/source\", \"Example.EventType\",\n BinaryData.fromString(jsonStringForData), CloudEventDataFormat.JSON, \"text/plain\");\n```\n\n\n[CNCF CloudEvent spec]: https://github.com/cloudevents/spec/blob/v1.0.1/spec.md"
|
|
methods:
|
|
- uid: "com.azure.core.models.CloudEvent.addExtensionAttribute(java.lang.String,java.lang.Object)"
|
|
fullName: "com.azure.core.models.CloudEvent.addExtensionAttribute(String name, Object value)"
|
|
name: "addExtensionAttribute(String name, Object value)"
|
|
nameWithType: "CloudEvent.addExtensionAttribute(String name, Object value)"
|
|
summary: "Add/Overwrite a single extension attribute to the cloud event."
|
|
parameters:
|
|
- description: "the name of the attribute. It must contains only lower-case alphanumeric characters and not be be any\n CloudEvent reserved attribute names."
|
|
name: "name"
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
- description: "the value to associate with the name."
|
|
name: "value"
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html\">Object</a>"
|
|
syntax: "public CloudEvent addExtensionAttribute(String name, Object value)"
|
|
desc: "Add/Overwrite a single extension attribute to the cloud event."
|
|
returns:
|
|
description: "the cloud event itself."
|
|
type: "<xref href=\"com.azure.core.models.CloudEvent?alt=com.azure.core.models.CloudEvent&text=CloudEvent\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.core.models.CloudEvent.fromString(java.lang.String)"
|
|
fullName: "com.azure.core.models.CloudEvent.fromString(String cloudEventsJson)"
|
|
name: "fromString(String cloudEventsJson)"
|
|
nameWithType: "CloudEvent.fromString(String cloudEventsJson)"
|
|
summary: "Deserialize <xref uid=\"com.azure.core.models.CloudEvent\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CloudEvent\"></xref> JSON string representation that has one Cloud<wbr>Event object or an array of Cloud<wbr>Event objects into a list of Cloud<wbr>Events, and validate whether any Cloud<wbr>Events have null `id`, `source`, or `type`."
|
|
modifiers:
|
|
- "static"
|
|
parameters:
|
|
- description: "the JSON payload containing one or more events."
|
|
name: "cloudEventsJson"
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
syntax: "public static List<CloudEvent> fromString(String cloudEventsJson)"
|
|
desc: "Deserialize <xref uid=\"com.azure.core.models.CloudEvent\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CloudEvent\"></xref> JSON string representation that has one CloudEvent object or an array of CloudEvent objects into a list of CloudEvents, and validate whether any CloudEvents have null `id`, `source`, or `type`. If you want to skip this validation, use <xref uid=\"com.azure.core.models.CloudEvent.fromString(java.lang.String,boolean)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#fromString(String, boolean)\"></xref>.\n\n**Deserialize CloudEvent Samples**\n\n```java\nList<CloudEvent> cloudEventList = CloudEvent.fromString(cloudEventJsonString);\n CloudEvent cloudEvent = cloudEventList.get(0);\n BinaryData cloudEventData = cloudEvent.getData();\n\n byte[] bytesValue = cloudEventData.toBytes(); // If data payload is in bytes (data_base64 is not null).\n User objectValue = cloudEventData.toObject(User.class); // If data payload is a User object.\n int intValue = cloudEventData.toObject(Integer.class); // If data payload is an int.\n boolean boolValue = cloudEventData.toObject(Boolean.class); // If data payload is boolean.\n String stringValue = cloudEventData.toObject(String.class); // If data payload is String.\n String jsonStringValue = cloudEventData.toString(); // The data payload represented in Json String.\n```"
|
|
returns:
|
|
description: "all of the events in the payload deserialized as <xref uid=\"com.azure.core.models.CloudEvent\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CloudEvents\"></xref>."
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/util/List.html\">List</a><<xref href=\"com.azure.core.models.CloudEvent?alt=com.azure.core.models.CloudEvent&text=CloudEvent\" data-throw-if-not-resolved=\"False\" />>"
|
|
- uid: "com.azure.core.models.CloudEvent.fromString(java.lang.String,boolean)"
|
|
fullName: "com.azure.core.models.CloudEvent.fromString(String cloudEventsJson, boolean skipValidation)"
|
|
name: "fromString(String cloudEventsJson, boolean skipValidation)"
|
|
nameWithType: "CloudEvent.fromString(String cloudEventsJson, boolean skipValidation)"
|
|
summary: "Deserialize <xref uid=\"com.azure.core.models.CloudEvent\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CloudEvents\"></xref> JSON string representation that has one Cloud<wbr>Event object or an array of Cloud<wbr>Event objects into a list of Cloud<wbr>Events."
|
|
modifiers:
|
|
- "static"
|
|
parameters:
|
|
- description: "the JSON payload containing one or more events."
|
|
name: "cloudEventsJson"
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
- description: "set to true if you'd like to skip the validation for the deserialized CloudEvents. A valid\n CloudEvent should have 'id', 'source' and 'type' not null."
|
|
name: "skipValidation"
|
|
type: "<xref href=\"boolean?alt=boolean&text=boolean\" data-throw-if-not-resolved=\"False\" />"
|
|
syntax: "public static List<CloudEvent> fromString(String cloudEventsJson, boolean skipValidation)"
|
|
desc: "Deserialize <xref uid=\"com.azure.core.models.CloudEvent\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CloudEvents\"></xref> JSON string representation that has one CloudEvent object or an array of CloudEvent objects into a list of CloudEvents."
|
|
returns:
|
|
description: "all of the events in the payload deserialized as <xref uid=\"com.azure.core.models.CloudEvent\" data-throw-if-not-resolved=\"false\" data-raw-source=\"CloudEvents\"></xref>."
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/util/List.html\">List</a><<xref href=\"com.azure.core.models.CloudEvent?alt=com.azure.core.models.CloudEvent&text=CloudEvent\" data-throw-if-not-resolved=\"False\" />>"
|
|
- uid: "com.azure.core.models.CloudEvent.getData()"
|
|
fullName: "com.azure.core.models.CloudEvent.getData()"
|
|
name: "getData()"
|
|
nameWithType: "CloudEvent.getData()"
|
|
summary: "Get the data associated with this event as a <xref uid=\"com.azure.core.util.BinaryData\" data-throw-if-not-resolved=\"false\" data-raw-source=\"BinaryData\"></xref>, which has API to deserialize the data into a String, an Object, or a byte\\[\\]."
|
|
syntax: "public BinaryData getData()"
|
|
desc: "Get the data associated with this event as a <xref uid=\"com.azure.core.util.BinaryData\" data-throw-if-not-resolved=\"false\" data-raw-source=\"BinaryData\"></xref>, which has API to deserialize the data into a String, an Object, or a byte\\[\\]."
|
|
returns:
|
|
description: "A <xref uid=\"com.azure.core.util.BinaryData\" data-throw-if-not-resolved=\"false\" data-raw-source=\"BinaryData\"></xref> that wraps the this event's data payload."
|
|
type: "<xref href=\"com.azure.core.util.BinaryData?alt=com.azure.core.util.BinaryData&text=BinaryData\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.core.models.CloudEvent.getDataContentType()"
|
|
fullName: "com.azure.core.models.CloudEvent.getDataContentType()"
|
|
name: "getDataContentType()"
|
|
nameWithType: "CloudEvent.getDataContentType()"
|
|
summary: "Get the content MIME type that the data is in."
|
|
syntax: "public String getDataContentType()"
|
|
desc: "Get the content MIME type that the data is in."
|
|
returns:
|
|
description: "the content type the data is in, or null it is not set."
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
- uid: "com.azure.core.models.CloudEvent.getDataSchema()"
|
|
fullName: "com.azure.core.models.CloudEvent.getDataSchema()"
|
|
name: "getDataSchema()"
|
|
nameWithType: "CloudEvent.getDataSchema()"
|
|
summary: "Get the schema that the data adheres to."
|
|
syntax: "public String getDataSchema()"
|
|
desc: "Get the schema that the data adheres to."
|
|
returns:
|
|
description: "a URI of the data schema, or null if it is not set."
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
- uid: "com.azure.core.models.CloudEvent.getExtensionAttributes()"
|
|
fullName: "com.azure.core.models.CloudEvent.getExtensionAttributes()"
|
|
name: "getExtensionAttributes()"
|
|
nameWithType: "CloudEvent.getExtensionAttributes()"
|
|
summary: "Get a map of the additional user-defined attributes associated with this event."
|
|
syntax: "public Map<String,Object> getExtensionAttributes()"
|
|
desc: "Get a map of the additional user-defined attributes associated with this event."
|
|
returns:
|
|
description: "an unmodifiable map of the extension attributes."
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/util/Map.html\">Map</a><<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>,<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html\">Object</a>>"
|
|
- uid: "com.azure.core.models.CloudEvent.getId()"
|
|
fullName: "com.azure.core.models.CloudEvent.getId()"
|
|
name: "getId()"
|
|
nameWithType: "CloudEvent.getId()"
|
|
summary: "Get the id of the cloud event."
|
|
syntax: "public String getId()"
|
|
desc: "Get the id of the cloud event."
|
|
returns:
|
|
description: "the id."
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
- uid: "com.azure.core.models.CloudEvent.getSource()"
|
|
fullName: "com.azure.core.models.CloudEvent.getSource()"
|
|
name: "getSource()"
|
|
nameWithType: "CloudEvent.getSource()"
|
|
summary: "Get the source of the event."
|
|
syntax: "public String getSource()"
|
|
desc: "Get the source of the event."
|
|
returns:
|
|
description: "the source."
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
- uid: "com.azure.core.models.CloudEvent.getSubject()"
|
|
fullName: "com.azure.core.models.CloudEvent.getSubject()"
|
|
name: "getSubject()"
|
|
nameWithType: "CloudEvent.getSubject()"
|
|
summary: "Get the subject associated with this event."
|
|
syntax: "public String getSubject()"
|
|
desc: "Get the subject associated with this event."
|
|
returns:
|
|
description: "the subject, or null if it is not set."
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
- uid: "com.azure.core.models.CloudEvent.getTime()"
|
|
fullName: "com.azure.core.models.CloudEvent.getTime()"
|
|
name: "getTime()"
|
|
nameWithType: "CloudEvent.getTime()"
|
|
summary: "Get the time associated with the occurrence of the event."
|
|
syntax: "public OffsetDateTime getTime()"
|
|
desc: "Get the time associated with the occurrence of the event."
|
|
returns:
|
|
description: "the event time, or null if the time is not set."
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html\">OffsetDateTime</a>"
|
|
- uid: "com.azure.core.models.CloudEvent.getType()"
|
|
fullName: "com.azure.core.models.CloudEvent.getType()"
|
|
name: "getType()"
|
|
nameWithType: "CloudEvent.getType()"
|
|
summary: "Get the type of event, e.<wbr>g."
|
|
syntax: "public String getType()"
|
|
desc: "Get the type of event, e.g. \"Contoso.Items.ItemReceived\"."
|
|
returns:
|
|
description: "the type of the event."
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
- uid: "com.azure.core.models.CloudEvent.setDataSchema(java.lang.String)"
|
|
fullName: "com.azure.core.models.CloudEvent.setDataSchema(String dataSchema)"
|
|
name: "setDataSchema(String dataSchema)"
|
|
nameWithType: "CloudEvent.setDataSchema(String dataSchema)"
|
|
summary: "Set the schema that the data adheres to."
|
|
parameters:
|
|
- description: "a String identifying the schema of the data. The <a href=\"https://github.com/cloudevents/spec/blob/v1.0.1/spec.md#dataschema\">\n CNCF CloudEvent spec dataschema</a> is defined as a URI. For compatibility with legacy system, this class\n accepts any String. But for interoperability, you should use a URI format string."
|
|
name: "dataSchema"
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
syntax: "public CloudEvent setDataSchema(String dataSchema)"
|
|
desc: "Set the schema that the data adheres to."
|
|
returns:
|
|
description: "the cloud event itself."
|
|
type: "<xref href=\"com.azure.core.models.CloudEvent?alt=com.azure.core.models.CloudEvent&text=CloudEvent\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.core.models.CloudEvent.setId(java.lang.String)"
|
|
fullName: "com.azure.core.models.CloudEvent.setId(String id)"
|
|
name: "setId(String id)"
|
|
nameWithType: "CloudEvent.setId(String id)"
|
|
summary: "Set a custom id."
|
|
parameters:
|
|
- description: "the id to set."
|
|
name: "id"
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
syntax: "public CloudEvent setId(String id)"
|
|
desc: "Set a custom id. Note that a random id is already set by default."
|
|
returns:
|
|
description: "the cloud event itself."
|
|
type: "<xref href=\"com.azure.core.models.CloudEvent?alt=com.azure.core.models.CloudEvent&text=CloudEvent\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.core.models.CloudEvent.setSubject(java.lang.String)"
|
|
fullName: "com.azure.core.models.CloudEvent.setSubject(String subject)"
|
|
name: "setSubject(String subject)"
|
|
nameWithType: "CloudEvent.setSubject(String subject)"
|
|
summary: "Set the subject of the event."
|
|
parameters:
|
|
- description: "the subject to set."
|
|
name: "subject"
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
|
|
syntax: "public CloudEvent setSubject(String subject)"
|
|
desc: "Set the subject of the event."
|
|
returns:
|
|
description: "the cloud event itself."
|
|
type: "<xref href=\"com.azure.core.models.CloudEvent?alt=com.azure.core.models.CloudEvent&text=CloudEvent\" data-throw-if-not-resolved=\"False\" />"
|
|
- uid: "com.azure.core.models.CloudEvent.setTime(java.time.OffsetDateTime)"
|
|
fullName: "com.azure.core.models.CloudEvent.setTime(OffsetDateTime time)"
|
|
name: "setTime(OffsetDateTime time)"
|
|
nameWithType: "CloudEvent.setTime(OffsetDateTime time)"
|
|
summary: "Set the time associated with the occurrence of the event."
|
|
parameters:
|
|
- description: "the time to set."
|
|
name: "time"
|
|
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html\">OffsetDateTime</a>"
|
|
syntax: "public CloudEvent setTime(OffsetDateTime time)"
|
|
desc: "Set the time associated with the occurrence of the event."
|
|
returns:
|
|
description: "the cloud event itself."
|
|
type: "<xref href=\"com.azure.core.models.CloudEvent?alt=com.azure.core.models.CloudEvent&text=CloudEvent\" data-throw-if-not-resolved=\"False\" />"
|
|
type: "class"
|
|
desc: "Represents the CloudEvent conforming to the 1.0 schema defined by the [Cloud Native Computing Foundation][]. CloudEvents is a specification for describing event data in common formats to provide interoperability across services, platforms and systems. \n\nSome Azure services, for instance, EventGrid, are compatible with this specification. You can use this class to communicate with these Azure services.\n\nDepending on your scenario, you can either use the constructor <xref uid=\"com.azure.core.models.CloudEvent.CloudEvent(java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.models.CloudEventDataFormat,java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#CloudEvent(String, String, BinaryData, CloudEventDataFormat, String)\"></xref> to create a CloudEvent, or use the factory method <xref uid=\"com.azure.core.models.CloudEvent.fromString(java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#fromString(String)\"></xref> to deserialize CloudEvent instances from a Json String representation of CloudEvents.\n\nIf you have the data payload of a CloudEvent and want to send it out, use the constructor <xref uid=\"com.azure.core.models.CloudEvent.CloudEvent(java.lang.String,java.lang.String,com.azure.core.util.BinaryData,com.azure.core.models.CloudEventDataFormat,java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#CloudEvent(String, String, BinaryData, CloudEventDataFormat, String)\"></xref> to create it. Then you can serialize the CloudEvent into its Json String representation and send it.\n\n**Create CloudEvent Samples**\n\n```java\n// Use BinaryData.fromBytes() to create data in format CloudEventDataFormat.BYTES\n byte[] exampleBytes = \"Hello World\".getBytes(StandardCharsets.UTF_8);\n CloudEvent cloudEvent = new CloudEvent(\"/cloudevents/example/source\", \"Example.EventType\",\n BinaryData.fromBytes(exampleBytes), CloudEventDataFormat.BYTES, \"application/octet-stream\");\n\n // Use BinaryData.fromObject() to create CloudEvent data in format CloudEventDataFormat.JSON\n // From a model class\n User user = new User(\"Stephen\", \"James\");\n CloudEvent cloudEventDataObject = new CloudEvent(\"/cloudevents/example/source\", \"Example.EventType\",\n BinaryData.fromObject(user), CloudEventDataFormat.JSON, \"application/json\");\n\n // From a String\n CloudEvent cloudEventDataStr = new CloudEvent(\"/cloudevents/example/source\", \"Example.EventType\",\n BinaryData.fromObject(\"Hello World\"), CloudEventDataFormat.JSON, \"text/plain\");\n\n // From an Integer\n CloudEvent cloudEventDataInt = new CloudEvent(\"/cloudevents/example/source\", \"Example.EventType\",\n BinaryData.fromObject(1), CloudEventDataFormat.JSON, \"int\");\n\n // From a Boolean\n CloudEvent cloudEventDataBool = new CloudEvent(\"/cloudevents/example/source\", \"Example.EventType\",\n BinaryData.fromObject(true), CloudEventDataFormat.JSON, \"bool\");\n\n // From null\n CloudEvent cloudEventDataNull = new CloudEvent(\"/cloudevents/example/source\", \"Example.EventType\",\n BinaryData.fromObject(null), CloudEventDataFormat.JSON, \"null\");\n\n // Use BinaryData.fromString() if you have a Json String for the CloudEvent data.\n String jsonStringForData = \"\\\"Hello World\\\"\"; // A json String.\n CloudEvent cloudEventDataJsonStr = new CloudEvent(\"/cloudevents/example/source\", \"Example.EventType\",\n BinaryData.fromString(jsonStringForData), CloudEventDataFormat.JSON, \"text/plain\");\n```\n\nOn the contrary, if you receive CloudEvents and have the Json string representation of one or more of CloudEvents, use <xref uid=\"com.azure.core.models.CloudEvent.fromString(java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#fromString(String)\"></xref> to deserialize them from the Json string.\n\n**Deserialize CloudEvent Samples**\n\n```java\nList<CloudEvent> cloudEventList = CloudEvent.fromString(cloudEventJsonString);\n CloudEvent cloudEvent = cloudEventList.get(0);\n BinaryData cloudEventData = cloudEvent.getData();\n\n byte[] bytesValue = cloudEventData.toBytes(); // If data payload is in bytes (data_base64 is not null).\n User objectValue = cloudEventData.toObject(User.class); // If data payload is a User object.\n int intValue = cloudEventData.toObject(Integer.class); // If data payload is an int.\n boolean boolValue = cloudEventData.toObject(Boolean.class); // If data payload is boolean.\n String stringValue = cloudEventData.toObject(String.class); // If data payload is String.\n String jsonStringValue = cloudEventData.toString(); // The data payload represented in Json String.\n```\n\n\n[Cloud Native Computing Foundation]: https://github.com/cloudevents/spec/blob/v1.0.1/spec.md"
|
|
metadata: {}
|
|
package: "com.azure.core.models"
|
|
artifact: com.azure:azure-core:1.37.0
|