Ejemplo n.º 1
0
        /// <summary>
        /// <see cref="ITableauGroupService.DeleteGroupAsync"/>
        /// </summary>
        public async Task DeleteGroupAsync(string id)
        {
            _logger?.Debug($"Deleting group {id}");

            var url = _tableauApiService.SiteUrl.AppendUri($"groups/{id}");

            var responseString = await _tableauApiService.SendDeleteAsync(url).ConfigureAwait(false);

            _logger?.Debug($"Response: {responseString}");

            _logger?.Debug($"Group {id} deleted");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// <see cref="ITableauUserService.RemoveUserFromSiteAsync"/>
        /// </summary>
        public async Task RemoveUserFromSiteAsync(string id)
        {
            _logger?.Debug($"Removing user {id} from site {_tableauApiService.SiteId}");

            var url = _tableauApiService.SiteUrl.AppendUri($"users/{id}");

            var responseString = await _tableauApiService.SendDeleteAsync(url).ConfigureAwait(false);

            _logger?.Debug($"Response: {responseString}");

            _logger?.Debug($"User {id} removed from site {_tableauApiService.SiteId}");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// <see cref="ITableauPermissionService.DeletePermissionAsync"/>
        /// </summary>
        public async Task DeletePermissionAsync(TableauPermission permission)
        {
            _logger?.Debug($"Deleting permission");
            var resourceTypeName = "";
            var resourceId       = "";

            if (permission.Datasource != null)
            {
                resourceTypeName = ResourceType.Datasource.ToString().ToLower();
                resourceId       = permission.Datasource.Id;
            }
            else if (permission.Project != null)
            {
                resourceTypeName = ResourceType.Project.ToString().ToLower();
                resourceId       = permission.Project.Id;
            }
            else if (permission.Workbook != null)
            {
                resourceTypeName = ResourceType.Workbook.ToString().ToLower();
                resourceId       = permission.Workbook.Id;
            }

            foreach (var granteeCapability in permission.GranteeCapabilities)
            {
                var granteeTypeName = "";
                var granteeId       = "";
                if (granteeCapability.Group != null)
                {
                    granteeTypeName = GranteeType.Group.ToString().ToLower();
                    granteeId       = granteeCapability.Group.Id;
                }
                else if (granteeCapability.User != null)
                {
                    granteeTypeName = GranteeType.User.ToString().ToLower();
                    granteeId       = granteeCapability.User.Id;
                }
                else
                {
                    throw new Exception("Unsupported resource/object type");
                }

                foreach (var capability in granteeCapability.Capabilities.Capability)
                {
                    _logger?.Debug(
                        String.Format(
                            "Deleting permission for {0} {1} to {2} {3}: {4} {5}",
                            resourceTypeName,
                            resourceId,
                            granteeTypeName,
                            granteeId,
                            capability.Mode,
                            capability.Name
                            )
                        );

                    var url = _tableauApiService.SiteUrl.AppendUri(
                        $"{resourceTypeName}s/{resourceId}/permissions/{granteeTypeName}s/{granteeId}/" +
                        $"{capability.Name}/{capability.Mode}"
                        );

                    try
                    {
                        var responseString = await _tableauApiService.SendDeleteAsync(url).ConfigureAwait(false);

                        _logger?.Debug($"Response: {responseString}");
                        _logger?.Debug($"Permission deleted");
                    }
                    catch (Exception ex)
                    {
                        _logger?.Error($"Error deleting permission: {ex.ToString()}");
                    }
                }
            }

            _logger?.Debug($"Permission deleted");
        }