@Override public Map<String, Object> toQuery() { Map<String, Object> result = new HashMap<>(); optionallyAdd(result, "node", getNodeFilter()); optionallyAdd(result, "service", getServiceFilter()); optionallyAdd(result, "tag", getTagFilter()); optionallyAdd(result, "dc", getDatacenter()); return result; } }
/** * Fires a Consul event. * * PUT /v1/event/fire/{name} * * @param name The name of the event. * @param eventOptions The event specific options to use. * @param payload Optional string payload. * @return The newly created {@link com.orbitz.consul.model.event.Event}. */ public Event fireEvent(String name, EventOptions eventOptions, String payload) { return http.extract(api.fireEvent(name, RequestBody.create(MediaType.parse("text/plain"), payload), eventOptions.toQuery())); }
/** * Fires a Consul event. * * PUT /v1/event/fire/{name} * * @param name The name of the event. * @param eventOptions The event specific options to use. * @return The newly created {@link com.orbitz.consul.model.event.Event}. */ public Event fireEvent(String name, EventOptions eventOptions) { return http.extract(api.fireEvent(name, eventOptions.toQuery())); }
/** * Fill a builder with attribute values from the provided {@code EventOptions} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(EventOptions instance) { Preconditions.checkNotNull(instance, "instance"); Optional<String> datacenterOptional = instance.getDatacenter(); if (datacenterOptional.isPresent()) { datacenter(datacenterOptional); } Optional<String> nodeFilterOptional = instance.getNodeFilter(); if (nodeFilterOptional.isPresent()) { nodeFilter(nodeFilterOptional); } Optional<String> serviceFilterOptional = instance.getServiceFilter(); if (serviceFilterOptional.isPresent()) { serviceFilter(serviceFilterOptional); } Optional<String> tagFilterOptional = instance.getTagFilter(); if (tagFilterOptional.isPresent()) { tagFilter(tagFilterOptional); } return this; }