|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | +package org.apache.beam.it.datadog; |
| 19 | + |
| 20 | +import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkNotNull; |
| 21 | + |
| 22 | +import com.google.auto.value.AutoValue; |
| 23 | +import javax.annotation.Nullable; |
| 24 | + |
| 25 | +/** A class for Datadog log entries, copy of DatadogEvent. */ |
| 26 | +@AutoValue |
| 27 | +public abstract class DatadogLogEntry { |
| 28 | + |
| 29 | + public static Builder newBuilder() { |
| 30 | + return new AutoValue_DatadogLogEntry.Builder(); |
| 31 | + } |
| 32 | + |
| 33 | + @Nullable |
| 34 | + public abstract String ddsource(); |
| 35 | + |
| 36 | + @Nullable |
| 37 | + public abstract String ddtags(); |
| 38 | + |
| 39 | + @Nullable |
| 40 | + public abstract String hostname(); |
| 41 | + |
| 42 | + @Nullable |
| 43 | + public abstract String service(); |
| 44 | + |
| 45 | + @Nullable |
| 46 | + public abstract String message(); |
| 47 | + |
| 48 | + /** A builder class for creating {@link DatadogLogEntry} objects. */ |
| 49 | + @AutoValue.Builder |
| 50 | + public abstract static class Builder { |
| 51 | + |
| 52 | + abstract Builder setDdsource(String source); |
| 53 | + |
| 54 | + abstract Builder setDdtags(String tags); |
| 55 | + |
| 56 | + abstract Builder setHostname(String hostname); |
| 57 | + |
| 58 | + abstract Builder setService(String service); |
| 59 | + |
| 60 | + abstract Builder setMessage(String message); |
| 61 | + |
| 62 | + abstract String message(); |
| 63 | + |
| 64 | + abstract DatadogLogEntry autoBuild(); |
| 65 | + |
| 66 | + public Builder withSource(String source) { |
| 67 | + checkNotNull(source, "withSource(source) called with null input."); |
| 68 | + |
| 69 | + return setDdsource(source); |
| 70 | + } |
| 71 | + |
| 72 | + public Builder withTags(String tags) { |
| 73 | + checkNotNull(tags, "withTags(tags) called with null input."); |
| 74 | + |
| 75 | + return setDdtags(tags); |
| 76 | + } |
| 77 | + |
| 78 | + public Builder withHostname(String hostname) { |
| 79 | + checkNotNull(hostname, "withHostname(hostname) called with null input."); |
| 80 | + |
| 81 | + return setHostname(hostname); |
| 82 | + } |
| 83 | + |
| 84 | + public Builder withService(String service) { |
| 85 | + checkNotNull(service, "withService(service) called with null input."); |
| 86 | + |
| 87 | + return setService(service); |
| 88 | + } |
| 89 | + |
| 90 | + public Builder withMessage(String message) { |
| 91 | + checkNotNull(message, "withMessage(message) called with null input."); |
| 92 | + |
| 93 | + return setMessage(message); |
| 94 | + } |
| 95 | + |
| 96 | + public DatadogLogEntry build() { |
| 97 | + checkNotNull(message(), "Message is required."); |
| 98 | + |
| 99 | + return autoBuild(); |
| 100 | + } |
| 101 | + } |
| 102 | +} |
0 commit comments