Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make email_alert field available via services API #700

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jakubgs
Copy link

@jakubgs jakubgs commented Oct 21, 2020

I've attempted to make it possible to enable email alerts by default by adding email_alert and it did't work.

The addition of is_public worked and makes it possible to create public services via API.

Resolves: #699

@jakubgs
Copy link
Author

jakubgs commented Oct 21, 2020

I can see that email_alert field:

email_alert = models.BooleanField(default=False)

Is part of CheckGroupMixin class:
class CheckGroupMixin(models.Model):

Which is inherited by the Service class:
class Service(CheckGroupMixin):

Which contains the is_public attribute:
is_public = models.BooleanField(
verbose_name='Is Public',
default=False,
help_text='The service will be shown in the public home'
)

So I'm not sure why email_alert doesn't work. They are both BooleanField type.

@jakubgs
Copy link
Author

jakubgs commented Oct 21, 2020

The field overall_status that is included in the services API endpoint:

cabot/cabot/rest_urls.py

Lines 50 to 57 in b18b1a0

router.register(r'services', create_viewset(
arg_model=models.Service,
arg_fields=check_group_mixin_fields + (
'url',
'instances',
'overall_status',
),
))

Seems to come from CheckGroupMixin:
overall_status = models.TextField(default=PASSING_STATUS)

And that one works fine.

@jakubgs
Copy link
Author

jakubgs commented Oct 21, 2020

Oh, I see, there's a separate alerts field that is a list of types of alerts enabled:

alerts = models.ManyToManyField(
'AlertPlugin',
blank=True,
help_text='Alerts channels through which you wish to be notified'
)

That's a bit confusing, but I figured that out based on the template. And this field is already exported.

@jakubgs
Copy link
Author

jakubgs commented Oct 21, 2020

It appears that 1 is the ID of the email alert type:

  {
    "name": "Websites",
    "users_to_notify": [
      2
    ],
    "alerts_enabled": true,
    "status_checks": [
      31,
    ],
    "alerts": [
      1
    ],
    "hackpad_id": "",
    "url": "https://example.org",
    "instances": [],
    "overall_status": "PASSING",
    "email_alert": true,
    "is_public": true,
    "id": 1
  }

Not sure where that's defined, but I assume it doesn't change.

@jakubgs jakubgs changed the title make email_alert and is_public available via services API make email_alert field available via services API Oct 21, 2020
@jakubgs
Copy link
Author

jakubgs commented Oct 21, 2020

I've dropped the addition of email_alert field.

Pip 21.0 drops support for Python 2:
https://pip.pypa.io/en/stable/news/#v21-0

Signed-off-by: Jakub Sokołowski <[email protected]>
Also use HTTPS for NPM package registry.

Signed-off-by: Jakub Sokołowski <[email protected]>
[email protected]

RUN pip install --upgrade pip
RUN pip install --upgrade pip==20.3.4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The related commit messages says "20.4.5" but the code says "20.3.4" 🤔 😃 How about pip<21? Gave me 20.3.4 in practice over here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The is_public setting for services appears to be ignored
2 participants