Skip to content

Commit

Permalink
Add action to promote a user to an admin (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
amandahla authored Oct 23, 2023
1 parent e1b949b commit 818711a
Show file tree
Hide file tree
Showing 22 changed files with 978 additions and 457 deletions.
9 changes: 9 additions & 0 deletions actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,12 @@ register-user:
default: false
required:
- username
promote-user-admin:
description: |
Promote a user as a server administrator.
You need to supply a user name.
properties:
username:
description: |
User name to be promoted to admin.
type: string
1 change: 1 addition & 0 deletions generate-src-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.

rm -rf src-docs
lazydocs --no-watermark --output-path src-docs src/*
78 changes: 50 additions & 28 deletions src-docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Helper module used to manage interactions with Synapse API.
- **SYNAPSE_PORT**
- **SYNAPSE_URL**
- **ADD_USER_ROOM_URL**
- **PROMOTE_USER_ADMIN_URL**
- **CREATE_ROOM_URL**
- **DEACTIVATE_ACCOUNT_URL**
- **LIST_ROOMS_URL**
Expand All @@ -23,7 +24,7 @@ Helper module used to manage interactions with Synapse API.

---

<a href="../src/synapse/api.py#L96"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L159"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `register_user`

Expand Down Expand Up @@ -61,7 +62,7 @@ Register user.

---

<a href="../src/synapse/api.py#L213"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L276"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `get_version`

Expand Down Expand Up @@ -90,7 +91,7 @@ We're using retry here because after the config change, Synapse is restarted.

---

<a href="../src/synapse/api.py#L245"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L308"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `get_access_token`

Expand Down Expand Up @@ -124,7 +125,7 @@ This is a way to do actions on behalf of a user.

---

<a href="../src/synapse/api.py#L274"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L337"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `override_rate_limit`

Expand All @@ -149,7 +150,7 @@ Override user's rate limit.

---

<a href="../src/synapse/api.py#L292"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L353"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `get_room_id`

Expand Down Expand Up @@ -180,7 +181,7 @@ Get room id.

---

<a href="../src/synapse/api.py#L328"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L389"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `deactivate_user`

Expand All @@ -201,7 +202,7 @@ Deactivate user.

---

<a href="../src/synapse/api.py#L350"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L409"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `create_management_room`

Expand Down Expand Up @@ -231,7 +232,7 @@ Create the management room to be used by Mjolnir.

---

<a href="../src/synapse/api.py#L404"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L461"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `make_room_admin`

Expand All @@ -258,14 +259,35 @@ Make user a room's admin.

---

<a href="../src/synapse/api.py#L43"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L476"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `promote_user_admin`

```python
promote_user_admin(user: User, server: str, admin_access_token: str) → None
```

Promote user to admin.



**Args:**

- <b>`user`</b>: user to be promoted to admin.
- <b>`server`</b>: to be used to promote the user id.
- <b>`admin_access_token`</b>: server admin access token to be used.


---

<a href="../src/synapse/api.py#L45"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `APIError`
Exception raised when something fails while calling the API.

Attrs: msg (str): Explanation of the error.

<a href="../src/synapse/api.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -287,12 +309,12 @@ Initialize a new instance of the APIError exception.

---

<a href="../src/synapse/api.py#L59"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L61"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `NetworkError`
Exception raised when requesting API fails due network issues.

<a href="../src/synapse/api.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -314,12 +336,12 @@ Initialize a new instance of the APIError exception.

---

<a href="../src/synapse/api.py#L63"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L65"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `GetNonceError`
Exception raised when getting nonce fails.

<a href="../src/synapse/api.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -341,12 +363,12 @@ Initialize a new instance of the APIError exception.

---

<a href="../src/synapse/api.py#L67"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L69"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `GetVersionError`
Exception raised when getting version fails.

<a href="../src/synapse/api.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -368,12 +390,12 @@ Initialize a new instance of the APIError exception.

---

<a href="../src/synapse/api.py#L71"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L73"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `VersionUnexpectedContentError`
Exception raised when output of getting version is unexpected.

<a href="../src/synapse/api.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -395,12 +417,12 @@ Initialize a new instance of the APIError exception.

---

<a href="../src/synapse/api.py#L75"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L77"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `GetRoomIDError`
Exception raised when getting room id fails.

<a href="../src/synapse/api.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -422,12 +444,12 @@ Initialize a new instance of the APIError exception.

---

<a href="../src/synapse/api.py#L79"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L81"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `GetUserIDError`
Exception raised when getting user id fails.

<a href="../src/synapse/api.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -449,12 +471,12 @@ Initialize a new instance of the APIError exception.

---

<a href="../src/synapse/api.py#L83"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L85"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `UserExistsError`
Exception raised when checking if user exists fails.

<a href="../src/synapse/api.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -476,12 +498,12 @@ Initialize a new instance of the APIError exception.

---

<a href="../src/synapse/api.py#L87"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L89"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `GetAccessTokenError`
Exception raised when getting access token fails.

<a href="../src/synapse/api.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand All @@ -503,12 +525,12 @@ Initialize a new instance of the APIError exception.

---

<a href="../src/synapse/api.py#L91"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L93"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `RegisterUserError`
Exception raised when registering user fails.

<a href="../src/synapse/api.py#L50"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/synapse/api.py#L52"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

Expand Down
29 changes: 26 additions & 3 deletions src-docs/charm.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@
# <kbd>module</kbd> `charm.py`
Charm for Synapse on kubernetes.

**Global Variables**
---------------
- **JUJU_HAS_SECRETS**
- **PEER_RELATION_NAME**
- **SECRET_ID**
- **SECRET_KEY**


---

## <kbd>class</kbd> `SynapseCharm`
Charm the service.

<a href="../src/charm.py#L32"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/charm.py#L41"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `__init__`

Expand Down Expand Up @@ -69,7 +75,7 @@ Unit that this execution is responsible for.

---

<a href="../src/charm.py#L89"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/charm.py#L101"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `change_config`

Expand All @@ -81,7 +87,24 @@ Change configuration.

---

<a href="../src/charm.py#L79"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../src/charm.py#L211"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `get_admin_access_token`

```python
get_admin_access_token() → Optional[str]
```

Get admin access token.



**Returns:**
admin access token or None if fails.

---

<a href="../src/charm.py#L91"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>function</kbd> `replan_nginx`

Expand Down
15 changes: 14 additions & 1 deletion src-docs/charm_state.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,20 @@ Configuration for accessing Synapse through proxy.
## <kbd>class</kbd> `SynapseConfig`
Represent Synapse builtin configuration values.

Attrs: server_name: server_name config. report_stats: report_stats config. public_baseurl: public_baseurl config. enable_mjolnir: enable_mjolnir config. smtp_enable_tls: enable tls while connecting to SMTP server. smtp_host: SMTP host. smtp_notif_from: defines the "From" address to use when sending emails. smtp_pass: password to authenticate to SMTP host. smtp_port: SMTP port. smtp_user: username to autehtncate to SMTP host.


**Attributes:**

- <b>`server_name`</b>: server_name config.
- <b>`report_stats`</b>: report_stats config.
- <b>`public_baseurl`</b>: public_baseurl config.
- <b>`enable_mjolnir`</b>: enable_mjolnir config.
- <b>`smtp_enable_tls`</b>: enable tls while connecting to SMTP server.
- <b>`smtp_host`</b>: SMTP host.
- <b>`smtp_notif_from`</b>: defines the "From" address to use when sending emails.
- <b>`smtp_pass`</b>: password to authenticate to SMTP host.
- <b>`smtp_port`</b>: SMTP port.
- <b>`smtp_user`</b>: username to authenticate to SMTP host.



Expand Down
35 changes: 0 additions & 35 deletions src-docs/constants.py.md

This file was deleted.

Loading

0 comments on commit 818711a

Please sign in to comment.