def get_provider_name(provider_type, provider_slug):
    """
    The things that users think of as "integrations" are actually three
    different things: integrations, plugins, and sentryapps. A user requesting
    than an integration be installed only actually knows the "provider" they
    want and not what type they want. This function looks up the display name
    for the integration they want installed.

    :param provider_type: One of: "first_party", "plugin", or "sentry_app".
    :param provider_slug: The unique identifier for the provider.
    :return: The display name for the provider.

    :raises: ValueError if provider_type is not one of the three from above.
    :raises: RuntimeError if the provider is not found.
    """
    try:
        if provider_type == "first_party":
            return integrations.get(provider_slug).name
        elif provider_type == "plugin":
            return plugins.get(provider_slug).title
        elif provider_type == "sentry_app":
            return SentryApp.objects.get(slug=provider_slug).name
        else:
            raise ValueError(f"Invalid providerType {provider_type}")
    except (KeyError, SentryApp.DoesNotExist):
        raise RuntimeError(f"Provider {provider_slug} not found")
 def has_one_required_feature(self, org, user):
     provider = integrations.get(self.provider)
     integration_features = [f"organizations:integrations-{f.value}" for f in provider.features]
     for flag_name in integration_features:
         try:
             if features.has(flag_name, org, actor=user):
                 return True
         # we have some integration features that are not actually
         # registered. Those features are unrestricted.
         except FeatureNotRegistered:
             return True
     return False
Exemplo n.º 3
0
def get_provider_name(provider_type: str, provider_slug: str) -> str | None:
    """
    The things that users think of as "integrations" are actually three
    different things: integrations, plugins, and sentryapps. A user requesting
    than an integration be installed only actually knows the "provider" they
    want and not what type they want. This function looks up the display name
    for the integration they want installed.

    :param provider_type: One of: "first_party", "plugin", or "sentry_app".
    :param provider_slug: The unique identifier for the provider.
    :return: The display name for the provider or None.
    """
    if provider_type == "first_party":
        if integrations.exists(provider_slug):
            return integrations.get(provider_slug).name
    elif provider_type == "plugin":
        if plugins.exists(provider_slug):
            return plugins.get(provider_slug).title
    elif provider_type == "sentry_app":
        sentry_app = SentryApp.objects.filter(slug=provider_slug).first()
        if sentry_app:
            return sentry_app.name
    return None
Exemplo n.º 4
0
    def get_provider(self):
        from sentry import integrations

        return integrations.get(self.provider)
Exemplo n.º 5
0
 def get_provider(self):
     from sentry import integrations
     return integrations.get(self.provider)