azure-docs-sdk-java/docs-ref-autogen/com.azure.messaging.eventgr...

177 строки
18 KiB
YAML

### YamlMime:JavaType
uid: "com.azure.messaging.eventgrid.EventGridEvent"
fullName: "com.azure.messaging.eventgrid.EventGridEvent"
name: "EventGridEvent"
nameWithType: "EventGridEvent"
summary: "Represents the Event<wbr>Grid event conforming to the [ EventGrid event schema][EventGrid event schema].\n\n\n[EventGrid event schema]: https://docs.microsoft.com/azure/event-grid/event-schema"
inheritances:
- "<xref href=\"java.lang.Object?displayProperty=fullName\" data-throw-if-not-resolved=\"False\" />"
inheritedMembers:
- "java.lang.Object.clone()"
- "java.lang.Object.equals(java.lang.Object)"
- "java.lang.Object.finalize()"
- "java.lang.Object.getClass()"
- "java.lang.Object.hashCode()"
- "java.lang.Object.notify()"
- "java.lang.Object.notifyAll()"
- "java.lang.Object.toString()"
- "java.lang.Object.wait()"
- "java.lang.Object.wait(long)"
- "java.lang.Object.wait(long,int)"
syntax: "public final class EventGridEvent"
constructors:
- uid: "com.azure.messaging.eventgrid.EventGridEvent.EventGridEvent(java.lang.String,java.lang.String,com.azure.core.util.BinaryData,java.lang.String)"
fullName: "com.azure.messaging.eventgrid.EventGridEvent.EventGridEvent(String subject, String eventType, BinaryData data, String dataVersion)"
name: "EventGridEvent(String subject, String eventType, BinaryData data, String dataVersion)"
nameWithType: "EventGridEvent.EventGridEvent(String subject, String eventType, BinaryData data, String dataVersion)"
summary: "Create a new instance of the Event<wbr>Grid<wbr>Event, with the given required fields."
parameters:
- description: "the subject of the event."
name: "subject"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "the type of the event, e.g. \"Contoso.Items.ItemReceived\"."
name: "eventType"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- description: "the data associated with this event. The content of this <xref uid=\"com.azure.core.util.BinaryData\" data-throw-if-not-resolved=\"false\" data-raw-source=\"BinaryData\"></xref> must be a Json value."
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: "the version of the data sent along with the event."
name: "dataVersion"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
syntax: "public EventGridEvent(String subject, String eventType, BinaryData data, String dataVersion)"
desc: "Create a new instance of the EventGridEvent, with the given required fields.\n\n**Create EventGridEvent Samples**\n\n```java\n// Use BinaryData.fromObject() to create EventGridEvent data\n // From a model class\n User user = new User(\"Stephen\", \"James\");\n EventGridEvent eventGridEventDataObject = new EventGridEvent(\"/EventGridEvents/example/source\",\n \"Example.EventType\", BinaryData.fromObject(user), \"0.1\");\n\n // From a String\n EventGridEvent eventGridEventDataStr = new EventGridEvent(\"/EventGridEvents/example/source\",\n \"Example.EventType\", BinaryData.fromObject(\"Hello World\"), \"0.1\");\n\n // From an Integer\n EventGridEvent eventGridEventDataInt = new EventGridEvent(\"/EventGridEvents/example/source\",\n \"Example.EventType\", BinaryData.fromObject(1), \"0.1\");\n\n // From a Boolean\n EventGridEvent eventGridEventDataBool = new EventGridEvent(\"/EventGridEvents/example/source\",\n \"Example.EventType\", BinaryData.fromObject(true), \"0.1\");\n\n // From null\n EventGridEvent eventGridEventDataNull = new EventGridEvent(\"/EventGridEvents/example/source\",\n \"Example.EventType\", BinaryData.fromObject(null), \"0.1\");\n\n // Use BinaryData.fromString() if you have a Json String for the EventGridEvent data.\n String jsonStringForData = \"\\\"Hello World\\\"\"; // A json String.\n EventGridEvent eventGridEventDataDataJsonStr = new EventGridEvent(\"/EventGridEvents/example/source\",\n \"Example.EventType\", BinaryData.fromString(jsonStringForData), \"0.1\");\n```"
methods:
- uid: "com.azure.messaging.eventgrid.EventGridEvent.fromString(java.lang.String)"
fullName: "com.azure.messaging.eventgrid.EventGridEvent.fromString(String eventGridJsonString)"
name: "fromString(String eventGridJsonString)"
nameWithType: "EventGridEvent.fromString(String eventGridJsonString)"
summary: "Deserialize <xref uid=\"com.azure.messaging.eventgrid.EventGridEvent\" data-throw-if-not-resolved=\"false\" data-raw-source=\"EventGridEvent\"></xref> JSON string representation that has one Event<wbr>Grid<wbr>Event object or an array of Cloud<wbr>Event objects into a list of Event<wbr>Grid<wbr>Events."
modifiers:
- "static"
parameters:
- description: "the JSON string containing one or more EventGridEvent objects."
name: "eventGridJsonString"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
syntax: "public static List<EventGridEvent> fromString(String eventGridJsonString)"
desc: "Deserialize <xref uid=\"com.azure.messaging.eventgrid.EventGridEvent\" data-throw-if-not-resolved=\"false\" data-raw-source=\"EventGridEvent\"></xref> JSON string representation that has one EventGridEvent object or an array of CloudEvent objects into a list of EventGridEvents.\n\n**Deserialize EventGridEvent Samples**\n\n```java\nList<EventGridEvent> eventGridEventList = EventGridEvent.fromString(eventGridEventJsonString);\n EventGridEvent eventGridEvent = eventGridEventList.get(0);\n BinaryData eventGridEventData = eventGridEvent.getData();\n\n User objectValue = eventGridEventData.toObject(User.class); // If data payload is a User object.\n int intValue = eventGridEventData.toObject(Integer.class); // If data payload is an int.\n boolean boolValue = eventGridEventData.toObject(Boolean.class); // If data payload is boolean.\n String stringValue = eventGridEventData.toObject(String.class); // If data payload is String.\n String jsonStringValue = eventGridEventData.toString(); // The data payload represented in Json String.\n```"
returns:
description: "A list of <xref uid=\"com.azure.messaging.eventgrid.EventGridEvent\" data-throw-if-not-resolved=\"false\" data-raw-source=\"EventGridEvents\"></xref> deserialized from eventGridJsonString."
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/util/List.html\">List</a>&lt;<xref href=\"com.azure.messaging.eventgrid.EventGridEvent?alt=com.azure.messaging.eventgrid.EventGridEvent&text=EventGridEvent\" data-throw-if-not-resolved=\"False\" />&gt;"
- uid: "com.azure.messaging.eventgrid.EventGridEvent.getData()"
fullName: "com.azure.messaging.eventgrid.EventGridEvent.getData()"
name: "getData()"
nameWithType: "EventGridEvent.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 to any objects by using <xref uid=\"com.azure.core.util.BinaryData.toObject*\" data-throw-if-not-resolved=\"false\" data-raw-source=\"BinaryData#toObject(TypeReference)\"></xref>."
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 to any objects by using <xref uid=\"com.azure.core.util.BinaryData.toObject*\" data-throw-if-not-resolved=\"false\" data-raw-source=\"BinaryData#toObject(TypeReference)\"></xref>."
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.messaging.eventgrid.EventGridEvent.getDataVersion()"
fullName: "com.azure.messaging.eventgrid.EventGridEvent.getDataVersion()"
name: "getDataVersion()"
nameWithType: "EventGridEvent.getDataVersion()"
summary: "Get the version of the data in the event."
syntax: "public String getDataVersion()"
desc: "Get the version of the data in the event. This can be used to specify versioning of event data schemas over time."
returns:
description: "the version of the event data."
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- uid: "com.azure.messaging.eventgrid.EventGridEvent.getEventTime()"
fullName: "com.azure.messaging.eventgrid.EventGridEvent.getEventTime()"
name: "getEventTime()"
nameWithType: "EventGridEvent.getEventTime()"
summary: "Get the time associated with the occurrence of this event."
syntax: "public OffsetDateTime getEventTime()"
desc: "Get the time associated with the occurrence of this event."
returns:
description: "the event time."
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/time/OffsetDateTime.html\">OffsetDateTime</a>"
- uid: "com.azure.messaging.eventgrid.EventGridEvent.getEventType()"
fullName: "com.azure.messaging.eventgrid.EventGridEvent.getEventType()"
name: "getEventType()"
nameWithType: "EventGridEvent.getEventType()"
summary: "Get the type of this event."
syntax: "public String getEventType()"
desc: "Get the type of this event."
returns:
description: "the event type."
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- uid: "com.azure.messaging.eventgrid.EventGridEvent.getId()"
fullName: "com.azure.messaging.eventgrid.EventGridEvent.getId()"
name: "getId()"
nameWithType: "EventGridEvent.getId()"
summary: "Get the unique id associated with this event."
syntax: "public String getId()"
desc: "Get the unique id associated with this 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.messaging.eventgrid.EventGridEvent.getSubject()"
fullName: "com.azure.messaging.eventgrid.EventGridEvent.getSubject()"
name: "getSubject()"
nameWithType: "EventGridEvent.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."
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- uid: "com.azure.messaging.eventgrid.EventGridEvent.getTopic()"
fullName: "com.azure.messaging.eventgrid.EventGridEvent.getTopic()"
name: "getTopic()"
nameWithType: "EventGridEvent.getTopic()"
summary: "Get the topic associated with this event if it is associated with a domain."
syntax: "public String getTopic()"
desc: "Get the topic associated with this event if it is associated with a domain."
returns:
description: "the topic, or null if the topic is not set."
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
- uid: "com.azure.messaging.eventgrid.EventGridEvent.setEventTime(java.time.OffsetDateTime)"
fullName: "com.azure.messaging.eventgrid.EventGridEvent.setEventTime(OffsetDateTime time)"
name: "setEventTime(OffsetDateTime time)"
nameWithType: "EventGridEvent.setEventTime(OffsetDateTime time)"
summary: "Set the time associated with 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 EventGridEvent setEventTime(OffsetDateTime time)"
desc: "Set the time associated with the event. Note that a default time has already been set when the event was constructed."
returns:
description: "the event itself."
type: "<xref href=\"com.azure.messaging.eventgrid.EventGridEvent?alt=com.azure.messaging.eventgrid.EventGridEvent&text=EventGridEvent\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.messaging.eventgrid.EventGridEvent.setId(java.lang.String)"
fullName: "com.azure.messaging.eventgrid.EventGridEvent.setId(String id)"
name: "setId(String id)"
nameWithType: "EventGridEvent.setId(String id)"
summary: "Set the unique id of the event."
parameters:
- description: "the unique id to set."
name: "id"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
syntax: "public EventGridEvent setId(String id)"
desc: "Set the unique id of the event. Note that a random id has already been set by default."
returns:
description: "the event itself."
type: "<xref href=\"com.azure.messaging.eventgrid.EventGridEvent?alt=com.azure.messaging.eventgrid.EventGridEvent&text=EventGridEvent\" data-throw-if-not-resolved=\"False\" />"
- uid: "com.azure.messaging.eventgrid.EventGridEvent.setTopic(java.lang.String)"
fullName: "com.azure.messaging.eventgrid.EventGridEvent.setTopic(String topic)"
name: "setTopic(String topic)"
nameWithType: "EventGridEvent.setTopic(String topic)"
summary: "Set the topic associated with this event."
parameters:
- description: "the topic to set."
name: "topic"
type: "<a href=\"https://docs.oracle.com/javase/8/docs/api/java/lang/String.html\">String</a>"
syntax: "public EventGridEvent setTopic(String topic)"
desc: "Set the topic associated with this event. Used to route events from domain endpoints."
returns:
description: "the event itself."
type: "<xref href=\"com.azure.messaging.eventgrid.EventGridEvent?alt=com.azure.messaging.eventgrid.EventGridEvent&text=EventGridEvent\" data-throw-if-not-resolved=\"False\" />"
type: "class"
desc: "Represents the EventGrid event conforming to the [ EventGrid event schema][EventGrid event schema].\n\nDepending on your scenario, you can either use the constructor <xref uid=\"com.azure.messaging.eventgrid.EventGridEvent.EventGridEvent(java.lang.String,java.lang.String,com.azure.core.util.BinaryData,java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#EventGridEvent(String, String, BinaryData, String)\"></xref> to create an EventGridEvent, or use the factory method <xref uid=\"com.azure.messaging.eventgrid.EventGridEvent.fromString(java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#fromString(String)\"></xref> to deserialize EventGridEvent instances from a Json String representation of EventGrid events.\n\nIf you have the data payload of an EventGridEvent and want to send it out, use the constructor <xref uid=\"com.azure.messaging.eventgrid.EventGridEvent.EventGridEvent(java.lang.String,java.lang.String,com.azure.core.util.BinaryData,java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"#EventGridEvent(String, String, BinaryData, String)\"></xref> to create it. Then use <xref uid=\"com.azure.messaging.eventgrid.EventGridPublisherAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"EventGridPublisherAsyncClient\"></xref> or <xref uid=\"com.azure.messaging.eventgrid.EventGridPublisherClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"EventGridPublisherClient\"></xref> to send it the EventGrid service.\n\n**Create EventGridEvent Samples**\n\n```java\n// Use BinaryData.fromObject() to create EventGridEvent data\n // From a model class\n User user = new User(\"Stephen\", \"James\");\n EventGridEvent eventGridEventDataObject = new EventGridEvent(\"/EventGridEvents/example/source\",\n \"Example.EventType\", BinaryData.fromObject(user), \"0.1\");\n\n // From a String\n EventGridEvent eventGridEventDataStr = new EventGridEvent(\"/EventGridEvents/example/source\",\n \"Example.EventType\", BinaryData.fromObject(\"Hello World\"), \"0.1\");\n\n // From an Integer\n EventGridEvent eventGridEventDataInt = new EventGridEvent(\"/EventGridEvents/example/source\",\n \"Example.EventType\", BinaryData.fromObject(1), \"0.1\");\n\n // From a Boolean\n EventGridEvent eventGridEventDataBool = new EventGridEvent(\"/EventGridEvents/example/source\",\n \"Example.EventType\", BinaryData.fromObject(true), \"0.1\");\n\n // From null\n EventGridEvent eventGridEventDataNull = new EventGridEvent(\"/EventGridEvents/example/source\",\n \"Example.EventType\", BinaryData.fromObject(null), \"0.1\");\n\n // Use BinaryData.fromString() if you have a Json String for the EventGridEvent data.\n String jsonStringForData = \"\\\"Hello World\\\"\"; // A json String.\n EventGridEvent eventGridEventDataDataJsonStr = new EventGridEvent(\"/EventGridEvents/example/source\",\n \"Example.EventType\", BinaryData.fromString(jsonStringForData), \"0.1\");\n```\n\nOn the contrary, if you receive events from any event handlers and therefore have the Json string representation of one or more of EventGridEvents, use <xref uid=\"com.azure.messaging.eventgrid.EventGridEvent.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 EventGridEvent Samples**\n\n```java\nList<EventGridEvent> eventGridEventList = EventGridEvent.fromString(eventGridEventJsonString);\n EventGridEvent eventGridEvent = eventGridEventList.get(0);\n BinaryData eventGridEventData = eventGridEvent.getData();\n\n User objectValue = eventGridEventData.toObject(User.class); // If data payload is a User object.\n int intValue = eventGridEventData.toObject(Integer.class); // If data payload is an int.\n boolean boolValue = eventGridEventData.toObject(Boolean.class); // If data payload is boolean.\n String stringValue = eventGridEventData.toObject(String.class); // If data payload is String.\n String jsonStringValue = eventGridEventData.toString(); // The data payload represented in Json String.\n```\n\n\n[EventGrid event schema]: https://docs.microsoft.com/azure/event-grid/event-schema"
metadata: {}
package: "com.azure.messaging.eventgrid"
artifact: com.azure:azure-messaging-eventgrid:4.12.2