Initial Commit
slip slop
This commit is contained in:
commit
064e672ab7
61 changed files with 3504 additions and 0 deletions
132
ain/README.md
Normal file
132
ain/README.md
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
# ain templates
|
||||
|
||||
[ain](https://github.com/jonaslu/ain) is a terminal HTTP client. These templates cover every API endpoint.
|
||||
|
||||
## Setup
|
||||
|
||||
### 1. Install ain
|
||||
|
||||
```bash
|
||||
brew install ain # macOS
|
||||
# or: go install github.com/jonaslu/ain/cmd/ain@latest
|
||||
```
|
||||
|
||||
ain requires `curl`, `wget`, or `httpie` to be available — `curl` is already on macOS.
|
||||
|
||||
### 2. Configure connection details
|
||||
|
||||
ain picks up variables from the project root `.env` automatically when run from the project root. `make local` will have already created that file for you. The relevant variables are:
|
||||
|
||||
```bash
|
||||
API_KEY=dev-secret-key-change-me
|
||||
REPERTORY_HOST=http://localhost:5000
|
||||
```
|
||||
|
||||
### 3. Run a template
|
||||
|
||||
Every template is run by combining `base.ain` with a specific template file. `base.ain` provides the host and auth header; the specific file adds the path, method, and body.
|
||||
|
||||
```bash
|
||||
ain ain/base.ain ain/health.ain
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Templates
|
||||
|
||||
### Health
|
||||
|
||||
```bash
|
||||
ain ain/base.ain ain/health.ain
|
||||
```
|
||||
|
||||
### Tunes
|
||||
|
||||
```bash
|
||||
# List all tunes
|
||||
ain ain/base.ain ain/tunes/list.ain
|
||||
|
||||
# List with filters (edit the [Query] section in the file first)
|
||||
ain ain/base.ain ain/tunes/list-filtered.ain
|
||||
|
||||
# Get a single tune
|
||||
ain ain/base.ain ain/tunes/get.ain --vars ID=1
|
||||
|
||||
# Create a tune (edit the [Body] in the file first)
|
||||
ain ain/base.ain ain/tunes/create.ain
|
||||
|
||||
# Update core fields
|
||||
ain ain/base.ain ain/tunes/update.ain --vars ID=1
|
||||
|
||||
# Delete a tune
|
||||
ain ain/base.ain ain/tunes/delete.ain --vars ID=1
|
||||
```
|
||||
|
||||
### Instruments (banjo / fiddle)
|
||||
|
||||
```bash
|
||||
# Create or replace a banjo entry
|
||||
ain ain/base.ain ain/instruments/upsert-banjo.ain --vars ID=1
|
||||
|
||||
# Create or replace a fiddle entry
|
||||
ain ain/base.ain ain/instruments/upsert-fiddle.ain --vars ID=1
|
||||
|
||||
# Patch individual banjo fields
|
||||
ain ain/base.ain ain/instruments/patch-banjo.ain --vars ID=1
|
||||
|
||||
# Patch individual fiddle fields
|
||||
ain ain/base.ain ain/instruments/patch-fiddle.ain --vars ID=1
|
||||
|
||||
# Delete banjo entry
|
||||
ain ain/base.ain ain/instruments/delete-banjo.ain --vars ID=1
|
||||
|
||||
# Delete fiddle entry
|
||||
ain ain/base.ain ain/instruments/delete-fiddle.ain --vars ID=1
|
||||
```
|
||||
|
||||
### Notes
|
||||
|
||||
```bash
|
||||
# List notes for a tune
|
||||
ain ain/base.ain ain/notes/list.ain --vars ID=1
|
||||
|
||||
# Add a note
|
||||
ain ain/base.ain ain/notes/create.ain --vars ID=1
|
||||
|
||||
# Update a note
|
||||
ain ain/base.ain ain/notes/update.ain --vars ID=1 NOTE_ID=2
|
||||
|
||||
# Delete a note
|
||||
ain ain/base.ain ain/notes/delete.ain --vars ID=1 NOTE_ID=2
|
||||
```
|
||||
|
||||
### References
|
||||
|
||||
```bash
|
||||
# List references for a tune
|
||||
ain ain/base.ain ain/references/list.ain --vars ID=1
|
||||
|
||||
# Add a reference (with optional musicians in the body)
|
||||
ain ain/base.ain ain/references/create.ain --vars ID=1
|
||||
|
||||
# Update a reference
|
||||
ain ain/base.ain ain/references/update.ain --vars ID=1 REF_ID=2
|
||||
|
||||
# Delete a reference
|
||||
ain ain/base.ain ain/references/delete.ain --vars ID=1 REF_ID=2
|
||||
|
||||
# Add a musician to a reference
|
||||
ain ain/base.ain ain/references/add-musician.ain --vars ID=1 REF_ID=2
|
||||
|
||||
# Remove a musician from a reference
|
||||
ain ain/base.ain ain/references/delete-musician.ain --vars ID=1 REF_ID=2 NAME="Tony Rice"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Tips
|
||||
|
||||
- **Print without sending**: `ain -p ain/base.ain ain/tunes/list.ain` — shows the curl command ain would run, useful for debugging
|
||||
- **Pipe output**: `ain ain/base.ain ain/tunes/list.ain | jq .` — pipe straight into jq or anything else
|
||||
- **Multiple filters**: edit `ain/tunes/list-filtered.ain` and remove the query params you don't need before running
|
||||
- **Musician names with spaces**: quote the whole `--vars` value: `--vars NAME="Doc Watson"`
|
||||
15
ain/base.ain
Normal file
15
ain/base.ain
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# ain/base.ain
|
||||
# Shared host and auth header — included by every other template.
|
||||
# Variables are loaded from the project root .env automatically when
|
||||
# ain is run from the project root.
|
||||
# See env.example for the full list of variables.
|
||||
|
||||
[Host]
|
||||
${REPERTORY_HOST}
|
||||
|
||||
[Headers]
|
||||
X-API-Key: ${API_KEY}
|
||||
Content-Type: application/json
|
||||
|
||||
[Backend]
|
||||
curl
|
||||
8
ain/health.ain
Normal file
8
ain/health.ain
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# Health check
|
||||
# ain ain/base.ain ain/health.ain
|
||||
|
||||
[Host]
|
||||
/health
|
||||
|
||||
[Method]
|
||||
GET
|
||||
8
ain/instruments/delete-banjo.ain
Normal file
8
ain/instruments/delete-banjo.ain
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# Delete a banjo entry for a tune
|
||||
# ain ain/base.ain ain/instruments/delete-banjo.ain --vars ID=1
|
||||
|
||||
[Host]
|
||||
/tunes/${ID}/banjo
|
||||
|
||||
[Method]
|
||||
DELETE
|
||||
8
ain/instruments/delete-fiddle.ain
Normal file
8
ain/instruments/delete-fiddle.ain
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# Delete a fiddle entry for a tune
|
||||
# ain ain/base.ain ain/instruments/delete-fiddle.ain --vars ID=1
|
||||
|
||||
[Host]
|
||||
/tunes/${ID}/fiddle
|
||||
|
||||
[Method]
|
||||
DELETE
|
||||
14
ain/instruments/patch-banjo.ain
Normal file
14
ain/instruments/patch-banjo.ain
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Partially update a banjo entry — only include fields you want to change
|
||||
# ain ain/base.ain ain/instruments/patch-banjo.ain --vars ID=1
|
||||
|
||||
[Host]
|
||||
/tunes/${ID}/banjo
|
||||
|
||||
[Method]
|
||||
PATCH
|
||||
|
||||
[Body]
|
||||
{
|
||||
"callable": true,
|
||||
"review": false
|
||||
}
|
||||
14
ain/instruments/patch-fiddle.ain
Normal file
14
ain/instruments/patch-fiddle.ain
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Partially update a fiddle entry — only include fields you want to change
|
||||
# ain ain/base.ain ain/instruments/patch-fiddle.ain --vars ID=1
|
||||
|
||||
[Host]
|
||||
/tunes/${ID}/fiddle
|
||||
|
||||
[Method]
|
||||
PATCH
|
||||
|
||||
[Body]
|
||||
{
|
||||
"tuning": "GDAD",
|
||||
"to_learn": false
|
||||
}
|
||||
19
ain/instruments/upsert-banjo.ain
Normal file
19
ain/instruments/upsert-banjo.ain
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Create or fully replace a banjo entry for a tune
|
||||
# ain ain/base.ain ain/instruments/upsert-banjo.ain --vars ID=1
|
||||
|
||||
[Host]
|
||||
/tunes/${ID}/banjo
|
||||
|
||||
[Method]
|
||||
PUT
|
||||
|
||||
[Body]
|
||||
{
|
||||
"tuning": "double C",
|
||||
"learned_from": "Earl Scruggs",
|
||||
"date_learned": "2024-03-01",
|
||||
"callable": true,
|
||||
"review": false,
|
||||
"to_learn": false,
|
||||
"difficulty": null
|
||||
}
|
||||
19
ain/instruments/upsert-fiddle.ain
Normal file
19
ain/instruments/upsert-fiddle.ain
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Create or fully replace a fiddle entry for a tune
|
||||
# ain ain/base.ain ain/instruments/upsert-fiddle.ain --vars ID=1
|
||||
|
||||
[Host]
|
||||
/tunes/${ID}/fiddle
|
||||
|
||||
[Method]
|
||||
PUT
|
||||
|
||||
[Body]
|
||||
{
|
||||
"tuning": "cross",
|
||||
"learned_from": "Alison Krauss",
|
||||
"date_learned": "2024-06-15",
|
||||
"callable": false,
|
||||
"review": true,
|
||||
"to_learn": false,
|
||||
"difficulty": null
|
||||
}
|
||||
13
ain/notes/create.ain
Normal file
13
ain/notes/create.ain
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Add a note to a tune
|
||||
# ain ain/base.ain ain/notes/create.ain --vars ID=1
|
||||
|
||||
[Host]
|
||||
/tunes/${ID}/notes
|
||||
|
||||
[Method]
|
||||
POST
|
||||
|
||||
[Body]
|
||||
{
|
||||
"note": "tricky B part — watch the timing"
|
||||
}
|
||||
8
ain/notes/delete.ain
Normal file
8
ain/notes/delete.ain
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# Delete a note
|
||||
# ain ain/base.ain ain/notes/delete.ain --vars ID=1 NOTE_ID=2
|
||||
|
||||
[Host]
|
||||
/tunes/${ID}/notes/${NOTE_ID}
|
||||
|
||||
[Method]
|
||||
DELETE
|
||||
8
ain/notes/list.ain
Normal file
8
ain/notes/list.ain
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# List all notes for a tune
|
||||
# ain ain/base.ain ain/notes/list.ain --vars ID=1
|
||||
|
||||
[Host]
|
||||
/tunes/${ID}/notes
|
||||
|
||||
[Method]
|
||||
GET
|
||||
13
ain/notes/update.ain
Normal file
13
ain/notes/update.ain
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Update a note
|
||||
# ain ain/base.ain ain/notes/update.ain --vars ID=1 NOTE_ID=2
|
||||
|
||||
[Host]
|
||||
/tunes/${ID}/notes/${NOTE_ID}
|
||||
|
||||
[Method]
|
||||
PATCH
|
||||
|
||||
[Body]
|
||||
{
|
||||
"note": "updated note text"
|
||||
}
|
||||
13
ain/references/add-musician.ain
Normal file
13
ain/references/add-musician.ain
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Add a musician tag to a reference
|
||||
# ain ain/base.ain ain/references/add-musician.ain --vars ID=1 REF_ID=2
|
||||
|
||||
[Host]
|
||||
/tunes/${ID}/references/${REF_ID}/musicians
|
||||
|
||||
[Method]
|
||||
POST
|
||||
|
||||
[Body]
|
||||
{
|
||||
"name": "Tony Rice"
|
||||
}
|
||||
18
ain/references/create.ain
Normal file
18
ain/references/create.ain
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Add a reference to a tune (with optional musicians)
|
||||
# ain ain/base.ain ain/references/create.ain --vars ID=1
|
||||
|
||||
[Host]
|
||||
/tunes/${ID}/references
|
||||
|
||||
[Method]
|
||||
POST
|
||||
|
||||
[Body]
|
||||
{
|
||||
"link": "https://www.youtube.com/watch?v=example",
|
||||
"site": "YouTube",
|
||||
"musicians": [
|
||||
{ "name": "Doc Watson" },
|
||||
{ "name": "Merle Watson" }
|
||||
]
|
||||
}
|
||||
8
ain/references/delete-musician.ain
Normal file
8
ain/references/delete-musician.ain
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# Remove a musician tag from a reference
|
||||
# ain ain/base.ain ain/references/delete-musician.ain --vars ID=1 REF_ID=2 NAME="Tony Rice"
|
||||
|
||||
[Host]
|
||||
/tunes/${ID}/references/${REF_ID}/musicians/${NAME}
|
||||
|
||||
[Method]
|
||||
DELETE
|
||||
8
ain/references/delete.ain
Normal file
8
ain/references/delete.ain
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# Delete a reference (cascades to its musicians)
|
||||
# ain ain/base.ain ain/references/delete.ain --vars ID=1 REF_ID=2
|
||||
|
||||
[Host]
|
||||
/tunes/${ID}/references/${REF_ID}
|
||||
|
||||
[Method]
|
||||
DELETE
|
||||
8
ain/references/list.ain
Normal file
8
ain/references/list.ain
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# List all references for a tune
|
||||
# ain ain/base.ain ain/references/list.ain --vars ID=1
|
||||
|
||||
[Host]
|
||||
/tunes/${ID}/references
|
||||
|
||||
[Method]
|
||||
GET
|
||||
14
ain/references/update.ain
Normal file
14
ain/references/update.ain
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Update a reference (link and/or site)
|
||||
# ain ain/base.ain ain/references/update.ain --vars ID=1 REF_ID=2
|
||||
|
||||
[Host]
|
||||
/tunes/${ID}/references/${REF_ID}
|
||||
|
||||
[Method]
|
||||
PATCH
|
||||
|
||||
[Body]
|
||||
{
|
||||
"site": "TuneArch",
|
||||
"link": "https://tunearchy.com/example"
|
||||
}
|
||||
46
ain/tunes/create.ain
Normal file
46
ain/tunes/create.ain
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# Create a tune with nested banjo, fiddle, notes, and references in one shot.
|
||||
# All fields except the top-level ones are optional — remove any block you don't need.
|
||||
# ain ain/base.ain ain/tunes/create.ain
|
||||
|
||||
[Host]
|
||||
/tunes/
|
||||
|
||||
[Method]
|
||||
POST
|
||||
|
||||
[Body]
|
||||
{
|
||||
"name": "Cluck Old Hen",
|
||||
"key": "A",
|
||||
"version": "full",
|
||||
"banjo": {
|
||||
"tuning": "double C",
|
||||
"learned_from": "Earl Scruggs",
|
||||
"date_learned": "2024-03-01",
|
||||
"callable": true,
|
||||
"review": false,
|
||||
"to_learn": false,
|
||||
"difficulty": null
|
||||
},
|
||||
"fiddle": {
|
||||
"tuning": "cross",
|
||||
"learned_from": "Alison Krauss",
|
||||
"date_learned": "2024-06-15",
|
||||
"callable": false,
|
||||
"review": true,
|
||||
"to_learn": false,
|
||||
"difficulty": null
|
||||
},
|
||||
"notes": [
|
||||
{ "note": "tricky B part — watch the timing" }
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"link": "https://www.youtube.com/watch?v=example",
|
||||
"site": "YouTube",
|
||||
"musicians": [
|
||||
{ "name": "Alison Krauss" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
8
ain/tunes/delete.ain
Normal file
8
ain/tunes/delete.ain
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# Delete a tune (cascades to all sub-records)
|
||||
# ain ain/base.ain ain/tunes/delete.ain --vars ID=1
|
||||
|
||||
[Host]
|
||||
/tunes/${ID}
|
||||
|
||||
[Method]
|
||||
DELETE
|
||||
8
ain/tunes/get.ain
Normal file
8
ain/tunes/get.ain
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# Get a single tune by ID
|
||||
# ain ain/base.ain ain/tunes/get.ain --vars ID=1
|
||||
|
||||
[Host]
|
||||
/tunes/${ID}
|
||||
|
||||
[Method]
|
||||
GET
|
||||
21
ain/tunes/list-filtered.ain
Normal file
21
ain/tunes/list-filtered.ain
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# Filter tunes — all params are optional, combine as needed
|
||||
# ain ain/base.ain ain/tunes/list-filtered.ain
|
||||
#
|
||||
# Tweak the [Query] section before running.
|
||||
# instrument must be set for tuning/callable/review/to_learn/difficulty to apply.
|
||||
|
||||
[Host]
|
||||
/tunes/
|
||||
|
||||
[Query]
|
||||
instrument=fiddle
|
||||
key=A
|
||||
tuning=cross
|
||||
callable=true
|
||||
review=false
|
||||
to_learn=false
|
||||
difficulty=easy
|
||||
search=cluck
|
||||
|
||||
[Method]
|
||||
GET
|
||||
8
ain/tunes/list.ain
Normal file
8
ain/tunes/list.ain
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# List all tunes (no filters)
|
||||
# ain ain/base.ain ain/tunes/list.ain
|
||||
|
||||
[Host]
|
||||
/tunes/
|
||||
|
||||
[Method]
|
||||
GET
|
||||
15
ain/tunes/update.ain
Normal file
15
ain/tunes/update.ain
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# Update core tune fields (name, key, version)
|
||||
# ain ain/base.ain ain/tunes/update.ain --vars ID=1
|
||||
|
||||
[Host]
|
||||
/tunes/${ID}
|
||||
|
||||
[Method]
|
||||
PATCH
|
||||
|
||||
[Body]
|
||||
{
|
||||
"name": "Cluck Old Hen",
|
||||
"key": "D",
|
||||
"version": "A part only"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue