Skip to content

Commit b8e4452

Browse files
authored
Use Windmill Hub resource types, and document custom resource type usage (#131)
* Document how to set up custom resource types * Move resource types into dir * Clarify how custom resource types might be used in this repo * Use Windmill Hub resource types
1 parent 460eb75 commit b8e4452

17 files changed

+60
-190
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ This repo also provides a shell script to batch push changes to a number of work
4343

4444
(set -a; source .env; set +a; bin/push.sh)
4545

46+
### Adding custom resource types
47+
48+
At times, this repository may contain one or more [custom resource types](https://www.windmill.dev/docs/core_concepts/resources_and_types#create-a-resource-type) that are used by a number of the scripts in this repository. However, we commit to adding all of our resource types to [Windmill Hub](https://www.windmill.dev/docs/core_concepts/resources_and_types#sync-resource-types-with-windmillhub).
49+
50+
There is no way to sync custom resource types to a Windmill workspace, so you will need to manually add them. The easiest way to do this is to paste them in to the JSON editor when creating a new resource type.
51+
4652
## Development
4753

4854
In Windmill, scripts can be written in Python, TypeScript, Go, and a number of other languages. Flows and apps can

c_arcgis_account.resource-type.json

Lines changed: 0 additions & 25 deletions
This file was deleted.

c_gfw_api.resource-type.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

c_kobotoolbox_account.resource-type.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

c_odk_config.resource-type.json

Lines changed: 0 additions & 44 deletions
This file was deleted.

c_twilio_message_template.resource-type.json

Lines changed: 0 additions & 54 deletions
This file was deleted.

f/connectors/alerts/alerts_twilio.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,20 @@
33

44
import json
55
import logging
6+
from typing import TypedDict
67

78
from twilio.rest import Client as TwilioClient
89

9-
# type names that refer to Windmill Resources
10-
c_twilio_message_template = dict
10+
11+
# https://hub.windmill.dev/resource_types/274/twilio_message_template
12+
class twilio_message_template(TypedDict):
13+
account_sid: str
14+
auth_token: str
15+
origin_number: str
16+
recipients: list[str]
17+
content_sid: str
18+
messaging_service_sid: str
19+
1120

1221
logging.basicConfig(level=logging.INFO)
1322
logger = logging.getLogger(__name__)
@@ -16,7 +25,7 @@
1625
def main(
1726
alerts_statistics: dict,
1827
community_slug: str,
19-
twilio: c_twilio_message_template,
28+
twilio: twilio_message_template,
2029
):
2130
send_twilio_message(twilio, alerts_statistics, community_slug)
2231

f/connectors/alerts/alerts_twilio.script.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ schema:
3333
ingesting and writing alerts to the database via a Twilio message
3434
content template.
3535
default: null
36-
format: resource-c_twilio_message_template
36+
format: resource-twilio_message_template
3737
required:
3838
- alerts_statistics
3939
- community_slug

f/connectors/arcgis/arcgis_feature_layer.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,27 @@
55
import logging
66
import os
77
from pathlib import Path
8+
from typing import TypedDict
89

910
import requests
1011

1112
from f.common_logic.db_operations import postgresql
1213
from f.common_logic.file_operations import save_data_to_file
1314
from f.connectors.geojson.geojson_to_postgres import main as save_geojson_to_postgres
1415

15-
# type names that refer to Windmill Resources
16-
c_arcgis_account = dict
16+
17+
# https://hub.windmill.dev/resource_types/271/arcgis_account
18+
class arcgis_account(TypedDict):
19+
username: str
20+
password: str
21+
1722

1823
logging.basicConfig(level=logging.INFO)
1924
logger = logging.getLogger(__name__)
2025

2126

2227
def main(
23-
arcgis_account: c_arcgis_account,
28+
arcgis_account: arcgis_account,
2429
feature_layer_url: str,
2530
db: postgresql,
2631
db_table_name: str,
@@ -61,7 +66,7 @@ def main(
6166
)
6267

6368

64-
def get_arcgis_token(arcgis_account: c_arcgis_account):
69+
def get_arcgis_token(arcgis_account: arcgis_account):
6570
"""
6671
Generate an ArcGIS token using the provided account credentials.
6772

f/connectors/arcgis/arcgis_feature_layer.script.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ schema:
1717
type: object
1818
description: The name of the ArcGIS account to use for fetching the feature layer.
1919
default: null
20-
format: resource-c_arcgis_account
20+
format: resource-arcgis_account
2121
originalType: string
2222
attachment_root:
2323
type: string

0 commit comments

Comments
 (0)