Skip to content

Use Windmill Hub resource types, and document custom resource type usage #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ This repo also provides a shell script to batch push changes to a number of work

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

### Adding custom resource types

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).

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.

## Development

In Windmill, scripts can be written in Python, TypeScript, Go, and a number of other languages. Flows and apps can
Expand Down
25 changes: 0 additions & 25 deletions c_arcgis_account.resource-type.json

This file was deleted.

18 changes: 0 additions & 18 deletions c_gfw_api.resource-type.json

This file was deleted.

26 changes: 0 additions & 26 deletions c_kobotoolbox_account.resource-type.json

This file was deleted.

44 changes: 0 additions & 44 deletions c_odk_config.resource-type.json

This file was deleted.

54 changes: 0 additions & 54 deletions c_twilio_message_template.resource-type.json

This file was deleted.

15 changes: 12 additions & 3 deletions f/connectors/alerts/alerts_twilio.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@

import json
import logging
from typing import TypedDict

from twilio.rest import Client as TwilioClient

# type names that refer to Windmill Resources
c_twilio_message_template = dict

# https://hub.windmill.dev/resource_types/274/twilio_message_template
class twilio_message_template(TypedDict):
account_sid: str
auth_token: str
origin_number: str
recipients: list[str]
content_sid: str
messaging_service_sid: str


logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Expand All @@ -16,7 +25,7 @@
def main(
alerts_statistics: dict,
community_slug: str,
twilio: c_twilio_message_template,
twilio: twilio_message_template,
):
send_twilio_message(twilio, alerts_statistics, community_slug)

Expand Down
2 changes: 1 addition & 1 deletion f/connectors/alerts/alerts_twilio.script.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ schema:
ingesting and writing alerts to the database via a Twilio message
content template.
default: null
format: resource-c_twilio_message_template
format: resource-twilio_message_template
required:
- alerts_statistics
- community_slug
Expand Down
13 changes: 9 additions & 4 deletions f/connectors/arcgis/arcgis_feature_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,27 @@
import logging
import os
from pathlib import Path
from typing import TypedDict

import requests

from f.common_logic.db_operations import postgresql
from f.common_logic.file_operations import save_data_to_file
from f.connectors.geojson.geojson_to_postgres import main as save_geojson_to_postgres

# type names that refer to Windmill Resources
c_arcgis_account = dict

# https://hub.windmill.dev/resource_types/271/arcgis_account
class arcgis_account(TypedDict):
username: str
password: str


logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


def main(
arcgis_account: c_arcgis_account,
arcgis_account: arcgis_account,
feature_layer_url: str,
db: postgresql,
db_table_name: str,
Expand Down Expand Up @@ -61,7 +66,7 @@ def main(
)


def get_arcgis_token(arcgis_account: c_arcgis_account):
def get_arcgis_token(arcgis_account: arcgis_account):
"""
Generate an ArcGIS token using the provided account credentials.

Expand Down
2 changes: 1 addition & 1 deletion f/connectors/arcgis/arcgis_feature_layer.script.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ schema:
type: object
description: The name of the ArcGIS account to use for fetching the feature layer.
default: null
format: resource-c_arcgis_account
format: resource-arcgis_account
originalType: string
attachment_root:
type: string
Expand Down
1 change: 1 addition & 0 deletions f/connectors/comapeo/comapeo_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from f.common_logic.db_operations import conninfo, postgresql


# https://hub.windmill.dev/resource_types/194/comapeo_server
class comapeo_server(TypedDict):
server_url: str
access_token: str
Expand Down
12 changes: 8 additions & 4 deletions f/connectors/globalforestwatch/gfw_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,26 @@
import logging
import re
from pathlib import Path
from typing import TypedDict

import requests

from f.common_logic.db_operations import postgresql
from f.common_logic.file_operations import save_data_to_file
from f.connectors.geojson.geojson_to_postgres import main as save_geojson_to_postgres

# type names that refer to Windmill Resources
c_gfw_api = dict

# https://hub.windmill.dev/resource_types/273/gfw_api
class gfw_api(TypedDict):
api_key: str


logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


def main(
gfw_api: c_gfw_api,
gfw_api: gfw_api,
bounding_box: str,
type_of_alert: str,
minimum_date: str,
Expand Down Expand Up @@ -57,7 +61,7 @@ def main(


def fetch_alerts_from_gfw(
api_key: c_gfw_api, bounding_box: str, type_of_alert: str, minimum_date: str
api_key: gfw_api, bounding_box: str, type_of_alert: str, minimum_date: str
):
"""
Get alerts from GFW API using the provided API key and bounding box.
Expand Down
2 changes: 1 addition & 1 deletion f/connectors/globalforestwatch/gfw_alerts.script.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ schema:
this year expires after 1 year. For now, you can obtain a new API key from
the Global Forest Watch API.
default: null
format: resource-c_gfw_api
format: resource-gfw_api
bounding_box:
type: string
description: >-
Expand Down
11 changes: 8 additions & 3 deletions f/connectors/kobotoolbox/kobotoolbox_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,26 @@
import json
import logging
from pathlib import Path
from typing import TypedDict

import requests

from f.common_logic.db_operations import StructuredDBWriter, conninfo, postgresql
from f.common_logic.file_operations import save_data_to_file

# type names that refer to Windmill Resources
c_kobotoolbox_account = dict

# https://hub.windmill.dev/resource_types/193/kobotoolbox_account
class kobotoolbox_account(TypedDict):
server_url: str
api_key: str


logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


def main(
kobotoolbox: c_kobotoolbox_account,
kobotoolbox: kobotoolbox_account,
form_id: str,
db: postgresql,
db_table_name: str,
Expand Down
2 changes: 1 addition & 1 deletion f/connectors/kobotoolbox/kobotoolbox_responses.script.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ schema:
type: object
description: A server and API key pair to connect to the KoboToolbox account
default: null
format: resource-c_kobotoolbox_account
format: resource-kobotoolbox_account
originalType: string
required:
- kobotoolbox
Expand Down
Loading