-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a pediodic job to sync tenants with chatops-proxy. Register request will behave as upsert, allowing us to backfill new tenant's columns: stack_id and stack_slug. Upsert is not merged on chatops-proxy, so that's why task handling 409 status on /tenants/register request. On top of that, I did small refactoring and introduced a new register_oncall_tenant func, which receives org as an argument to not to write `register_tenant(org.uuid, org.stack_id, org.stack_slug,.....)` every time. Part of grafana/oncall-gateway#247 Need to be merged after #4559.
- Loading branch information
1 parent
5cf921b
commit 48b7eca
Showing
6 changed files
with
114 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# register_oncall_tenant moved to separate file from engine/apps/chatops_proxy/utils.py to avoid circular imports. | ||
from django.conf import settings | ||
|
||
from apps.chatops_proxy.client import SERVICE_TYPE_ONCALL, ChatopsProxyAPIClient | ||
|
||
|
||
def register_oncall_tenant(org): | ||
""" | ||
register_oncall_tenant registers oncall organization as a tenant in chatops-proxy. | ||
""" | ||
client = ChatopsProxyAPIClient(settings.ONCALL_GATEWAY_URL, settings.ONCALL_GATEWAY_API_TOKEN) | ||
client.register_tenant( | ||
str(org.uuid), | ||
settings.ONCALL_BACKEND_REGION, | ||
SERVICE_TYPE_ONCALL, | ||
org.stack_id, | ||
org.stack_slug, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters