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

Dashboard RBAC role support #863

Merged
merged 1 commit into from
Jun 15, 2021
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.4.1.dev8",
"regenerated": "2021-06-14 11:43:39.800721",
"spec_repo_commit": "6c1fcab"
"regenerated": "2021-06-14 19:17:51.699962",
"spec_repo_commit": "0664044"
},
"v2": {
"apigentools_version": "1.4.1.dev8",
"regenerated": "2021-06-14 11:44:20.341651",
"spec_repo_commit": "6c1fcab"
"regenerated": "2021-06-14 19:18:38.923397",
"spec_repo_commit": "0664044"
}
}
}
1 change: 1 addition & 0 deletions api_docs/v1/Dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Name | Type | Description | Notes
**modifiedAt** | **OffsetDateTime** | Modification date of the dashboard. | [optional] [readonly]
**notifyList** | **List<String>** | List of handles of users to notify when changes are made to this dashboard. | [optional]
**reflowType** | **DashboardReflowType** | | [optional]
**restrictedRoles** | **List<String>** | A list of role identifiers. Only the author and users associated with at least one of these roles can edit this dashboard. Overrides the `is_read_only` property if both are present. **This feature is currently in beta.** | [optional]
**templateVariablePresets** | [**List<DashboardTemplateVariablePreset>**](DashboardTemplateVariablePreset.md) | Array of template variables saved views. | [optional]
**templateVariables** | [**List<DashboardTemplateVariable>**](DashboardTemplateVariable.md) | List of template variables for this dashboard. | [optional]
**title** | **String** | Title of the dashboard. |
Expand Down
43 changes: 43 additions & 0 deletions src/main/java/com/datadog/api/v1/client/model/Dashboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
Dashboard.JSON_PROPERTY_MODIFIED_AT,
Dashboard.JSON_PROPERTY_NOTIFY_LIST,
Dashboard.JSON_PROPERTY_REFLOW_TYPE,
Dashboard.JSON_PROPERTY_RESTRICTED_ROLES,
Dashboard.JSON_PROPERTY_TEMPLATE_VARIABLE_PRESETS,
Dashboard.JSON_PROPERTY_TEMPLATE_VARIABLES,
Dashboard.JSON_PROPERTY_TITLE,
Expand Down Expand Up @@ -77,6 +78,9 @@ public class Dashboard {
public static final String JSON_PROPERTY_REFLOW_TYPE = "reflow_type";
private DashboardReflowType reflowType;

public static final String JSON_PROPERTY_RESTRICTED_ROLES = "restricted_roles";
private List<String> restrictedRoles = null;

public static final String JSON_PROPERTY_TEMPLATE_VARIABLE_PRESETS = "template_variable_presets";
private JsonNullable<List<DashboardTemplateVariablePreset>> templateVariablePresets =
JsonNullable.<List<DashboardTemplateVariablePreset>>undefined();
Expand Down Expand Up @@ -306,6 +310,42 @@ public void setReflowType(DashboardReflowType reflowType) {
this.reflowType = reflowType;
}

public Dashboard restrictedRoles(List<String> restrictedRoles) {
this.restrictedRoles = restrictedRoles;
return this;
}

public Dashboard addRestrictedRolesItem(String restrictedRolesItem) {
if (this.restrictedRoles == null) {
this.restrictedRoles = new ArrayList<>();
}
this.restrictedRoles.add(restrictedRolesItem);
return this;
}

/**
* A list of role identifiers. Only the author and users associated with at least one of these
* roles can edit this dashboard. Overrides the &#x60;is_read_only&#x60; property if both are
* present. **This feature is currently in beta.**
*
* @return restrictedRoles
*/
@javax.annotation.Nullable
@ApiModelProperty(
value =
"A list of role identifiers. Only the author and users associated with at least one of"
+ " these roles can edit this dashboard. Overrides the `is_read_only` property if"
+ " both are present. **This feature is currently in beta.**")
@JsonProperty(JSON_PROPERTY_RESTRICTED_ROLES)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public List<String> getRestrictedRoles() {
return restrictedRoles;
}

public void setRestrictedRoles(List<String> restrictedRoles) {
this.restrictedRoles = restrictedRoles;
}

public Dashboard templateVariablePresets(
List<DashboardTemplateVariablePreset> templateVariablePresets) {
this.templateVariablePresets =
Expand Down Expand Up @@ -488,6 +528,7 @@ public boolean equals(Object o) {
&& Objects.equals(this.modifiedAt, dashboard.modifiedAt)
&& Objects.equals(this.notifyList, dashboard.notifyList)
&& Objects.equals(this.reflowType, dashboard.reflowType)
&& Objects.equals(this.restrictedRoles, dashboard.restrictedRoles)
&& Objects.equals(this.templateVariablePresets, dashboard.templateVariablePresets)
&& Objects.equals(this.templateVariables, dashboard.templateVariables)
&& Objects.equals(this.title, dashboard.title)
Expand All @@ -507,6 +548,7 @@ public int hashCode() {
modifiedAt,
notifyList,
reflowType,
restrictedRoles,
templateVariablePresets,
templateVariables,
title,
Expand All @@ -527,6 +569,7 @@ public String toString() {
sb.append(" modifiedAt: ").append(toIndentedString(modifiedAt)).append("\n");
sb.append(" notifyList: ").append(toIndentedString(notifyList)).append("\n");
sb.append(" reflowType: ").append(toIndentedString(reflowType)).append("\n");
sb.append(" restrictedRoles: ").append(toIndentedString(restrictedRoles)).append("\n");
sb.append(" templateVariablePresets: ")
.append(toIndentedString(templateVariablePresets))
.append("\n");
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/datadog/api/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11062,6 +11062,9 @@ components:
notify_list:
- notify_list
- notify_list
restricted_roles:
- restricted_roles
- restricted_roles
title: ""
widgets:
- definition:
Expand Down Expand Up @@ -11124,6 +11127,15 @@ components:
type: array
reflow_type:
$ref: '#/components/schemas/DashboardReflowType'
restricted_roles:
description: A list of role identifiers. Only the author and users associated
with at least one of these roles can edit this dashboard. Overrides the
`is_read_only` property if both are present. **This feature is currently
in beta.**
items:
description: A role UUID.
type: string
type: array
template_variable_presets:
description: Array of template variables saved views.
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ Feature: Dashboards
@generated @skip
Scenario: Create a new dashboard returns "Bad Request" response
Given new "CreateDashboard" request
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [null], "reflow_type": "auto", "template_variable_presets": [{"name": null, "template_variables": [{"name": null, "value": null}]}], "template_variables": [{"default": "my-host", "name": "host1", "prefix": "host"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "system.cpu.user"}}, "type": "hostmap"}}]}
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [null], "reflow_type": "auto", "restricted_roles": [null], "template_variable_presets": [{"name": null, "template_variables": [{"name": null, "value": null}]}], "template_variables": [{"default": "my-host", "name": "host1", "prefix": "host"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "system.cpu.user"}}, "type": "hostmap"}}]}
When the request is sent
Then the response status is 400 Bad Request

@generated @skip
Scenario: Create a new dashboard returns "OK" response
Given new "CreateDashboard" request
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [null], "reflow_type": "auto", "template_variable_presets": [{"name": null, "template_variables": [{"name": null, "value": null}]}], "template_variables": [{"default": "my-host", "name": "host1", "prefix": "host"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "system.cpu.user"}}, "type": "hostmap"}}]}
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [null], "reflow_type": "auto", "restricted_roles": [null], "template_variable_presets": [{"name": null, "template_variables": [{"name": null, "value": null}]}], "template_variables": [{"default": "my-host", "name": "host1", "prefix": "host"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "system.cpu.user"}}, "type": "hostmap"}}]}
When the request is sent
Then the response status is 200 OK

Expand Down Expand Up @@ -78,22 +78,22 @@ Feature: Dashboards
Scenario: Update a dashboard returns "Bad Request" response
Given new "UpdateDashboard" request
And request contains "dashboard_id" parameter from "<PATH>"
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [null], "reflow_type": "auto", "template_variable_presets": [{"name": null, "template_variables": [{"name": null, "value": null}]}], "template_variables": [{"default": "my-host", "name": "host1", "prefix": "host"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "system.cpu.user"}}, "type": "hostmap"}}]}
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [null], "reflow_type": "auto", "restricted_roles": [null], "template_variable_presets": [{"name": null, "template_variables": [{"name": null, "value": null}]}], "template_variables": [{"default": "my-host", "name": "host1", "prefix": "host"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "system.cpu.user"}}, "type": "hostmap"}}]}
When the request is sent
Then the response status is 400 Bad Request

@generated @skip
Scenario: Update a dashboard returns "Item Not Found" response
Given new "UpdateDashboard" request
And request contains "dashboard_id" parameter from "<PATH>"
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [null], "reflow_type": "auto", "template_variable_presets": [{"name": null, "template_variables": [{"name": null, "value": null}]}], "template_variables": [{"default": "my-host", "name": "host1", "prefix": "host"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "system.cpu.user"}}, "type": "hostmap"}}]}
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [null], "reflow_type": "auto", "restricted_roles": [null], "template_variable_presets": [{"name": null, "template_variables": [{"name": null, "value": null}]}], "template_variables": [{"default": "my-host", "name": "host1", "prefix": "host"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "system.cpu.user"}}, "type": "hostmap"}}]}
When the request is sent
Then the response status is 404 Item Not Found

@generated @skip
Scenario: Update a dashboard returns "OK" response
Given new "UpdateDashboard" request
And request contains "dashboard_id" parameter from "<PATH>"
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [null], "reflow_type": "auto", "template_variable_presets": [{"name": null, "template_variables": [{"name": null, "value": null}]}], "template_variables": [{"default": "my-host", "name": "host1", "prefix": "host"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "system.cpu.user"}}, "type": "hostmap"}}]}
And body with value {"description": null, "is_read_only": false, "layout_type": "ordered", "notify_list": [null], "reflow_type": "auto", "restricted_roles": [null], "template_variable_presets": [{"name": null, "template_variables": [{"name": null, "value": null}]}], "template_variables": [{"default": "my-host", "name": "host1", "prefix": "host"}], "title": "", "widgets": [{"definition": {"requests": {"fill": {"q": "system.cpu.user"}}, "type": "hostmap"}}]}
When the request is sent
Then the response status is 200 OK