from __future__ import absolute_import

import six

from collections import namedtuple, defaultdict
from django.db.models import Q
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _

from sentry.identity.pipeline import IdentityProviderPipeline
from sentry.integrations import (
    IntegrationFeatures,
    IntegrationMetadata,
    IntegrationProvider,
    FeatureDescription,
    IntegrationInstallation,
)

from sentry.models import AuditLogEntryEvent, Integration, Organization, Rule, RuleStatus
from sentry.pipeline import NestedPipelineView, PipelineView
from sentry.utils.compat import map
from sentry.utils.http import absolute_uri
from sentry.shared_integrations.exceptions import ApiError, IntegrationError
from sentry.integrations.slack import post_migration
from sentry.utils.audit import create_audit_entry

from .client import SlackClient
from .utils import logger, get_integration_type

from sentry.web.helpers import render_to_response


Channel = namedtuple("Channel", ["name", "id"])

DESCRIPTION = """
Connect your Sentry organization to one or more Slack workspaces, and start