Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add include_tags in logs archives #501

Merged
merged 11 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.2.0",
"regenerated": "2020-10-21 14:47:54.710537",
"spec_repo_commit": "68b59be"
"regenerated": "2020-10-22 07:42:49.950130",
"spec_repo_commit": "f1dd07f"
},
"v2": {
"apigentools_version": "1.2.0",
"regenerated": "2020-10-21 14:48:01.432047",
"spec_repo_commit": "68b59be"
"regenerated": "2020-10-22 07:42:57.411095",
"spec_repo_commit": "f1dd07f"
}
}
}
22 changes: 22 additions & 0 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3370,6 +3370,7 @@ components:
- team:app
query: source:nginx
name: Nginx Archive
include_tags: false
state: WORKING
id: a2zcMylnM4OCHpYusxIi3g
type: archives
Expand All @@ -3385,10 +3386,18 @@ components:
- team:app
query: source:nginx
name: Nginx Archive
include_tags: false
state: WORKING
properties:
destination:
$ref: '#/components/schemas/LogsArchiveDestination'
include_tags:
default: false
description: |-
To store the tags in the archive, set the value "true".
If it is set to "false", the tags will be deleted when the logs are sent to the archive.
example: false
type: boolean
name:
description: The archive name.
example: Nginx Archive
Expand Down Expand Up @@ -3424,6 +3433,7 @@ components:
- team:app
query: source:nginx
name: Nginx Archive
include_tags: false
type: archives
properties:
data:
Expand All @@ -3437,9 +3447,17 @@ components:
- team:app
query: source:nginx
name: Nginx Archive
include_tags: false
properties:
destination:
$ref: '#/components/schemas/LogsArchiveCreateRequestDestination'
include_tags:
default: false
description: |-
To store the tags in the archive, set the value "true".
If it is set to "false", the tags will be deleted when the logs are sent to the archive.
example: false
type: boolean
name:
description: The archive name.
example: Nginx Archive
Expand Down Expand Up @@ -3472,6 +3490,7 @@ components:
- team:app
query: source:nginx
name: Nginx Archive
include_tags: false
type: archives
properties:
attributes:
Expand Down Expand Up @@ -3503,6 +3522,7 @@ components:
- team:app
query: source:nginx
name: Nginx Archive
include_tags: false
state: WORKING
id: a2zcMylnM4OCHpYusxIi3g
type: archives
Expand Down Expand Up @@ -3759,6 +3779,7 @@ components:
- team:app
query: source:nginx
name: Nginx Archive
include_tags: false
state: WORKING
id: a2zcMylnM4OCHpYusxIi3g
type: archives
Expand All @@ -3768,6 +3789,7 @@ components:
- team:app
query: source:nginx
name: Nginx Archive
include_tags: false
state: WORKING
id: a2zcMylnM4OCHpYusxIi3g
type: archives
Expand Down
1 change: 1 addition & 0 deletions api_docs/v2/LogsArchiveAttributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The attributes associated with the archive.
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**destination** | [**LogsArchiveDestination**](LogsArchiveDestination.md) | |
**includeTags** | **Boolean** | To store the tags in the archive, set the value \"true\". If it is set to \"false\", the tags will be deleted when the logs are sent to the archive. | [optional]
**name** | **String** | The archive name. |
**query** | **String** | The archive query/filter. Logs matching this query are included in the archive. |
**rehydrationTags** | **List<String>** | An array of tags to add to rehydrated logs from an archive. | [optional]
Expand Down
1 change: 1 addition & 0 deletions api_docs/v2/LogsArchiveCreateRequestAttributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The attributes associated with the archive.
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**destination** | [**LogsArchiveCreateRequestDestination**](LogsArchiveCreateRequestDestination.md) | |
**includeTags** | **Boolean** | To store the tags in the archive, set the value \"true\". If it is set to \"false\", the tags will be deleted when the logs are sent to the archive. | [optional]
**name** | **String** | The archive name. |
**query** | **String** | The archive query/filter. Logs matching this query are included in the archive. |
**rehydrationTags** | **List<String>** | An array of tags to add to rehydrated logs from an archive. | [optional]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
@ApiModel(description = "The attributes associated with the archive.")
@JsonPropertyOrder({
LogsArchiveAttributes.JSON_PROPERTY_DESTINATION,
LogsArchiveAttributes.JSON_PROPERTY_INCLUDE_TAGS,
LogsArchiveAttributes.JSON_PROPERTY_NAME,
LogsArchiveAttributes.JSON_PROPERTY_QUERY,
LogsArchiveAttributes.JSON_PROPERTY_REHYDRATION_TAGS,
Expand All @@ -46,6 +47,9 @@ public class LogsArchiveAttributes {
public static final String JSON_PROPERTY_DESTINATION = "destination";
private LogsArchiveDestination destination;

public static final String JSON_PROPERTY_INCLUDE_TAGS = "include_tags";
private Boolean includeTags = false;

public static final String JSON_PROPERTY_NAME = "name";
private String name;

Expand Down Expand Up @@ -83,6 +87,30 @@ public void setDestination(LogsArchiveDestination destination) {
}


public LogsArchiveAttributes includeTags(Boolean includeTags) {
this.includeTags = includeTags;
return this;
}

/**
* To store the tags in the archive, set the value \"true\". If it is set to \"false\", the tags will be deleted when the logs are sent to the archive.
* @return includeTags
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "false", value = "To store the tags in the archive, set the value \"true\". If it is set to \"false\", the tags will be deleted when the logs are sent to the archive.")
@JsonProperty(JSON_PROPERTY_INCLUDE_TAGS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public Boolean getIncludeTags() {
return includeTags;
}


public void setIncludeTags(Boolean includeTags) {
this.includeTags = includeTags;
}


public LogsArchiveAttributes name(String name) {
this.name = name;
return this;
Expand Down Expand Up @@ -198,6 +226,7 @@ public boolean equals(Object o) {
}
LogsArchiveAttributes logsArchiveAttributes = (LogsArchiveAttributes) o;
return Objects.equals(this.destination, logsArchiveAttributes.destination) &&
Objects.equals(this.includeTags, logsArchiveAttributes.includeTags) &&
Objects.equals(this.name, logsArchiveAttributes.name) &&
Objects.equals(this.query, logsArchiveAttributes.query) &&
Objects.equals(this.rehydrationTags, logsArchiveAttributes.rehydrationTags) &&
Expand All @@ -206,7 +235,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(destination, name, query, rehydrationTags, state);
return Objects.hash(destination, includeTags, name, query, rehydrationTags, state);
}


Expand All @@ -215,6 +244,7 @@ public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class LogsArchiveAttributes {\n");
sb.append(" destination: ").append(toIndentedString(destination)).append("\n");
sb.append(" includeTags: ").append(toIndentedString(includeTags)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" query: ").append(toIndentedString(query)).append("\n");
sb.append(" rehydrationTags: ").append(toIndentedString(rehydrationTags)).append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
@ApiModel(description = "The attributes associated with the archive.")
@JsonPropertyOrder({
LogsArchiveCreateRequestAttributes.JSON_PROPERTY_DESTINATION,
LogsArchiveCreateRequestAttributes.JSON_PROPERTY_INCLUDE_TAGS,
LogsArchiveCreateRequestAttributes.JSON_PROPERTY_NAME,
LogsArchiveCreateRequestAttributes.JSON_PROPERTY_QUERY,
LogsArchiveCreateRequestAttributes.JSON_PROPERTY_REHYDRATION_TAGS
Expand All @@ -44,6 +45,9 @@ public class LogsArchiveCreateRequestAttributes {
public static final String JSON_PROPERTY_DESTINATION = "destination";
private LogsArchiveCreateRequestDestination destination;

public static final String JSON_PROPERTY_INCLUDE_TAGS = "include_tags";
private Boolean includeTags = false;

public static final String JSON_PROPERTY_NAME = "name";
private String name;

Expand Down Expand Up @@ -77,6 +81,30 @@ public void setDestination(LogsArchiveCreateRequestDestination destination) {
}


public LogsArchiveCreateRequestAttributes includeTags(Boolean includeTags) {
this.includeTags = includeTags;
return this;
}

/**
* To store the tags in the archive, set the value \"true\". If it is set to \"false\", the tags will be deleted when the logs are sent to the archive.
* @return includeTags
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "false", value = "To store the tags in the archive, set the value \"true\". If it is set to \"false\", the tags will be deleted when the logs are sent to the archive.")
@JsonProperty(JSON_PROPERTY_INCLUDE_TAGS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)

public Boolean getIncludeTags() {
return includeTags;
}


public void setIncludeTags(Boolean includeTags) {
this.includeTags = includeTags;
}


public LogsArchiveCreateRequestAttributes name(String name) {
this.name = name;
return this;
Expand Down Expand Up @@ -168,14 +196,15 @@ public boolean equals(Object o) {
}
LogsArchiveCreateRequestAttributes logsArchiveCreateRequestAttributes = (LogsArchiveCreateRequestAttributes) o;
return Objects.equals(this.destination, logsArchiveCreateRequestAttributes.destination) &&
Objects.equals(this.includeTags, logsArchiveCreateRequestAttributes.includeTags) &&
Objects.equals(this.name, logsArchiveCreateRequestAttributes.name) &&
Objects.equals(this.query, logsArchiveCreateRequestAttributes.query) &&
Objects.equals(this.rehydrationTags, logsArchiveCreateRequestAttributes.rehydrationTags);
}

@Override
public int hashCode() {
return Objects.hash(destination, name, query, rehydrationTags);
return Objects.hash(destination, includeTags, name, query, rehydrationTags);
}


Expand All @@ -184,6 +213,7 @@ public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class LogsArchiveCreateRequestAttributes {\n");
sb.append(" destination: ").append(toIndentedString(destination)).append("\n");
sb.append(" includeTags: ").append(toIndentedString(includeTags)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" query: ").append(toIndentedString(query)).append("\n");
sb.append(" rehydrationTags: ").append(toIndentedString(rehydrationTags)).append("\n");
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/datadog/api/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,14 @@ components:
properties:
destination:
$ref: '#/components/schemas/LogsArchiveDestination'
include_tags:
default: false
description: 'To store the tags in the archive, set the value "true".

If it is set to "false", the tags will be deleted when the logs are sent
to the archive.'
example: false
type: boolean
name:
description: The archive name.
example: Nginx Archive
Expand Down Expand Up @@ -605,6 +613,14 @@ components:
properties:
destination:
$ref: '#/components/schemas/LogsArchiveCreateRequestDestination'
include_tags:
default: false
description: 'To store the tags in the archive, set the value "true".

If it is set to "false", the tags will be deleted when the logs are sent
to the archive.'
example: false
type: boolean
name:
description: The archive name.
example: Nginx Archive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@
import com.datadog.api.v2.client.model.LogsArchiveIntegrationAzure;
import com.datadog.api.v2.client.model.LogsArchiveIntegrationGCS;
import com.datadog.api.v2.client.model.LogsArchiveIntegrationS3;
import com.datadog.api.v2.client.model.LogsArchiveOrder;
import com.datadog.api.v2.client.model.LogsArchiveOrderAttributes;
import com.datadog.api.v2.client.model.LogsArchiveOrderDefinition;
import com.datadog.api.v2.client.model.LogsArchives;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;

Expand Down Expand Up @@ -217,6 +221,55 @@ public void updateLogsArchiveTest() throws IOException, ApiException {
assertEquals(objectMapper.readValue(outputData, LogsArchive.class), response);
}

/**
* Get an ordered list of archive IDs
*/
@Test
public void getArchiveOrderTest() throws ApiException, IOException {
String outputData = TestUtils.getFixture(String.format("%s/%s/out/%s", fixturePrefix, "archive_order", "default.json"));
stubFor(get(urlPathEqualTo(String.format("%s", apiUriForArchiveOrder)))
.willReturn(okJson(outputData).withStatus(200)));


LogsArchiveOrder response = api.getLogsArchiveOrder().execute();
assertEquals(objectMapper.readValue(outputData, LogsArchiveOrder.class), response);
}

/**
* update the order of archives
*/
@Test
public void updateArchiveOrderTest() throws ApiException, IOException {
LogsArchiveOrder input = createUpdatedLogsArchiveOrder();
String outputData = TestUtils.getFixture(String.format("%s/%s/out/%s", fixturePrefix, "archive_order", "updated.json"));
stubFor(put(urlPathEqualTo(String.format("%s", apiUriForArchiveOrder)))
.withRequestBody(equalToJson(objectMapper.writeValueAsString(input)))
.willReturn(okJson(outputData).withStatus(200))
);

LogsArchiveOrder response = api.updateLogsArchiveOrder().body(input).execute();
assertEquals(objectMapper.readValue(outputData, LogsArchiveOrder.class), response);

}

private LogsArchiveOrder createUpdatedLogsArchiveOrder() throws IOException {
String getDefaultData = TestUtils.getFixture(String.format("%s/%s/out/%s", fixturePrefix, "archive_order", "default.json"));
LogsArchiveOrder oldArchiveOrder = objectMapper.readValue(getDefaultData, LogsArchiveOrder.class);
assert oldArchiveOrder.getData() != null;
assert oldArchiveOrder.getData().getAttributes() != null;
List<String> newArchiveIds = oldArchiveOrder.getData().getAttributes().getArchiveIds();
newArchiveIds.add(newArchiveIds.get(0));
newArchiveIds.remove(0);
LogsArchiveOrderAttributes archiveOrderAttributes = new LogsArchiveOrderAttributes();
archiveOrderAttributes.setArchiveIds(newArchiveIds);
LogsArchiveOrderDefinition archiveOrderDefinition = new LogsArchiveOrderDefinition();
archiveOrderDefinition.setAttributes(archiveOrderAttributes);
LogsArchiveOrder logsArchiveOrder = new LogsArchiveOrder();
logsArchiveOrder.setData(archiveOrderDefinition);

return logsArchiveOrder;
}

private LogsArchiveCreateRequest createLogsArchiveCreateRequestS3() {
LogsArchiveIntegrationS3 integration = new LogsArchiveIntegrationS3()
.accountId("711111111111")
Expand All @@ -230,7 +283,8 @@ private LogsArchiveCreateRequest createLogsArchiveCreateRequestS3() {
.destination(new LogsArchiveCreateRequestDestination(destination))
.name("datadog-api-client-go Tests Archive")
.query("service:toto")
.rehydrationTags(Arrays.asList("team:intake", "team:app"));
.rehydrationTags(Arrays.asList("team:intake", "team:app"))
.includeTags(true);
return new LogsArchiveCreateRequest().data(new LogsArchiveCreateRequestDefinition().attributes(attributes));
}

Expand All @@ -250,7 +304,8 @@ private LogsArchiveCreateRequest createLogsArchiveCreateRequestAzure() {
.destination(new LogsArchiveCreateRequestDestination(destination))
.name("datadog-api-client-go Tests Archive")
.query("service:toto")
.rehydrationTags(Arrays.asList("team:intake", "team:app"));
.rehydrationTags(Arrays.asList("team:intake", "team:app"))
.includeTags(true);
return new LogsArchiveCreateRequest().data(new LogsArchiveCreateRequestDefinition().attributes(attributes));
}

Expand All @@ -267,7 +322,8 @@ private LogsArchiveCreateRequest createLogsArchiveCreateRequestGCS() {
.destination(new LogsArchiveCreateRequestDestination(destination))
.name("datadog-api-client-go Tests Archive")
.query("service:toto")
.rehydrationTags(Arrays.asList("team:intake", "team:app"));
.rehydrationTags(Arrays.asList("team:intake", "team:app"))
.includeTags(true);
return new LogsArchiveCreateRequest().data(new LogsArchiveCreateRequestDefinition().attributes(attributes));
}

Expand Down
Loading