Skip to content

make email_alert field available via services API#700

Open
jakubgs wants to merge 4 commits into
arachnys:masterfrom
status-im:add-service-fields
Open

make email_alert field available via services API#700
jakubgs wants to merge 4 commits into
arachnys:masterfrom
status-im:add-service-fields

Conversation

@jakubgs

@jakubgs jakubgs commented Oct 21, 2020

Copy link
Copy Markdown

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

jakubgs commented Oct 21, 2020

Copy link
Copy Markdown
Author

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

jakubgs commented Oct 21, 2020

Copy link
Copy Markdown
Author

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

jakubgs commented Oct 21, 2020

Copy link
Copy Markdown
Author

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

jakubgs commented Oct 21, 2020

Copy link
Copy Markdown
Author

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 force-pushed the add-service-fields branch from 6841f8f to bb5ec32 Compare October 21, 2020 17:04
@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

jakubgs commented Oct 21, 2020

Copy link
Copy Markdown
Author

I've dropped the addition of email_alert field.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
Pip 21.0 drops support for Python 2:
https://pip.pypa.io/en/stable/news/#v21-0

Signed-off-by: Jakub Sokołowski <jakub@status.im>
Also use HTTPS for NPM package registry.

Signed-off-by: Jakub Sokołowski <jakub@status.im>
arachnys#698

Signed-off-by: Jakub Sokołowski <jakub@status.im>
Comment thread Dockerfile
less@1.3

RUN pip install --upgrade pip
RUN pip install --upgrade pip==20.3.4

Copy link
Copy Markdown
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