lib/rally_user_helper.rb
# Project permissions are automatically deleted in this case
Project permissions are automatically deleted in this case
Project permissions are automatically deleted in this case
def delete_workspace_permission(user, workspace)
      if @upgrade_only_mode then
        @logger.info "  #{user["UserName"]} #{workspace["Name"]} - upgrade_only_mode == true."
        @logger.warn "  Proposed Permission: #{NOACCESS}"
        @logger.info "  Proposed Permission change would downgrade permissions. No permission updates applied."
        return
      end
      workspace_permission_query = RallyAPI::RallyQuery.new()
      workspace_permission_query.type = :workspacepermission
      workspace_permission_query.fetch = "Workspace,Name,ObjectID,Role,User,UserName"
      workspace_permission_query.page_size = 200 
      workspace_permission_query.order = "Name Asc"
      workspace_permission_query.query_string = "(User.UserName = \"" + user.UserName + "\")"
      query_results = @rally.find(workspace_permission_query)
      query_results.each do | this_workspace_permission |
        this_workspace = this_workspace_permission.Workspace
        this_workspace_oid = this_workspace["ObjectID"].to_s
        if this_workspace_permission != nil && this_workspace_oid == workspace["ObjectID"].to_s
          begin
            @rally.delete(this_workspace_permission["_ref"])
          rescue Exception => ex
            this_user = this_workspace_permission.User
            this_user_name = this_user.Name
            @logger.warn "Cannot remove WorkspacePermission: #{this_workspace_permission.Name}."
            @logger.warn "WorkspacePermission either already NoAccess, or would remove the only WorkspacePermission in Subscription."
            @logger.warn "User #{this_user_name} must have access to at least one Workspace within the Subscription."
          end
        end
      end
    end
def delete_workspace_permission ( user , workspace ) if @upgrade_only_mode then @logger . info "  #{user["UserName"]} #{workspace["Name"]} - upgrade_only_mode == true." @logger . warn "  Proposed Permission: #{NOACCESS}" @logger . info "  Proposed Permission change would downgrade permissions. No permission updates applied." return end workspace_permission_query = RallyAPI :: RallyQuery . new ( ) workspace_permission_query . type = :workspacepermission workspace_permission_query . fetch = "Workspace,Name,ObjectID,Role,User,UserName" workspace_permission_query . page_size = 200 workspace_permission_query . order = "Name Asc" workspace_permission_query . query_string = "(User.UserName = \"" + user . UserName + "\")" query_results = @rally . find ( workspace_permission_query ) query_results . each do | this_workspace_permission | this_workspace = this_workspace_permission . Workspace this_workspace_oid = this_workspace [ "ObjectID" ] . to_s if this_workspace_permission != nil && this_workspace_oid == workspace [ "ObjectID" ] . to_s begin @rally . delete ( this_workspace_permission [ "_ref" ] ) rescue Exception => ex this_user = this_workspace_permission . User this_user_name = this_user . Name @logger . warn "Cannot remove WorkspacePermission: #{this_workspace_permission.Name}." @logger . warn "WorkspacePermission either already NoAccess, or would remove the only WorkspacePermission in Subscription." @logger . warn "User #{this_user_name} must have access to at least one Workspace within the Subscription." end end end end
Project permissions are automatically deleted in this case
Project permissions are automatically deleted in this case
# queries on permissions are a bit limited - to only one filter parameter #optional - default is 200
user
workspace