All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.algolia.model.ingestion.SourceInput Maven / Gradle / Ivy

The newest version!
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost
// - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

package com.algolia.model.ingestion;

import com.algolia.exceptions.AlgoliaRuntimeException;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.annotation.*;
import java.io.IOException;
import java.util.logging.Logger;

/** SourceInput */
@JsonDeserialize(using = SourceInput.Deserializer.class)
public interface SourceInput {
  class Deserializer extends JsonDeserializer {

    private static final Logger LOGGER = Logger.getLogger(Deserializer.class.getName());

    @Override
    public SourceInput deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
      JsonNode tree = jp.readValueAsTree();
      // deserialize SourceDocker
      if (tree.isObject() && tree.has("registry") && tree.has("image") && tree.has("imageType") && tree.has("configuration")) {
        try (JsonParser parser = tree.traverse(jp.getCodec())) {
          return parser.readValueAs(SourceDocker.class);
        } catch (Exception e) {
          // deserialization failed, continue
          LOGGER.finest("Failed to deserialize oneOf SourceDocker (error: " + e.getMessage() + ") (type: SourceDocker)");
        }
      }
      // deserialize SourceGA4BigQueryExport
      if (tree.isObject() && tree.has("projectID") && tree.has("datasetID") && tree.has("tablePrefix")) {
        try (JsonParser parser = tree.traverse(jp.getCodec())) {
          return parser.readValueAs(SourceGA4BigQueryExport.class);
        } catch (Exception e) {
          // deserialization failed, continue
          LOGGER.finest(
            "Failed to deserialize oneOf SourceGA4BigQueryExport (error: " + e.getMessage() + ") (type: SourceGA4BigQueryExport)"
          );
        }
      }
      // deserialize SourceCommercetools
      if (tree.isObject() && tree.has("projectKey")) {
        try (JsonParser parser = tree.traverse(jp.getCodec())) {
          return parser.readValueAs(SourceCommercetools.class);
        } catch (Exception e) {
          // deserialization failed, continue
          LOGGER.finest("Failed to deserialize oneOf SourceCommercetools (error: " + e.getMessage() + ") (type: SourceCommercetools)");
        }
      }
      // deserialize SourceBigCommerce
      if (tree.isObject() && tree.has("storeHash")) {
        try (JsonParser parser = tree.traverse(jp.getCodec())) {
          return parser.readValueAs(SourceBigCommerce.class);
        } catch (Exception e) {
          // deserialization failed, continue
          LOGGER.finest("Failed to deserialize oneOf SourceBigCommerce (error: " + e.getMessage() + ") (type: SourceBigCommerce)");
        }
      }
      // deserialize SourceBigQuery
      if (tree.isObject() && tree.has("projectID")) {
        try (JsonParser parser = tree.traverse(jp.getCodec())) {
          return parser.readValueAs(SourceBigQuery.class);
        } catch (Exception e) {
          // deserialization failed, continue
          LOGGER.finest("Failed to deserialize oneOf SourceBigQuery (error: " + e.getMessage() + ") (type: SourceBigQuery)");
        }
      }
      // deserialize SourceShopify
      if (tree.isObject() && tree.has("shopURL")) {
        try (JsonParser parser = tree.traverse(jp.getCodec())) {
          return parser.readValueAs(SourceShopify.class);
        } catch (Exception e) {
          // deserialization failed, continue
          LOGGER.finest("Failed to deserialize oneOf SourceShopify (error: " + e.getMessage() + ") (type: SourceShopify)");
        }
      }
      // deserialize SourceJSON
      if (tree.isObject()) {
        try (JsonParser parser = tree.traverse(jp.getCodec())) {
          return parser.readValueAs(SourceJSON.class);
        } catch (Exception e) {
          // deserialization failed, continue
          LOGGER.finest("Failed to deserialize oneOf SourceJSON (error: " + e.getMessage() + ") (type: SourceJSON)");
        }
      }
      // deserialize SourceCSV
      if (tree.isObject()) {
        try (JsonParser parser = tree.traverse(jp.getCodec())) {
          return parser.readValueAs(SourceCSV.class);
        } catch (Exception e) {
          // deserialization failed, continue
          LOGGER.finest("Failed to deserialize oneOf SourceCSV (error: " + e.getMessage() + ") (type: SourceCSV)");
        }
      }
      throw new AlgoliaRuntimeException(String.format("Failed to deserialize json element: %s", tree));
    }

    /** Handle deserialization of the 'null' value. */
    @Override
    public SourceInput getNullValue(DeserializationContext ctxt) throws JsonMappingException {
      throw new JsonMappingException(ctxt.getParser(), "SourceInput cannot be null");
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy