diff --git a/NAMESPACE b/NAMESPACE index 6c34847..7f40b14 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,6 +9,7 @@ export(adjust_tableau_font_style) export(adjust_tableau_size) export(authenticate_server) export(check_dashboard_names) +export(create_group) export(download_filtered_tableau_image) export(download_tableau_crosstab_excel) export(download_tableau_data) diff --git a/R/create_group.R b/R/create_group.R new file mode 100644 index 0000000..a6bf8db --- /dev/null +++ b/R/create_group.R @@ -0,0 +1,50 @@ +#' Create Group +#' +#' Creates a group on Tableau Server or Tableau Cloud site. +#' +#' @param tableau A list containing the Tableau authentication variables: `base_url`, `token`, and `site_id`. +#' @param group_name The name of the group to create. +#' @param api_version The API version to use (default: 3.19). +#' +#' @return The ID of the new group. +#' @export +#' +#' @family Tableau REST API +create_group <- function(tableau, group_name, api_version = 3.19) { + base_url <- tableau$base_url + token <- tableau$token + site_id <- tableau$site_id + + url <- paste0( + base_url, + "/api/", + 3.19, + "/sites/", + site_id, + "/groups" + ) + + # Construct the request body + request_body <- paste0( + "", + "", + "" + ) + + api_response <- httr::POST( + url, + httr::add_headers("X-Tableau-Auth" = token), + body = request_body + ) + + # Check the response status code + if (httr::status_code(api_response) != 201) { + stop("Group creation failed. Please check your API key and base URL.") + } + + # Extract the ID of the new group from the Location header + location_header <- httr::headers(api_response)$location + group_id <- stringr::str_extract(location_header, "\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}") + + return(group_id) +} diff --git a/R/delete_group.R b/R/delete_group.R new file mode 100644 index 0000000..a5872ff --- /dev/null +++ b/R/delete_group.R @@ -0,0 +1,31 @@ +#' Delete Group +#' +#' Deletes the specified group from the site. +#' +#' @param tableau A list containing the Tableau authentication variables: `base_url`, `token`, `user_id`, and `site_id`. +#' @param group_id The ID of the group to delete. +#' @param api_version The API version to use (default: 3.19). +delete_group <- function(tableau, group_id, api_version = 3.19) { + base_url <- tableau$base_url + site_id <- tableau$site_id + token <- tableau$token + + url <- paste0( + base_url, + "api/", + api_version, + "/sites/", + site_id, + "/groups/", + group_id + ) + + api_response <- httr::DELETE(url, + httr::add_headers("X-Tableau-Auth" = token) + ) + + # Check the response status code + if (httr::status_code(api_response) != 204) { + stop("Group deletion failed. Please check your API key and base URL.") + } +} diff --git a/TODO.md b/TODO.md index d326e23..00e96f6 100644 --- a/TODO.md +++ b/TODO.md @@ -284,8 +284,8 @@ - [ ] Update Subscription - [x] Add User to Group - [x] Add User to Site -- [ ] Create Group -- [ ] Delete Group +- [x] Create Group +- [x] Delete Group - [ ] Delete Users from Site with CSV - [x] Get Groups for a User - [x] Get Users in Group diff --git a/man/add_tags_to_view.Rd b/man/add_tags_to_view.Rd index 98ba417..bda282b 100644 --- a/man/add_tags_to_view.Rd +++ b/man/add_tags_to_view.Rd @@ -27,6 +27,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/add_tags_to_workbook.Rd b/man/add_tags_to_workbook.Rd index 40bd715..a92d975 100644 --- a/man/add_tags_to_workbook.Rd +++ b/man/add_tags_to_workbook.Rd @@ -27,6 +27,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/add_user_to_group.Rd b/man/add_user_to_group.Rd index 7f182d4..6474999 100644 --- a/man/add_user_to_group.Rd +++ b/man/add_user_to_group.Rd @@ -27,6 +27,7 @@ Other Tableau REST API: \code{\link{add_tags_to_workbook}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/add_user_to_site.Rd b/man/add_user_to_site.Rd index b363cfb..503054f 100644 --- a/man/add_user_to_site.Rd +++ b/man/add_user_to_site.Rd @@ -35,6 +35,7 @@ Other Tableau REST API: \code{\link{add_tags_to_workbook}()}, \code{\link{add_user_to_group}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/authenticate_server.Rd b/man/authenticate_server.Rd index 5e56a28..38d9e06 100644 --- a/man/authenticate_server.Rd +++ b/man/authenticate_server.Rd @@ -27,6 +27,7 @@ Other Tableau REST API: \code{\link{add_tags_to_workbook}()}, \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/create_group.Rd b/man/create_group.Rd new file mode 100644 index 0000000..b8eff4a --- /dev/null +++ b/man/create_group.Rd @@ -0,0 +1,53 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/create_group.R +\name{create_group} +\alias{create_group} +\title{Create Group} +\usage{ +create_group(tableau, group_name, api_version = 3.19) +} +\arguments{ +\item{tableau}{A list containing the Tableau authentication variables: `base_url`, `token`, and `site_id`.} + +\item{group_name}{The name of the group to create.} + +\item{api_version}{The API version to use (default: 3.19).} +} +\value{ +The ID of the new group. +} +\description{ +Creates a group on Tableau Server or Tableau Cloud site. +} +\seealso{ +Other Tableau REST API: +\code{\link{add_tags_to_view}()}, +\code{\link{add_tags_to_workbook}()}, +\code{\link{add_user_to_group}()}, +\code{\link{add_user_to_site}()}, +\code{\link{authenticate_server}()}, +\code{\link{download_filtered_tableau_image}()}, +\code{\link{download_tableau_crosstab_excel}()}, +\code{\link{download_tableau_data}()}, +\code{\link{download_workbooks_server_pdf}()}, +\code{\link{download_workbooks_server_powerpoint}()}, +\code{\link{download_workbooks_server}()}, +\code{\link{get_groups_for_user}()}, +\code{\link{get_server_connected_apps}()}, +\code{\link{get_server_datasources}()}, +\code{\link{get_server_groups}()}, +\code{\link{get_server_info}()}, +\code{\link{get_server_jobs}()}, +\code{\link{get_server_projects}()}, +\code{\link{get_server_refresh_tasks}()}, +\code{\link{get_server_schedules}()}, +\code{\link{get_server_user_favorites}()}, +\code{\link{get_server_users}()}, +\code{\link{get_server_views}()}, +\code{\link{get_server_workbooks}()}, +\code{\link{get_table_assets}()}, +\code{\link{get_users_in_group}()}, +\code{\link{remove_user_from_group}()}, +\code{\link{remove_user_from_site}()} +} +\concept{Tableau REST API} diff --git a/man/delete_group.Rd b/man/delete_group.Rd new file mode 100644 index 0000000..310ea58 --- /dev/null +++ b/man/delete_group.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/delete_group.R +\name{delete_group} +\alias{delete_group} +\title{Delete Group} +\usage{ +delete_group(tableau, group_id, api_version = 3.19) +} +\arguments{ +\item{tableau}{A list containing the Tableau authentication variables: `base_url`, `token`, `user_id`, and `site_id`.} + +\item{group_id}{The ID of the group to delete.} + +\item{api_version}{The API version to use (default: 3.19).} +} +\description{ +Deletes the specified group from the site. +} diff --git a/man/download_filtered_tableau_image.Rd b/man/download_filtered_tableau_image.Rd index 8af9eeb..695edc9 100644 --- a/man/download_filtered_tableau_image.Rd +++ b/man/download_filtered_tableau_image.Rd @@ -33,6 +33,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, \code{\link{download_workbooks_server_pdf}()}, diff --git a/man/download_tableau_crosstab_excel.Rd b/man/download_tableau_crosstab_excel.Rd index 864899f..486063d 100644 --- a/man/download_tableau_crosstab_excel.Rd +++ b/man/download_tableau_crosstab_excel.Rd @@ -30,6 +30,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_data}()}, \code{\link{download_workbooks_server_pdf}()}, diff --git a/man/download_tableau_data.Rd b/man/download_tableau_data.Rd index 200ccd2..89dcbac 100644 --- a/man/download_tableau_data.Rd +++ b/man/download_tableau_data.Rd @@ -25,6 +25,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_workbooks_server_pdf}()}, diff --git a/man/download_workbooks_server.Rd b/man/download_workbooks_server.Rd index ef6d88b..700b609 100644 --- a/man/download_workbooks_server.Rd +++ b/man/download_workbooks_server.Rd @@ -36,6 +36,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/download_workbooks_server_pdf.Rd b/man/download_workbooks_server_pdf.Rd index 9121461..220dfc5 100644 --- a/man/download_workbooks_server_pdf.Rd +++ b/man/download_workbooks_server_pdf.Rd @@ -33,6 +33,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/download_workbooks_server_powerpoint.Rd b/man/download_workbooks_server_powerpoint.Rd index a84216d..86f5294 100644 --- a/man/download_workbooks_server_powerpoint.Rd +++ b/man/download_workbooks_server_powerpoint.Rd @@ -33,6 +33,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/get_groups_for_user.Rd b/man/get_groups_for_user.Rd index d2fcb50..f064744 100644 --- a/man/get_groups_for_user.Rd +++ b/man/get_groups_for_user.Rd @@ -39,6 +39,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/get_server_connected_apps.Rd b/man/get_server_connected_apps.Rd index e0e4d6e..8a6f69c 100644 --- a/man/get_server_connected_apps.Rd +++ b/man/get_server_connected_apps.Rd @@ -26,6 +26,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/get_server_datasources.Rd b/man/get_server_datasources.Rd index a8882df..a7516a4 100644 --- a/man/get_server_datasources.Rd +++ b/man/get_server_datasources.Rd @@ -33,6 +33,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/get_server_groups.Rd b/man/get_server_groups.Rd index d16a8cf..e607ac8 100644 --- a/man/get_server_groups.Rd +++ b/man/get_server_groups.Rd @@ -33,6 +33,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/get_server_info.Rd b/man/get_server_info.Rd index d6612ed..e216857 100644 --- a/man/get_server_info.Rd +++ b/man/get_server_info.Rd @@ -33,6 +33,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/get_server_jobs.Rd b/man/get_server_jobs.Rd index decaba9..5000e64 100644 --- a/man/get_server_jobs.Rd +++ b/man/get_server_jobs.Rd @@ -33,6 +33,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/get_server_projects.Rd b/man/get_server_projects.Rd index 9a2e3e6..55451af 100644 --- a/man/get_server_projects.Rd +++ b/man/get_server_projects.Rd @@ -33,6 +33,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/get_server_refresh_tasks.Rd b/man/get_server_refresh_tasks.Rd index 87203d2..b5f6d1a 100644 --- a/man/get_server_refresh_tasks.Rd +++ b/man/get_server_refresh_tasks.Rd @@ -26,6 +26,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/get_server_schedules.Rd b/man/get_server_schedules.Rd index 114ba3b..c04a28f 100644 --- a/man/get_server_schedules.Rd +++ b/man/get_server_schedules.Rd @@ -33,6 +33,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/get_server_user_favorites.Rd b/man/get_server_user_favorites.Rd index f991c06..dcc5853 100644 --- a/man/get_server_user_favorites.Rd +++ b/man/get_server_user_favorites.Rd @@ -36,6 +36,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/get_server_users.Rd b/man/get_server_users.Rd index ae7160a..1d8deb9 100644 --- a/man/get_server_users.Rd +++ b/man/get_server_users.Rd @@ -33,6 +33,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/get_server_views.Rd b/man/get_server_views.Rd index de15375..0d9844f 100644 --- a/man/get_server_views.Rd +++ b/man/get_server_views.Rd @@ -36,6 +36,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/get_server_workbooks.Rd b/man/get_server_workbooks.Rd index f2d74ff..abad487 100644 --- a/man/get_server_workbooks.Rd +++ b/man/get_server_workbooks.Rd @@ -33,6 +33,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/get_table_assets.Rd b/man/get_table_assets.Rd index 9f44981..bc4ba90 100644 --- a/man/get_table_assets.Rd +++ b/man/get_table_assets.Rd @@ -24,6 +24,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/get_users_in_group.Rd b/man/get_users_in_group.Rd index aa177e4..ae5e59e 100644 --- a/man/get_users_in_group.Rd +++ b/man/get_users_in_group.Rd @@ -36,6 +36,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/remove_user_from_group.Rd b/man/remove_user_from_group.Rd index 0fd529c..a4caa53 100644 --- a/man/remove_user_from_group.Rd +++ b/man/remove_user_from_group.Rd @@ -28,6 +28,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()}, diff --git a/man/remove_user_from_site.Rd b/man/remove_user_from_site.Rd index 7a50779..c329ea6 100644 --- a/man/remove_user_from_site.Rd +++ b/man/remove_user_from_site.Rd @@ -28,6 +28,7 @@ Other Tableau REST API: \code{\link{add_user_to_group}()}, \code{\link{add_user_to_site}()}, \code{\link{authenticate_server}()}, +\code{\link{create_group}()}, \code{\link{download_filtered_tableau_image}()}, \code{\link{download_tableau_crosstab_excel}()}, \code{\link{download_tableau_data}()},