Class: ElasticGraph::SchemaDefinition::Results

Inherits:
Object
  • Object
show all
Includes:
ElasticGraph::SchemaArtifacts::ArtifactsHelperMethods
Defined in:
elasticgraph-schema_definition/lib/elastic_graph/schema_definition/results.rb

Overview

Note:

This class is designed to implement the same interface as ElasticGraph::SchemaArtifacts::FromDisk, so that it can be used

Provides the results of defining a schema.

interchangeably with schema artifacts loaded from disk. This allows the artifacts to be used in tests without having to dump them or reload them.

Instance Method Summary collapse

Methods included from ElasticGraph::SchemaArtifacts::ArtifactsHelperMethods

#datastore_scripts, #index_mappings_by_index_def_name, #index_templates, #indices

Instance Method Details

#available_json_schema_versionsSet<Integer>

Returns set of available JSON schema versions.

Returns:

  • (Set<Integer>)

    set of available JSON schema versions



61
62
63
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/results.rb', line 61

def available_json_schema_versions
  @available_json_schema_versions ||= Set[latest_json_schema_version]
end

#datastore_configHash<String, Object>

Returns the Elasticsearch/OpenSearch configuration dumped as datastore_config.yaml.

Returns:

  • (Hash<String, Object>)

    the Elasticsearch/OpenSearch configuration dumped as datastore_config.yaml



40
41
42
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/results.rb', line 40

def datastore_config
  @datastore_config ||= generate_datastore_config
end

#graphql_schema_stringString

Returns the generated GraphQL SDL schema string dumped as schema.graphql.

Returns:

  • (String)

    the generated GraphQL SDL schema string dumped as schema.graphql



35
36
37
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/results.rb', line 35

def graphql_schema_string
  @graphql_schema_string ||= generate_sdl
end

#json_schemas_for(version) ⇒ Hash<String, Object>

Returns the JSON schema for the requested version, if available.

Parameters:

  • version (Integer)

    desired JSON schema version

Returns:

  • (Hash<String, Object>)

    the JSON schema for the requested version, if available

Raises:

  • (Errors::NotFoundError)

    if the requested JSON schema version is not available



52
53
54
55
56
57
58
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/results.rb', line 52

def json_schemas_for(version)
  unless available_json_schema_versions.include?(version)
    raise Errors::NotFoundError, "The requested json schema version (#{version}) is not available. Available versions: #{available_json_schema_versions.to_a.join(", ")}."
  end

  @latest_versioned_json_schema ||= (current_public_json_schema).json_schema
end

#latest_json_schema_versionHash<String, Object>

Returns the newly generated JSON schema.

Returns:

  • (Hash<String, Object>)

    the newly generated JSON schema



66
67
68
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/results.rb', line 66

def latest_json_schema_version
  current_public_json_schema[JSON_SCHEMA_VERSION_KEY]
end

#runtime_metadataHash<String, Object>

Returns runtime metadata used by other parts of ElasticGraph and dumped as runtime_metadata.yaml.

Returns:

  • (Hash<String, Object>)

    runtime metadata used by other parts of ElasticGraph and dumped as runtime_metadata.yaml



45
46
47
# File 'elasticgraph-schema_definition/lib/elastic_graph/schema_definition/results.rb', line 45

def 
  @runtime_metadata ||= 
end