Skip to content

Commit

Permalink
[Connector API] Don't index literal nulls to connector doc (elastic#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
jedrazb authored Jul 10, 2024
1 parent 8d3b0ad commit f794966
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,42 @@ setup:
- match: { custom_scheduling: {} }
- match: { filtering.0.domain: DEFAULT }


---
'Create Connector - Check for missing keys':
- do:
connector.put:
connector_id: test-connector
body:
index_name: search-test
name: my-connector
language: pl
is_native: false
service_type: super-connector

- match: { result: 'created' }

- do:
connector.get:
connector_id: test-connector

- match: { id: test-connector }
- match: { index_name: search-test }
- match: { name: my-connector }
- match: { language: pl }
- match: { is_native: false }
- match: { service_type: super-connector }

# check keys that are not populated upon connector creation
- is_false: api_key_id
- is_false: api_key_secret_id
- is_false: description
- is_false: error
- is_false: features
- is_false: last_seen
- is_false: sync_cursor


---
'Create Connector - Resource already exists':
- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,25 +377,61 @@ public void toInnerXContent(XContentBuilder builder, Params params) throws IOExc
if (connectorId != null) {
builder.field(ID_FIELD.getPreferredName(), connectorId);
}
builder.field(API_KEY_ID_FIELD.getPreferredName(), apiKeyId);
builder.field(API_KEY_SECRET_ID_FIELD.getPreferredName(), apiKeySecretId);
builder.xContentValuesMap(CONFIGURATION_FIELD.getPreferredName(), configuration);
builder.xContentValuesMap(CUSTOM_SCHEDULING_FIELD.getPreferredName(), customScheduling);
builder.field(DESCRIPTION_FIELD.getPreferredName(), description);
builder.field(ERROR_FIELD.getPreferredName(), error);
builder.field(FEATURES_FIELD.getPreferredName(), features);
builder.xContentList(FILTERING_FIELD.getPreferredName(), filtering);
builder.field(INDEX_NAME_FIELD.getPreferredName(), indexName);
if (apiKeyId != null) {
builder.field(API_KEY_ID_FIELD.getPreferredName(), apiKeyId);
}
if (apiKeySecretId != null) {
builder.field(API_KEY_SECRET_ID_FIELD.getPreferredName(), apiKeySecretId);
}
if (configuration != null) {
builder.xContentValuesMap(CONFIGURATION_FIELD.getPreferredName(), configuration);
}
if (customScheduling != null) {
builder.xContentValuesMap(CUSTOM_SCHEDULING_FIELD.getPreferredName(), customScheduling);
}
if (description != null) {
builder.field(DESCRIPTION_FIELD.getPreferredName(), description);
}
if (error != null) {
builder.field(ERROR_FIELD.getPreferredName(), error);
}
if (features != null) {
builder.field(FEATURES_FIELD.getPreferredName(), features);
}
if (filtering != null) {
builder.xContentList(FILTERING_FIELD.getPreferredName(), filtering);
}
if (indexName != null) {
builder.field(INDEX_NAME_FIELD.getPreferredName(), indexName);
}
builder.field(IS_NATIVE_FIELD.getPreferredName(), isNative);
builder.field(LANGUAGE_FIELD.getPreferredName(), language);
builder.field(LAST_SEEN_FIELD.getPreferredName(), lastSeen);
syncInfo.toXContent(builder, params);
builder.field(NAME_FIELD.getPreferredName(), name);
builder.field(PIPELINE_FIELD.getPreferredName(), pipeline);
builder.field(SCHEDULING_FIELD.getPreferredName(), scheduling);
builder.field(SERVICE_TYPE_FIELD.getPreferredName(), serviceType);
builder.field(SYNC_CURSOR_FIELD.getPreferredName(), syncCursor);
builder.field(STATUS_FIELD.getPreferredName(), status.toString());
if (language != null) {
builder.field(LANGUAGE_FIELD.getPreferredName(), language);
}
if (lastSeen != null) {
builder.field(LAST_SEEN_FIELD.getPreferredName(), lastSeen);
}
if (syncInfo != null) {
syncInfo.toXContent(builder, params);
}
if (name != null) {
builder.field(NAME_FIELD.getPreferredName(), name);
}
if (pipeline != null) {
builder.field(PIPELINE_FIELD.getPreferredName(), pipeline);
}
if (scheduling != null) {
builder.field(SCHEDULING_FIELD.getPreferredName(), scheduling);
}
if (serviceType != null) {
builder.field(SERVICE_TYPE_FIELD.getPreferredName(), serviceType);
}
if (syncCursor != null) {
builder.field(SYNC_CURSOR_FIELD.getPreferredName(), syncCursor);
}
if (status != null) {
builder.field(STATUS_FIELD.getPreferredName(), status.toString());
}
builder.field(SYNC_NOW_FIELD.getPreferredName(), syncNow);
}

Expand Down

0 comments on commit f794966

Please sign in to comment.