blob: b53029adf88ca6cb8c71a60c4a3a916b253f9ee6 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.flink.statefun.flink.core.httpfn;
import java.io.Serializable;
import java.util.Objects;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonPointer;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.flink.statefun.flink.common.json.Selectors;
import org.apache.flink.statefun.sdk.TypeName;
public final class TransportClientSpec implements Serializable {
private static JsonPointer FACTORY_KIND = JsonPointer.compile("/type");
public static TransportClientSpec fromJsonNode(ObjectNode node) {
final TypeName factoryKind = TypeName.parseFrom(Selectors.textAt(node, FACTORY_KIND));
return new TransportClientSpec(factoryKind, node);
}
private final TypeName factoryKind;
private final ObjectNode specNode;
public TransportClientSpec(TypeName factoryKind, ObjectNode properties) {
this.factoryKind = Objects.requireNonNull(factoryKind);
this.specNode = Objects.requireNonNull(properties);
}
public TypeName factoryKind() {
return factoryKind;
}
public ObjectNode specNode() {
return specNode;
}
}