Ejemplo n.º 1
0
        public async Task CreateOrUpdateSchemaRecordAsync(SchemaInfo schemaInfo)
        {
            if (schemaInfo == null)
            {
                throw new ArgumentNullException(nameof(schemaInfo));
            }
            if (string.IsNullOrEmpty(schemaInfo.Id))
            {
                schemaInfo.Id = $"{schemaInfo.OwnerId}/{schemaInfo.RepositoryId}/{schemaInfo.SchemaId}";
            }
            var validator         = new SchemaInfoValidator();
            var validationResults = await validator.ValidateAsync(schemaInfo);

            if (!validationResults.IsValid)
            {
                throw new ValidationException("Invalid schema info", validationResults);
            }
            var indexResponse = await _client.IndexDocumentAsync(schemaInfo);

            if (!indexResponse.IsValid)
            {
                throw new SchemaStoreException($"Failed to insert or update schema record: {indexResponse.DebugInformation}");
            }
            await _client.RefreshAsync(Indices.Index <SchemaInfo>());
        }
Ejemplo n.º 2
0
 public SchemaInfoValidatorTests()
 {
     _validator = new SchemaInfoValidator();
 }