From 035e8a158aa73fcc7876133da49b75eea112ad28 Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Mon, 4 Dec 2023 13:14:30 +0100 Subject: [PATCH 01/32] Add smtp interface --- interfaces/smtp/README.md | 57 ++++++++++ interfaces/smtp/charms.yaml | 6 ++ .../smtp/interface_tests/test_provider.py | 15 +++ interfaces/smtp/schema.py | 102 ++++++++++++++++++ 4 files changed, 180 insertions(+) create mode 100644 interfaces/smtp/README.md create mode 100644 interfaces/smtp/charms.yaml create mode 100644 interfaces/smtp/interface_tests/test_provider.py create mode 100644 interfaces/smtp/schema.py diff --git a/interfaces/smtp/README.md b/interfaces/smtp/README.md new file mode 100644 index 00000000..109ac50c --- /dev/null +++ b/interfaces/smtp/README.md @@ -0,0 +1,57 @@ +# `smtp` + +## Overview + +This relation interface describes the expected behavior between of any charm claiming to be able to interface with a SMTP Provider and the SMTP Provider itself. + +## Usage + +In most cases, this will be accomplished using the [smtp library](https://github.com/canonical/smtp-integrator-operator/blob/main/lib/charms/smtp_integrator/v0/smtp.py), although charm developers are free to provide alternative libraries as long as they fulfil the behavioural and schematic requirements described in this document. + +## Direction + +The `smtp` interface implements a provider/requirer pattern. +The requirer is a charm that requires SMTP details to connect to an SMTP server, and the provider is a charm holding those details. + +```mermaid +flowchart TD + Provider -- host, port, user, password_id, auth_type, transport_security, domain --> Requirer +``` + +## Behavior + +The requirer and the provider must adhere to a certain set of criteria to be considered compatible with the interface. + +### Provider + +- Is expected to provide the host in the relation databag. +- Is expected to provide the port in the relation databag. +- Is expected to provide the auth_type in the relation databag. +- Is expected to provide the transport_security in the relation databag. + +### Requirer + +- Is not expected to provide anything + +## Relation Data + +### Provider + +[\[JSON Schema\]](./schemas/provider.json) + +Provider provides the SMTP configuration. It should be placed in the **application** databag. + +#### Example + +```yaml +related-units: {} +application_data: { + "host": "example.smtp", + "port": "25", + "user": "example_user", + "password_id": "01548499c9233d4612352c989162d940f6a9e6f6d5cc058dfcf66f51575e09c2", + "auth_type": "plain", + "transport_security": "tls", + "domain": "domain", +} +``` diff --git a/interfaces/smtp/charms.yaml b/interfaces/smtp/charms.yaml new file mode 100644 index 00000000..738f7f5c --- /dev/null +++ b/interfaces/smtp/charms.yaml @@ -0,0 +1,6 @@ +providers: + - name: smtp-integrator + url: https://github.com/canonical/smtp-integrator-operator + +requirers: + [] diff --git a/interfaces/smtp/interface_tests/test_provider.py b/interfaces/smtp/interface_tests/test_provider.py new file mode 100644 index 00000000..33a77316 --- /dev/null +++ b/interfaces/smtp/interface_tests/test_provider.py @@ -0,0 +1,15 @@ +# Copyright 2023 Canonical +# See LICENSE file for licensing details. +from interface_tester.interface_test import Tester +from scenario import Relation, State + + +def test_data_published_on_created(): + t = Tester(State( + relations=[Relation( + endpoint="saml", + interface="saml", + )], + )) + t.run("saml-relation-created") + t.assert_schema_valid() diff --git a/interfaces/smtp/schema.py b/interfaces/smtp/schema.py new file mode 100644 index 00000000..50425136 --- /dev/null +++ b/interfaces/smtp/schema.py @@ -0,0 +1,102 @@ +# Copyright 2023 Canonical +# See LICENSE file for licensing details. +"""This file defines the schema for the provider side of the saml interface. + +It exposes one interfaces.schema_base.DataBagSchema subclass called: +- ProviderSchema + +Examples: + ProviderSchema: + unit: + app: {"smtp": + { + "host": "example.smtp", + "port": "25", + "user": "example_user", + "password_id": "01548499c9233d4612352c989162d940f6a9e6f6d5cc058dfcf66f51575e09c2", + "auth_type": "plain", + "transport_security": "tls", + "domain": "domain", + } + } +""" +from interface_tester.schema_base import DataBagSchema +from pydantic import AnyHttpUrl, BaseModel, Field +from typing import Optional + + +class TransportSecurity(str, Enum): + """Represent the transport security values. + + Attributes: + NONE: none + STARTTLS: starttls + TLS: tls + """ + + NONE = "none" + STARTTLS = "starttls" + TLS = "tls" + + +class AuthType(str, Enum): + """Represent the auth type values. + + Attributes: + NONE: none + NOT_PROVIDED: not_provided + PLAIN: plain + """ + + NONE = "none" + NOT_PROVIDED = "not_provided" + PLAIN = "plain" + +class SmtpProviderData(BaseModel): + host: str = Field( + ..., + min_length=1, + description="SMTP host.", + title="Host", + examples=["example.smtp"], + ) + port: int = Field(None, + ge=1, + le=65536, + description="SMTP port.", + title="Port", + examples=[25], + ) + user: Optional[str] = Field( + description="SMTP user.", + title="User", + examples=["some_user"], + ) + password_id: Optional[str] = Field( + description="Secret ID for the SMTP password.", + title="Password id", + examples=["01548499c9233d4612352c989162d940f6a9e6f6d5cc058dfcf66f51575e09c2"], + ) + auth_type: AuthType = Field( + description="The type used to authenticate with the SMTP relay.", + title="Auth type", + examples=[AuthType.NONE], + ) + transport_security: TransportSecurity = Field( + description="The security protocol to use for the outgoing SMTP relay.", + title="Transport security", + examples=[TransportSecurity.NONE], + ) + domain: Optional[str] = Field( + description="The domain used by the sent emails from SMTP relay.", + title="Domain", + examples=["domain"], + ) + + +class ProviderSchema(DataBagSchema): + """Provider schema for SMTP.""" + app: SmtpProviderData + +class RequirerSchema(DataBagSchema): + """Requirer schema for SMTP.""" From c92a5655196adb79c1b972c4b70820dbdd845f00 Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Mon, 4 Dec 2023 13:25:01 +0100 Subject: [PATCH 02/32] Add smtp interface --- README.md | 1 + interfaces/smtp/schema.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2d6fba54..5bfee140 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ To quickly get started, see the [template interface](https://github.com/canonica | | [`auth_proxy`](interfaces/auth_proxy/v0/README.md) | ![Status: Draft](https://img.shields.io/badge/Status-Draft-orange) | | | [`openfga`](interfaces/openfga/v0/README.md) | ![Status: Live](https://img.shields.io/badge/Status-Live-darkgreen) | | | [`saml`](interfaces/saml/v0/README.md) | ![Status: Live](https://img.shields.io/badge/Status-Live-darkgreen) | +| | [`smtp`](interfaces/smtp/v0/README.md) | ![Status: Live](https://img.shields.io/badge/Status-Live-darkgreen) | | Observability | [`grafana_auth`](interfaces/grafana_auth/v0/README.md) | ![Status: Draft](https://img.shields.io/badge/Status-Draft-orange) | | | [`prometheus_remote_write`](interfaces/prometheus_remote_write/v0/README.md) | ![Status: Live](https://img.shields.io/badge/Status-Live-darkgreen) | | | [`prometheus_scrape`](interfaces/prometheus_scrape/v0/README.md) | ![Status: Live](https://img.shields.io/badge/Status-Live-darkgreen) | diff --git a/interfaces/smtp/schema.py b/interfaces/smtp/schema.py index 50425136..95e360f9 100644 --- a/interfaces/smtp/schema.py +++ b/interfaces/smtp/schema.py @@ -20,8 +20,9 @@ } } """ +from enum import Enum from interface_tester.schema_base import DataBagSchema -from pydantic import AnyHttpUrl, BaseModel, Field +from pydantic import BaseModel, Field from typing import Optional From 01cb82ac5cdb79e1b9e0b78778b3cb189b6b80a9 Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Mon, 4 Dec 2023 13:26:04 +0100 Subject: [PATCH 03/32] Add smtp interface --- interfaces/smtp/interface_tests/test_provider.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interfaces/smtp/interface_tests/test_provider.py b/interfaces/smtp/interface_tests/test_provider.py index 33a77316..0bd7d41c 100644 --- a/interfaces/smtp/interface_tests/test_provider.py +++ b/interfaces/smtp/interface_tests/test_provider.py @@ -7,9 +7,9 @@ def test_data_published_on_created(): t = Tester(State( relations=[Relation( - endpoint="saml", - interface="saml", + endpoint="smtp", + interface="smtp", )], )) - t.run("saml-relation-created") + t.run("smtp-relation-created") t.assert_schema_valid() From d4487e335a3709e978318fd3538c65b005d9fe25 Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Mon, 4 Dec 2023 13:27:24 +0100 Subject: [PATCH 04/32] Add smtp interface --- interfaces/smtp/{ => v0}/README.md | 0 interfaces/smtp/{ => v0}/charms.yaml | 0 interfaces/smtp/{ => v0}/interface_tests/test_provider.py | 0 interfaces/smtp/{ => v0}/schema.py | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename interfaces/smtp/{ => v0}/README.md (100%) rename interfaces/smtp/{ => v0}/charms.yaml (100%) rename interfaces/smtp/{ => v0}/interface_tests/test_provider.py (100%) rename interfaces/smtp/{ => v0}/schema.py (100%) diff --git a/interfaces/smtp/README.md b/interfaces/smtp/v0/README.md similarity index 100% rename from interfaces/smtp/README.md rename to interfaces/smtp/v0/README.md diff --git a/interfaces/smtp/charms.yaml b/interfaces/smtp/v0/charms.yaml similarity index 100% rename from interfaces/smtp/charms.yaml rename to interfaces/smtp/v0/charms.yaml diff --git a/interfaces/smtp/interface_tests/test_provider.py b/interfaces/smtp/v0/interface_tests/test_provider.py similarity index 100% rename from interfaces/smtp/interface_tests/test_provider.py rename to interfaces/smtp/v0/interface_tests/test_provider.py diff --git a/interfaces/smtp/schema.py b/interfaces/smtp/v0/schema.py similarity index 100% rename from interfaces/smtp/schema.py rename to interfaces/smtp/v0/schema.py From bde7546bd892861d4b42e1fcd8c54ec03f75fcbd Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Mon, 4 Dec 2023 13:40:10 +0100 Subject: [PATCH 05/32] Add smtp interface --- docs/json_schemas/smtp/v0/provider.json | 76 +++++++++++++++++++++++++ docs/json_schemas/smtp/v0/requirer.json | 20 +++++++ interfaces/smtp/v0/schema.py | 4 +- 3 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 docs/json_schemas/smtp/v0/provider.json create mode 100644 docs/json_schemas/smtp/v0/requirer.json diff --git a/docs/json_schemas/smtp/v0/provider.json b/docs/json_schemas/smtp/v0/provider.json new file mode 100644 index 00000000..b309ea93 --- /dev/null +++ b/docs/json_schemas/smtp/v0/provider.json @@ -0,0 +1,76 @@ +{ + "title": "ProviderSchema", + "description": "Provider schema for SMTP.", + "type": "object", + "properties": { + "unit": { + "$ref": "#/definitions/BaseModel" + }, + "app": { + "$ref": "#/definitions/SamlProviderData" + } + }, + "required": [ + "app" + ], + "definitions": { + "BaseModel": { + "title": "BaseModel", + "type": "object", + "properties": {} + }, + "SamlProviderData": { + "title": "SmtpProviderData", + "type": "object", + "properties": { + "host": { + "title": "Host", + "description": "SMTP host.", + "examples": ["example.smtp"], + "type": "string" + }, + "port": { + "title": "Port", + "description": "SMTP port.", + "examples": [25], + "type": "number" + }, + "user": { + "title": "User", + "description": "SMTP user.", + "examples": ["some_user"], + "type": "string" + }, + "password_id": { + "title": "Password ID", + "description": "Secret ID for the SMTP password.", + "examples": ["01548499c9233d4612352c989162d940f6a9e6f6d5cc058dfcf66f51575e09c2"], + "type": "string" + }, + "auth_type": { + "title": "Auth type", + "description": "The type used to authenticate with the SMTP relay.", + "examples": ["none"], + "type": "string" + }, + "transport_security": { + "title": "Transport security", + "description": "The security protocol to use for the outgoing SMTP relay.", + "examples": ["none"], + "type": "string" + }, + "domain": { + "title": "Domain", + "description": "The domain used by the sent emails from SMTP relay.", + "examples": ["domain"], + "type": "string" + } + }, + "required": [ + "host", + "auth_type", + "transport_security", + ] + } + } +} \ No newline at end of file diff --git a/docs/json_schemas/smtp/v0/requirer.json b/docs/json_schemas/smtp/v0/requirer.json new file mode 100644 index 00000000..41757db9 --- /dev/null +++ b/docs/json_schemas/smtp/v0/requirer.json @@ -0,0 +1,20 @@ +{ + "title": "RequirerSchema", + "description": "Requirer schema for SAML.", + "type": "object", + "properties": { + "unit": { + "$ref": "#/definitions/BaseModel" + }, + "app": { + "$ref": "#/definitions/BaseModel" + } + }, + "definitions": { + "BaseModel": { + "title": "BaseModel", + "type": "object", + "properties": {} + } + } +} \ No newline at end of file diff --git a/interfaces/smtp/v0/schema.py b/interfaces/smtp/v0/schema.py index 95e360f9..add884a6 100644 --- a/interfaces/smtp/v0/schema.py +++ b/interfaces/smtp/v0/schema.py @@ -1,6 +1,6 @@ # Copyright 2023 Canonical # See LICENSE file for licensing details. -"""This file defines the schema for the provider side of the saml interface. +"""This file defines the schema for the provider side of the smtp interface. It exposes one interfaces.schema_base.DataBagSchema subclass called: - ProviderSchema @@ -75,7 +75,7 @@ class SmtpProviderData(BaseModel): ) password_id: Optional[str] = Field( description="Secret ID for the SMTP password.", - title="Password id", + title="Password ID", examples=["01548499c9233d4612352c989162d940f6a9e6f6d5cc058dfcf66f51575e09c2"], ) auth_type: AuthType = Field( From 6495359312170b0a4e58df5c00f2d2a671e0cd12 Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Mon, 4 Dec 2023 18:08:38 +0100 Subject: [PATCH 06/32] Fix linting --- docs/json_schemas/smtp/v0/provider.json | 71 ++++++++++++++++++++----- 1 file changed, 58 insertions(+), 13 deletions(-) diff --git a/docs/json_schemas/smtp/v0/provider.json b/docs/json_schemas/smtp/v0/provider.json index b309ea93..4536949b 100644 --- a/docs/json_schemas/smtp/v0/provider.json +++ b/docs/json_schemas/smtp/v0/provider.json @@ -7,7 +7,7 @@ "$ref": "#/definitions/BaseModel" }, "app": { - "$ref": "#/definitions/SamlProviderData" + "$ref": "#/definitions/SmtpProviderData" } }, "required": [ @@ -19,57 +19,102 @@ "type": "object", "properties": {} }, - "SamlProviderData": { + "AuthType": { + "title": "AuthType", + "description": "Represent the auth type values.\n\nAttributes:\n NONE: none\n NOT_PROVIDED: not_provided\n PLAIN: plain", + "enum": [ + "none", + "not_provided", + "plain" + ], + "type": "string" + }, + "TransportSecurity": { + "title": "TransportSecurity", + "description": "Represent the transport security values.\n\nAttributes:\n NONE: none\n STARTTLS: starttls\n TLS: tls", + "enum": [ + "none", + "starttls", + "tls" + ], + "type": "string" + }, + "SmtpProviderData": { "title": "SmtpProviderData", "type": "object", "properties": { "host": { "title": "Host", "description": "SMTP host.", - "examples": ["example.smtp"], + "minLength": 1, + "examples": [ + "example.smtp" + ], "type": "string" }, "port": { "title": "Port", "description": "SMTP port.", - "examples": [25], - "type": "number" + "minimum": 1, + "maximum": 65536, + "examples": [ + 25 + ], + "type": "integer" }, "user": { "title": "User", "description": "SMTP user.", - "examples": ["some_user"], + "examples": [ + "some_user" + ], "type": "string" }, "password_id": { "title": "Password ID", "description": "Secret ID for the SMTP password.", - "examples": ["01548499c9233d4612352c989162d940f6a9e6f6d5cc058dfcf66f51575e09c2"], + "examples": [ + "01548499c9233d4612352c989162d940f6a9e6f6d5cc058dfcf66f51575e09c2" + ], "type": "string" }, "auth_type": { "title": "Auth type", "description": "The type used to authenticate with the SMTP relay.", - "examples": ["none"], - "type": "string" + "examples": [ + "none" + ], + "allOf": [ + { + "$ref": "#/definitions/AuthType" + } + ] }, "transport_security": { "title": "Transport security", "description": "The security protocol to use for the outgoing SMTP relay.", - "examples": ["none"], - "type": "string" + "examples": [ + "none" + ], + "allOf": [ + { + "$ref": "#/definitions/TransportSecurity" + } + ] }, "domain": { "title": "Domain", "description": "The domain used by the sent emails from SMTP relay.", - "examples": ["domain"], + "examples": [ + "domain" + ], "type": "string" } }, "required": [ "host", "auth_type", - "transport_security", + "transport_security" ] } } From 3ef1c7bb1525b15918af133ed95fc3990152c93b Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Tue, 5 Dec 2023 09:40:45 +0100 Subject: [PATCH 07/32] Fix json schemas --- docs/json_schemas/smtp/v0/requirer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/json_schemas/smtp/v0/requirer.json b/docs/json_schemas/smtp/v0/requirer.json index 41757db9..8176ddc0 100644 --- a/docs/json_schemas/smtp/v0/requirer.json +++ b/docs/json_schemas/smtp/v0/requirer.json @@ -1,6 +1,6 @@ { "title": "RequirerSchema", - "description": "Requirer schema for SAML.", + "description": "Requirer schema for SMTP.", "type": "object", "properties": { "unit": { From afdefe857d5f05c8dea83392172877f06e9a02d9 Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Tue, 5 Dec 2023 10:11:35 +0100 Subject: [PATCH 08/32] Add password field --- interfaces/smtp/v0/README.md | 7 +++++++ interfaces/smtp/v0/schema.py | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/interfaces/smtp/v0/README.md b/interfaces/smtp/v0/README.md index 109ac50c..5821879f 100644 --- a/interfaces/smtp/v0/README.md +++ b/interfaces/smtp/v0/README.md @@ -18,6 +18,13 @@ flowchart TD Provider -- host, port, user, password_id, auth_type, transport_security, domain --> Requirer ``` +or alternatively, if secrets are not supported by both sides + +```mermaid +flowchart TD + Provider -- host, port, user, password, auth_type, transport_security, domain --> Requirer +``` + ## Behavior The requirer and the provider must adhere to a certain set of criteria to be considered compatible with the interface. diff --git a/interfaces/smtp/v0/schema.py b/interfaces/smtp/v0/schema.py index add884a6..fc83043a 100644 --- a/interfaces/smtp/v0/schema.py +++ b/interfaces/smtp/v0/schema.py @@ -73,6 +73,11 @@ class SmtpProviderData(BaseModel): title="User", examples=["some_user"], ) + password_id: Optional[str] = Field( + description="SMTP password.", + title="Password", + examples=["somepasswd"], + ) password_id: Optional[str] = Field( description="Secret ID for the SMTP password.", title="Password ID", From 7af81059bc4548319d9e1030e2b720d2db17e1c9 Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Tue, 5 Dec 2023 11:07:15 +0100 Subject: [PATCH 09/32] Fix password field, docs and linting --- interfaces/smtp/v0/README.md | 14 +++++++------- .../smtp/v0/interface_tests/test_provider.py | 16 ++++++++++------ interfaces/smtp/v0/schema.py | 10 +++++++--- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/interfaces/smtp/v0/README.md b/interfaces/smtp/v0/README.md index 5821879f..517715ab 100644 --- a/interfaces/smtp/v0/README.md +++ b/interfaces/smtp/v0/README.md @@ -31,22 +31,22 @@ The requirer and the provider must adhere to a certain set of criteria to be con ### Provider -- Is expected to provide the host in the relation databag. -- Is expected to provide the port in the relation databag. -- Is expected to provide the auth_type in the relation databag. -- Is expected to provide the transport_security in the relation databag. +- Is expected to publish the `host` in the relation databag. +- Is expected to publish the `port` in the relation databag. +- Is expected to publish the `auth_type` in the relation databag. +- Is expected to publish the `transport_security` in the relation databag. ### Requirer -- Is not expected to provide anything +- Is not expected to publish anything ## Relation Data ### Provider -[\[JSON Schema\]](./schemas/provider.json) +[\[Pydantic Schema\]](./schema.py) -Provider provides the SMTP configuration. It should be placed in the **application** databag. +Provider publishes the SMTP configuration. It should be placed in the **application** databag. #### Example diff --git a/interfaces/smtp/v0/interface_tests/test_provider.py b/interfaces/smtp/v0/interface_tests/test_provider.py index 0bd7d41c..2dcbfc8b 100644 --- a/interfaces/smtp/v0/interface_tests/test_provider.py +++ b/interfaces/smtp/v0/interface_tests/test_provider.py @@ -5,11 +5,15 @@ def test_data_published_on_created(): - t = Tester(State( - relations=[Relation( - endpoint="smtp", - interface="smtp", - )], - )) + t = Tester( + State( + relations=[ + Relation( + endpoint="smtp", + interface="smtp", + ) + ], + ) + ) t.run("smtp-relation-created") t.assert_schema_valid() diff --git a/interfaces/smtp/v0/schema.py b/interfaces/smtp/v0/schema.py index fc83043a..8ef9e5f2 100644 --- a/interfaces/smtp/v0/schema.py +++ b/interfaces/smtp/v0/schema.py @@ -53,6 +53,7 @@ class AuthType(str, Enum): NOT_PROVIDED = "not_provided" PLAIN = "plain" + class SmtpProviderData(BaseModel): host: str = Field( ..., @@ -61,7 +62,8 @@ class SmtpProviderData(BaseModel): title="Host", examples=["example.smtp"], ) - port: int = Field(None, + port: int = Field( + None, ge=1, le=65536, description="SMTP port.", @@ -73,7 +75,7 @@ class SmtpProviderData(BaseModel): title="User", examples=["some_user"], ) - password_id: Optional[str] = Field( + password: Optional[str] = Field( description="SMTP password.", title="Password", examples=["somepasswd"], @@ -81,7 +83,7 @@ class SmtpProviderData(BaseModel): password_id: Optional[str] = Field( description="Secret ID for the SMTP password.", title="Password ID", - examples=["01548499c9233d4612352c989162d940f6a9e6f6d5cc058dfcf66f51575e09c2"], + examples=["secret:123213123123123123123"], ) auth_type: AuthType = Field( description="The type used to authenticate with the SMTP relay.", @@ -102,7 +104,9 @@ class SmtpProviderData(BaseModel): class ProviderSchema(DataBagSchema): """Provider schema for SMTP.""" + app: SmtpProviderData + class RequirerSchema(DataBagSchema): """Requirer schema for SMTP.""" From 6ae6c16c37a6356b0e5ff1ba96ec24a709701a1f Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Tue, 5 Dec 2023 11:20:39 +0100 Subject: [PATCH 10/32] Fix json schemas --- docs/json_schemas/smtp/v0/provider.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/json_schemas/smtp/v0/provider.json b/docs/json_schemas/smtp/v0/provider.json index 4536949b..8f6e1352 100644 --- a/docs/json_schemas/smtp/v0/provider.json +++ b/docs/json_schemas/smtp/v0/provider.json @@ -70,11 +70,19 @@ ], "type": "string" }, + "password": { + "title": "Password", + "description": "SMTP password.", + "examples": [ + "somepasswd" + ], + "type": "string" + }, "password_id": { "title": "Password ID", "description": "Secret ID for the SMTP password.", "examples": [ - "01548499c9233d4612352c989162d940f6a9e6f6d5cc058dfcf66f51575e09c2" + "secret:123213123123123123123" ], "type": "string" }, From d8669e6be56c05e1131a781b91d4ebe10b88b18a Mon Sep 17 00:00:00 2001 From: arturo-seijas <102022572+arturo-seijas@users.noreply.github.com> Date: Tue, 5 Dec 2023 11:57:30 +0100 Subject: [PATCH 11/32] Update interfaces/smtp/v0/README.md Co-authored-by: PietroPasotti --- interfaces/smtp/v0/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/smtp/v0/README.md b/interfaces/smtp/v0/README.md index 517715ab..23f33734 100644 --- a/interfaces/smtp/v0/README.md +++ b/interfaces/smtp/v0/README.md @@ -2,7 +2,7 @@ ## Overview -This relation interface describes the expected behavior between of any charm claiming to be able to interface with a SMTP Provider and the SMTP Provider itself. +This relation interface specification describes the expected behavior of charms integrating over the `smtp` Juju interface to provide or consume SMTP data. ## Usage From bb39ee503a0deff084d99a58bd35dbf4ad17b345 Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Tue, 5 Dec 2023 14:29:32 +0100 Subject: [PATCH 12/32] Improve descriptions --- =4 | 0 interfaces/smtp/v0/schema.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 =4 diff --git a/=4 b/=4 new file mode 100644 index 00000000..e69de29b diff --git a/interfaces/smtp/v0/schema.py b/interfaces/smtp/v0/schema.py index 8ef9e5f2..6114a936 100644 --- a/interfaces/smtp/v0/schema.py +++ b/interfaces/smtp/v0/schema.py @@ -81,7 +81,7 @@ class SmtpProviderData(BaseModel): examples=["somepasswd"], ) password_id: Optional[str] = Field( - description="Secret ID for the SMTP password.", + description="Juju secret ID for the SMTP password.", title="Password ID", examples=["secret:123213123123123123123"], ) From 79dc8350f9890255097cbb5811803c5cac276d8b Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Tue, 5 Dec 2023 14:33:53 +0100 Subject: [PATCH 13/32] Fix json schemas --- docs/json_schemas/smtp/v0/provider.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/json_schemas/smtp/v0/provider.json b/docs/json_schemas/smtp/v0/provider.json index 8f6e1352..fbd68e66 100644 --- a/docs/json_schemas/smtp/v0/provider.json +++ b/docs/json_schemas/smtp/v0/provider.json @@ -80,7 +80,7 @@ }, "password_id": { "title": "Password ID", - "description": "Secret ID for the SMTP password.", + "description": "Juju secret ID for the SMTP password.", "examples": [ "secret:123213123123123123123" ], From 1805a2c16d51f6de020a3b2bb4ece286592257af Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Mon, 11 Dec 2023 10:15:53 +0100 Subject: [PATCH 14/32] Fix password_id in schema example --- interfaces/smtp/v0/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/smtp/v0/schema.py b/interfaces/smtp/v0/schema.py index 6114a936..d6e0a0e2 100644 --- a/interfaces/smtp/v0/schema.py +++ b/interfaces/smtp/v0/schema.py @@ -13,7 +13,7 @@ "host": "example.smtp", "port": "25", "user": "example_user", - "password_id": "01548499c9233d4612352c989162d940f6a9e6f6d5cc058dfcf66f51575e09c2", + "password_id": "secret:123213123123123123123", "auth_type": "plain", "transport_security": "tls", "domain": "domain", From ce41444f739bc73d012821a41d3c777364a9764e Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Mon, 11 Dec 2023 10:16:57 +0100 Subject: [PATCH 15/32] Fix schema docstrings --- interfaces/smtp/v0/schema.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/interfaces/smtp/v0/schema.py b/interfaces/smtp/v0/schema.py index d6e0a0e2..2b2af274 100644 --- a/interfaces/smtp/v0/schema.py +++ b/interfaces/smtp/v0/schema.py @@ -27,13 +27,7 @@ class TransportSecurity(str, Enum): - """Represent the transport security values. - - Attributes: - NONE: none - STARTTLS: starttls - TLS: tls - """ + """Represent the transport security values.""" NONE = "none" STARTTLS = "starttls" @@ -41,13 +35,7 @@ class TransportSecurity(str, Enum): class AuthType(str, Enum): - """Represent the auth type values. - - Attributes: - NONE: none - NOT_PROVIDED: not_provided - PLAIN: plain - """ + """Represent the auth type values.""" NONE = "none" NOT_PROVIDED = "not_provided" From 2d9c04b08561e8cb020d4549a77adadff6ed6483 Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Mon, 11 Dec 2023 10:20:01 +0100 Subject: [PATCH 16/32] Fix readme --- interfaces/smtp/v0/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/smtp/v0/README.md b/interfaces/smtp/v0/README.md index 23f33734..c8363720 100644 --- a/interfaces/smtp/v0/README.md +++ b/interfaces/smtp/v0/README.md @@ -18,7 +18,7 @@ flowchart TD Provider -- host, port, user, password_id, auth_type, transport_security, domain --> Requirer ``` -or alternatively, if secrets are not supported by both sides +or alternatively, if secrets are not supported by either sides ```mermaid flowchart TD From 8aca137b97baa5ba2853739b6aba1bbeeb7eeb9a Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Mon, 11 Dec 2023 10:21:16 +0100 Subject: [PATCH 17/32] Add more port examples to the schema --- interfaces/smtp/v0/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/smtp/v0/schema.py b/interfaces/smtp/v0/schema.py index 2b2af274..c2948d51 100644 --- a/interfaces/smtp/v0/schema.py +++ b/interfaces/smtp/v0/schema.py @@ -56,7 +56,7 @@ class SmtpProviderData(BaseModel): le=65536, description="SMTP port.", title="Port", - examples=[25], + examples=[25, 587, 465], ) user: Optional[str] = Field( description="SMTP user.", From 59b8ed163501845e0caeec96449d45e7c146707b Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Mon, 11 Dec 2023 10:23:50 +0100 Subject: [PATCH 18/32] Change domain example in schema --- interfaces/smtp/v0/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/smtp/v0/schema.py b/interfaces/smtp/v0/schema.py index c2948d51..06130b35 100644 --- a/interfaces/smtp/v0/schema.py +++ b/interfaces/smtp/v0/schema.py @@ -86,7 +86,7 @@ class SmtpProviderData(BaseModel): domain: Optional[str] = Field( description="The domain used by the sent emails from SMTP relay.", title="Domain", - examples=["domain"], + examples=["example.com"], ) From c0e5bbf047ed56884028c4888e1275d61f06677a Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Mon, 11 Dec 2023 10:25:49 +0100 Subject: [PATCH 19/32] Change domain examples --- interfaces/smtp/v0/README.md | 4 ++-- interfaces/smtp/v0/schema.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/interfaces/smtp/v0/README.md b/interfaces/smtp/v0/README.md index c8363720..23eb718e 100644 --- a/interfaces/smtp/v0/README.md +++ b/interfaces/smtp/v0/README.md @@ -53,8 +53,8 @@ Provider publishes the SMTP configuration. It should be placed in the **applicat ```yaml related-units: {} application_data: { - "host": "example.smtp", - "port": "25", + "host": "example.com", + "port": "587", "user": "example_user", "password_id": "01548499c9233d4612352c989162d940f6a9e6f6d5cc058dfcf66f51575e09c2", "auth_type": "plain", diff --git a/interfaces/smtp/v0/schema.py b/interfaces/smtp/v0/schema.py index 06130b35..1f799bab 100644 --- a/interfaces/smtp/v0/schema.py +++ b/interfaces/smtp/v0/schema.py @@ -10,8 +10,8 @@ unit: app: {"smtp": { - "host": "example.smtp", - "port": "25", + "host": "example.com", + "port": "587", "user": "example_user", "password_id": "secret:123213123123123123123", "auth_type": "plain", @@ -48,7 +48,7 @@ class SmtpProviderData(BaseModel): min_length=1, description="SMTP host.", title="Host", - examples=["example.smtp"], + examples=["example.com"], ) port: int = Field( None, From 2ce21b4c86076ab55c9b95f30cb84c8a93646b06 Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Mon, 11 Dec 2023 10:26:21 +0100 Subject: [PATCH 20/32] Change domain examples --- interfaces/smtp/v0/README.md | 2 +- interfaces/smtp/v0/schema.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interfaces/smtp/v0/README.md b/interfaces/smtp/v0/README.md index 23eb718e..b96947a1 100644 --- a/interfaces/smtp/v0/README.md +++ b/interfaces/smtp/v0/README.md @@ -59,6 +59,6 @@ application_data: { "password_id": "01548499c9233d4612352c989162d940f6a9e6f6d5cc058dfcf66f51575e09c2", "auth_type": "plain", "transport_security": "tls", - "domain": "domain", + "domain": "example.com", } ``` diff --git a/interfaces/smtp/v0/schema.py b/interfaces/smtp/v0/schema.py index 1f799bab..c220ab8e 100644 --- a/interfaces/smtp/v0/schema.py +++ b/interfaces/smtp/v0/schema.py @@ -16,7 +16,7 @@ "password_id": "secret:123213123123123123123", "auth_type": "plain", "transport_security": "tls", - "domain": "domain", + "domain": "example.com", } } """ From e00912c9649c05286ca15d4c163e6bb9733e5f79 Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Mon, 11 Dec 2023 10:29:24 +0100 Subject: [PATCH 21/32] Fix expectations in readme --- interfaces/smtp/v0/README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/interfaces/smtp/v0/README.md b/interfaces/smtp/v0/README.md index b96947a1..32e03b51 100644 --- a/interfaces/smtp/v0/README.md +++ b/interfaces/smtp/v0/README.md @@ -31,10 +31,7 @@ The requirer and the provider must adhere to a certain set of criteria to be con ### Provider -- Is expected to publish the `host` in the relation databag. -- Is expected to publish the `port` in the relation databag. -- Is expected to publish the `auth_type` in the relation databag. -- Is expected to publish the `transport_security` in the relation databag. +- Is expected to provide the SMTP details so that the requirer can connect. ### Requirer From a2d744389f34aa04636ccf4e3c44162600e45c24 Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Mon, 11 Dec 2023 10:33:23 +0100 Subject: [PATCH 22/32] Build schema --- docs/json_schemas/smtp/v0/provider.json | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/json_schemas/smtp/v0/provider.json b/docs/json_schemas/smtp/v0/provider.json index fbd68e66..67fcf3a5 100644 --- a/docs/json_schemas/smtp/v0/provider.json +++ b/docs/json_schemas/smtp/v0/provider.json @@ -21,7 +21,7 @@ }, "AuthType": { "title": "AuthType", - "description": "Represent the auth type values.\n\nAttributes:\n NONE: none\n NOT_PROVIDED: not_provided\n PLAIN: plain", + "description": "Represent the auth type values.", "enum": [ "none", "not_provided", @@ -31,7 +31,7 @@ }, "TransportSecurity": { "title": "TransportSecurity", - "description": "Represent the transport security values.\n\nAttributes:\n NONE: none\n STARTTLS: starttls\n TLS: tls", + "description": "Represent the transport security values.", "enum": [ "none", "starttls", @@ -48,7 +48,7 @@ "description": "SMTP host.", "minLength": 1, "examples": [ - "example.smtp" + "example.com" ], "type": "string" }, @@ -58,7 +58,9 @@ "minimum": 1, "maximum": 65536, "examples": [ - 25 + 25, + 587, + 465 ], "type": "integer" }, @@ -114,7 +116,7 @@ "title": "Domain", "description": "The domain used by the sent emails from SMTP relay.", "examples": [ - "domain" + "example.com" ], "type": "string" } From 6b8e1e898692771c16500423feb4a4c74a396184 Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Mon, 11 Dec 2023 12:57:06 +0100 Subject: [PATCH 23/32] Expend schema descriptions --- interfaces/smtp/v0/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/smtp/v0/schema.py b/interfaces/smtp/v0/schema.py index c220ab8e..e61ab27e 100644 --- a/interfaces/smtp/v0/schema.py +++ b/interfaces/smtp/v0/schema.py @@ -64,7 +64,7 @@ class SmtpProviderData(BaseModel): examples=["some_user"], ) password: Optional[str] = Field( - description="SMTP password.", + description="SMTP password. Populated instead of password_id when secrets are not supported.", title="Password", examples=["somepasswd"], ) From 6938456b4727550bec4bdccae852e9ac0e0afa0e Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Mon, 11 Dec 2023 12:59:13 +0100 Subject: [PATCH 24/32] Expend schema descriptions --- interfaces/smtp/v0/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/smtp/v0/schema.py b/interfaces/smtp/v0/schema.py index e61ab27e..b482e805 100644 --- a/interfaces/smtp/v0/schema.py +++ b/interfaces/smtp/v0/schema.py @@ -69,7 +69,7 @@ class SmtpProviderData(BaseModel): examples=["somepasswd"], ) password_id: Optional[str] = Field( - description="Juju secret ID for the SMTP password.", + description="Juju secret ID for the SMTP password. Populated instead of password when secrets are supported.", title="Password ID", examples=["secret:123213123123123123123"], ) From 2393fc8290b4bb224698ed306b00c381afd01e19 Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Mon, 11 Dec 2023 13:01:29 +0100 Subject: [PATCH 25/32] Expend schema descriptions --- interfaces/smtp/v0/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/smtp/v0/schema.py b/interfaces/smtp/v0/schema.py index b482e805..183a0c48 100644 --- a/interfaces/smtp/v0/schema.py +++ b/interfaces/smtp/v0/schema.py @@ -79,7 +79,7 @@ class SmtpProviderData(BaseModel): examples=[AuthType.NONE], ) transport_security: TransportSecurity = Field( - description="The security protocol to use for the outgoing SMTP relay.", + description="The security protocol to use for the SMTP relay.", title="Transport security", examples=[TransportSecurity.NONE], ) From 50f312ebd02eed07590a1fabc6773399dec5ccdc Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Mon, 11 Dec 2023 13:08:17 +0100 Subject: [PATCH 26/32] Fix schema definition --- interfaces/smtp/v0/schema.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/interfaces/smtp/v0/schema.py b/interfaces/smtp/v0/schema.py index 183a0c48..505d08dd 100644 --- a/interfaces/smtp/v0/schema.py +++ b/interfaces/smtp/v0/schema.py @@ -44,14 +44,12 @@ class AuthType(str, Enum): class SmtpProviderData(BaseModel): host: str = Field( - ..., min_length=1, description="SMTP host.", title="Host", examples=["example.com"], ) port: int = Field( - None, ge=1, le=65536, description="SMTP port.", From 9483efa26e00d32e1d34beb8933952aa5b922fd3 Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Mon, 11 Dec 2023 13:09:14 +0100 Subject: [PATCH 27/32] Fix schema definition --- docs/json_schemas/smtp/v0/provider.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/json_schemas/smtp/v0/provider.json b/docs/json_schemas/smtp/v0/provider.json index 67fcf3a5..e45d6622 100644 --- a/docs/json_schemas/smtp/v0/provider.json +++ b/docs/json_schemas/smtp/v0/provider.json @@ -74,7 +74,7 @@ }, "password": { "title": "Password", - "description": "SMTP password.", + "description": "SMTP password. Populated instead of password_id when secrets are not supported.", "examples": [ "somepasswd" ], @@ -82,7 +82,7 @@ }, "password_id": { "title": "Password ID", - "description": "Juju secret ID for the SMTP password.", + "description": "Juju secret ID for the SMTP password. Populated instead of password when secrets are supported.", "examples": [ "secret:123213123123123123123" ], @@ -102,7 +102,7 @@ }, "transport_security": { "title": "Transport security", - "description": "The security protocol to use for the outgoing SMTP relay.", + "description": "The security protocol to use for the SMTP relay.", "examples": [ "none" ], @@ -123,6 +123,7 @@ }, "required": [ "host", + "port", "auth_type", "transport_security" ] From 64b793ba9cb2b277a8ee292ec105c5796e49c856 Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Tue, 12 Dec 2023 10:07:09 +0100 Subject: [PATCH 28/32] Fix domain description --- interfaces/smtp/v0/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/smtp/v0/schema.py b/interfaces/smtp/v0/schema.py index 505d08dd..5682c292 100644 --- a/interfaces/smtp/v0/schema.py +++ b/interfaces/smtp/v0/schema.py @@ -82,7 +82,7 @@ class SmtpProviderData(BaseModel): examples=[TransportSecurity.NONE], ) domain: Optional[str] = Field( - description="The domain used by the sent emails from SMTP relay.", + description="The EMAIL FROM domain for the outgoing email.", title="Domain", examples=["example.com"], ) From 65fb50013a35ca8d264e6776ce2eb12a50e91800 Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Tue, 12 Dec 2023 10:08:39 +0100 Subject: [PATCH 29/32] Fix domain description --- docs/json_schemas/smtp/v0/provider.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/json_schemas/smtp/v0/provider.json b/docs/json_schemas/smtp/v0/provider.json index e45d6622..fcfc97f7 100644 --- a/docs/json_schemas/smtp/v0/provider.json +++ b/docs/json_schemas/smtp/v0/provider.json @@ -114,7 +114,7 @@ }, "domain": { "title": "Domain", - "description": "The domain used by the sent emails from SMTP relay.", + "description": "The EMAIL FROM domain for the outgoing email.", "examples": [ "example.com" ], From 697f5034d4d592b834ec81866aa299758bca7746 Mon Sep 17 00:00:00 2001 From: arturo-seijas <102022572+arturo-seijas@users.noreply.github.com> Date: Thu, 14 Dec 2023 11:42:58 +0100 Subject: [PATCH 30/32] Update interfaces/smtp/v0/schema.py Co-authored-by: Tony Meyer --- interfaces/smtp/v0/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/smtp/v0/schema.py b/interfaces/smtp/v0/schema.py index 5682c292..510d2b5d 100644 --- a/interfaces/smtp/v0/schema.py +++ b/interfaces/smtp/v0/schema.py @@ -82,7 +82,7 @@ class SmtpProviderData(BaseModel): examples=[TransportSecurity.NONE], ) domain: Optional[str] = Field( - description="The EMAIL FROM domain for the outgoing email.", + description="The MAIL FROM domain for the outgoing email.", title="Domain", examples=["example.com"], ) From 30c25793dfa7775ad8d0d529ddfc61630f505cae Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Thu, 14 Dec 2023 11:44:40 +0100 Subject: [PATCH 31/32] Remove accidentally commited file --- =4 | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 =4 diff --git a/=4 b/=4 deleted file mode 100644 index e69de29b..00000000 From a3ebb51bb26a6385ab5af707f082c1f900a1f813 Mon Sep 17 00:00:00 2001 From: arturo-seijas Date: Thu, 14 Dec 2023 12:03:52 +0100 Subject: [PATCH 32/32] Fix schemas --- docs/json_schemas/smtp/v0/provider.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/json_schemas/smtp/v0/provider.json b/docs/json_schemas/smtp/v0/provider.json index fcfc97f7..4e04b47a 100644 --- a/docs/json_schemas/smtp/v0/provider.json +++ b/docs/json_schemas/smtp/v0/provider.json @@ -114,7 +114,7 @@ }, "domain": { "title": "Domain", - "description": "The EMAIL FROM domain for the outgoing email.", + "description": "The MAIL FROM domain for the outgoing email.", "examples": [ "example.com" ],