From dd84b2b232ee90b6e719f62e63a8960f54aa3f62 Mon Sep 17 00:00:00 2001 From: Alvin Tang Date: Tue, 18 May 2021 12:59:57 -0400 Subject: [PATCH 01/32] Created `docs.yml` to generate docs on push --- .github/workflows/docs.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..357ea45 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,22 @@ +name: CLI Docs +on: + push: + branches: + - "main" + tags: + - "v*" +jobs: + build: + runs-on: ubuntu-latest + steps: + # Install Go v1.16 + - name: Install Go v1.16 + uses: actions/setup-go@v2 + with: + go-version: "1.16" + # Checkout the commit SHA that triggered the workflow + - name: Checkout code + uses: actions/checkout@v2 + # Generate docs + - name: Generate docs + run: go run ./scripts/gen-docs/main.go ${GITHUB_REF/refs\/tags\//} From 5cd3966cf8bc098cebe0ac1cb2189cc9fdc7734d Mon Sep 17 00:00:00 2001 From: Alvin Tang Date: Tue, 18 May 2021 13:00:47 -0400 Subject: [PATCH 02/32] Renamed job in `docs.yaml` --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 357ea45..578ccd6 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -6,7 +6,7 @@ on: tags: - "v*" jobs: - build: + docs: runs-on: ubuntu-latest steps: # Install Go v1.16 From 11b26bdfd388e8b3b28c4fd20b47e8f920d18d52 Mon Sep 17 00:00:00 2001 From: Alvin Tang Date: Tue, 18 May 2021 13:04:30 -0400 Subject: [PATCH 03/32] Ignore autogen docs for source code --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0da4724..098dd28 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,4 @@ .idea/ # Ignore autogen docs for source code (development) -docs/source +docs/source/ From 2ad88773fbc9847a9bec3043f32d2049cadf12ec Mon Sep 17 00:00:00 2001 From: Alvin Tang Date: Tue, 18 May 2021 13:13:52 -0400 Subject: [PATCH 04/32] Updated `docs.yml` to include pushing changes --- .github/workflows/docs.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 578ccd6..4a4b7ad 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -9,14 +9,22 @@ jobs: docs: runs-on: ubuntu-latest steps: - # Install Go v1.16 - name: Install Go v1.16 uses: actions/setup-go@v2 with: go-version: "1.16" + # Checkout the commit SHA that triggered the workflow - name: Checkout code uses: actions/checkout@v2 - # Generate docs + - name: Generate docs run: go run ./scripts/gen-docs/main.go ${GITHUB_REF/refs\/tags\//} + + - name: Check for changes + run: git status + + - name: Commit and push docs + run: | + git commit -am ":memo: Auto generated docs for ${GITHUB_REF/refs\/tags\//}" + git push From 07e16e9ea10bc438f193c747ca18aa8bdd85cf58 Mon Sep 17 00:00:00 2001 From: Alvin Tang Date: Tue, 18 May 2021 13:18:33 -0400 Subject: [PATCH 05/32] Updated `docs.yml` to include config info for push --- .github/workflows/docs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 4a4b7ad..b7d9b1e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -26,5 +26,7 @@ jobs: - name: Commit and push docs run: | + git config --global user.name "Alvin Tang (via GH Actions)" + git config --global user.email "alvintangz@users.noreply.github.com" git commit -am ":memo: Auto generated docs for ${GITHUB_REF/refs\/tags\//}" git push From e36e5ee168001ea04a2224e153e10a50332a0a5b Mon Sep 17 00:00:00 2001 From: Alvin Tang Date: Tue, 18 May 2021 13:20:40 -0400 Subject: [PATCH 06/32] Updated `docs.yml` to fix exit code --- .github/workflows/docs.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index b7d9b1e..23dda31 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -21,12 +21,11 @@ jobs: - name: Generate docs run: go run ./scripts/gen-docs/main.go ${GITHUB_REF/refs\/tags\//} - - name: Check for changes - run: git status - - name: Commit and push docs run: | git config --global user.name "Alvin Tang (via GH Actions)" git config --global user.email "alvintangz@users.noreply.github.com" - git commit -am ":memo: Auto generated docs for ${GITHUB_REF/refs\/tags\//}" + git add . + git status + git commit -m ":memo: Auto generated docs for ${GITHUB_REF/refs\/tags\//}" git push From ff6121a44a4144d720251f8e01582851545e75ed Mon Sep 17 00:00:00 2001 From: Alvin Tang Date: Tue, 18 May 2021 13:23:01 -0400 Subject: [PATCH 07/32] Updated `docs.yml` to fix exit code issue again --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 23dda31..8e5125a 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -23,7 +23,7 @@ jobs: - name: Commit and push docs run: | - git config --global user.name "Alvin Tang (via GH Actions)" + git config --global user.name "Alvin Tang" git config --global user.email "alvintangz@users.noreply.github.com" git add . git status From e9ae673861c270e3edb74014558e80571e134b41 Mon Sep 17 00:00:00 2001 From: Alvin Tang Date: Tue, 18 May 2021 13:28:19 -0400 Subject: [PATCH 08/32] Updated `docs.yml` to fix issue again with exit code due to `main` being a protected branch --- .github/workflows/docs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 8e5125a..4d77c0c 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -17,6 +17,8 @@ jobs: # Checkout the commit SHA that triggered the workflow - name: Checkout code uses: actions/checkout@v2 + with: + persist-credentials: false - name: Generate docs run: go run ./scripts/gen-docs/main.go ${GITHUB_REF/refs\/tags\//} From 898704b81bff0408b2e84bf6f8d40b384fa9a630 Mon Sep 17 00:00:00 2001 From: Alvin Tang Date: Tue, 18 May 2021 13:34:46 -0400 Subject: [PATCH 09/32] Disabled protected branch and updated `docs.yml` accordingly. --- .github/workflows/docs.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 4d77c0c..23dda31 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -17,15 +17,13 @@ jobs: # Checkout the commit SHA that triggered the workflow - name: Checkout code uses: actions/checkout@v2 - with: - persist-credentials: false - name: Generate docs run: go run ./scripts/gen-docs/main.go ${GITHUB_REF/refs\/tags\//} - name: Commit and push docs run: | - git config --global user.name "Alvin Tang" + git config --global user.name "Alvin Tang (via GH Actions)" git config --global user.email "alvintangz@users.noreply.github.com" git add . git status From a9f769e56983aac1080658b515ee54562e9692a7 Mon Sep 17 00:00:00 2001 From: Alvin Tang Date: Tue, 18 May 2021 13:43:53 -0400 Subject: [PATCH 10/32] Updated `docs.yml` with personal access token --- .github/workflows/docs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 23dda31..9cccd87 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -17,6 +17,8 @@ jobs: # Checkout the commit SHA that triggered the workflow - name: Checkout code uses: actions/checkout@v2 + with: + token: ${{ secrets.ADMIN_ACCESS_TOKEN }} - name: Generate docs run: go run ./scripts/gen-docs/main.go ${GITHUB_REF/refs\/tags\//} From 12f29db63accdd0c73f57811455ab318e7fa9461 Mon Sep 17 00:00:00 2001 From: "Alvin Tang (via GH Actions)" Date: Tue, 18 May 2021 17:44:24 +0000 Subject: [PATCH 11/32] :memo: Auto generated docs for refs/heads/main --- docs/refs/heads/main/vf-admin.md | 18 ++++++++ docs/refs/heads/main/vf-admin_configure.md | 44 +++++++++++++++++++ docs/refs/heads/main/vf-admin_organization.md | 25 +++++++++++ .../heads/main/vf-admin_organization_add.md | 36 +++++++++++++++ .../heads/main/vf-admin_organization_get.md | 32 ++++++++++++++ .../heads/main/vf-admin_organization_list.md | 32 ++++++++++++++ .../main/vf-admin_organization_remove.md | 32 ++++++++++++++ .../main/vf-admin_organization_update.md | 36 +++++++++++++++ docs/refs/heads/main/vf-admin_requirement.md | 25 +++++++++++ .../heads/main/vf-admin_requirement_add.md | 34 ++++++++++++++ .../heads/main/vf-admin_requirement_get.md | 32 ++++++++++++++ .../heads/main/vf-admin_requirement_list.md | 24 ++++++++++ .../heads/main/vf-admin_requirement_remove.md | 32 ++++++++++++++ .../heads/main/vf-admin_requirement_update.md | 34 ++++++++++++++ docs/refs/heads/main/vf-admin_version.md | 24 ++++++++++ 15 files changed, 460 insertions(+) create mode 100644 docs/refs/heads/main/vf-admin.md create mode 100644 docs/refs/heads/main/vf-admin_configure.md create mode 100644 docs/refs/heads/main/vf-admin_organization.md create mode 100644 docs/refs/heads/main/vf-admin_organization_add.md create mode 100644 docs/refs/heads/main/vf-admin_organization_get.md create mode 100644 docs/refs/heads/main/vf-admin_organization_list.md create mode 100644 docs/refs/heads/main/vf-admin_organization_remove.md create mode 100644 docs/refs/heads/main/vf-admin_organization_update.md create mode 100644 docs/refs/heads/main/vf-admin_requirement.md create mode 100644 docs/refs/heads/main/vf-admin_requirement_add.md create mode 100644 docs/refs/heads/main/vf-admin_requirement_get.md create mode 100644 docs/refs/heads/main/vf-admin_requirement_list.md create mode 100644 docs/refs/heads/main/vf-admin_requirement_remove.md create mode 100644 docs/refs/heads/main/vf-admin_requirement_update.md create mode 100644 docs/refs/heads/main/vf-admin_version.md diff --git a/docs/refs/heads/main/vf-admin.md b/docs/refs/heads/main/vf-admin.md new file mode 100644 index 0000000..4cd9b43 --- /dev/null +++ b/docs/refs/heads/main/vf-admin.md @@ -0,0 +1,18 @@ +## vf-admin + +vf-admin is a CLI to manage vaccine availabilities and other data for the Vaccine Hunters Finder tool. + +### Options + +``` + -h, --help help for vf-admin + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin configure](vf-admin_configure.md) - Configure a named profile with credentials +* [vf-admin organization](vf-admin_organization.md) - Manage organizations +* [vf-admin requirement](vf-admin_requirement.md) - Manage requirements +* [vf-admin version](vf-admin_version.md) - Returns the current version of the CLI + diff --git a/docs/refs/heads/main/vf-admin_configure.md b/docs/refs/heads/main/vf-admin_configure.md new file mode 100644 index 0000000..1fde961 --- /dev/null +++ b/docs/refs/heads/main/vf-admin_configure.md @@ -0,0 +1,44 @@ +## vf-admin configure + +Configure a named profile with credentials + +### Synopsis + +Configure the default profile or simply create new named profiles with an authentication key. + +A named profile is a set of settings and credentials that you can apply to a vf-admin CLI command. + + +``` +vf-admin configure [flags] +``` + +### Examples + +``` +z +# set up authentication key for default profile +$ vf-admin configure --key 7260841f-b47a-4b5c-9830-585af07c4405 + +# set up authentication key for a custom profile +$ vf-admin configure --profile alvin --key 7260841f-b47a-4b5c-9830-585af07c4405 + +``` + +### Options + +``` + -h, --help help for configure + -k, --key string The authentication key for future requests. +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin](vf-admin.md) - vf-admin is a CLI to manage vaccine availabilities and other data for the Vaccine Hunters Finder tool. + diff --git a/docs/refs/heads/main/vf-admin_organization.md b/docs/refs/heads/main/vf-admin_organization.md new file mode 100644 index 0000000..58eabd6 --- /dev/null +++ b/docs/refs/heads/main/vf-admin_organization.md @@ -0,0 +1,25 @@ +## vf-admin organization + +Manage organizations + +### Options + +``` + -h, --help help for organization +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin](vf-admin.md) - vf-admin is a CLI to manage vaccine availabilities and other data for the Vaccine Hunters Finder tool. +* [vf-admin organization add](vf-admin_organization_add.md) - Add a new organization +* [vf-admin organization get](vf-admin_organization_get.md) - Retrieve an organization with a specified id +* [vf-admin organization list](vf-admin_organization_list.md) - Retrieve a list of organizations +* [vf-admin organization remove](vf-admin_organization_remove.md) - Remove an organization with a specified id +* [vf-admin organization update](vf-admin_organization_update.md) - Update an organization with a specified id + diff --git a/docs/refs/heads/main/vf-admin_organization_add.md b/docs/refs/heads/main/vf-admin_organization_add.md new file mode 100644 index 0000000..8833ed1 --- /dev/null +++ b/docs/refs/heads/main/vf-admin_organization_add.md @@ -0,0 +1,36 @@ +## vf-admin organization add + +Add a new organization + +``` +vf-admin organization add [flags] +``` + +### Examples + +``` +# Add a new organization with short name "WHO", full name "World Health Organization", description "The World Health Organization is a specialized agency of the United Nations responsible for international public health." and url "https://www.who.int/" +$ vf-admin organization add --shortName WHO --fullName "World Health Organization" --description "The World Health Organization is a specialized agency of the United Nations responsible for international public health." --url "https://www.who.int/" + +``` + +### Options + +``` + --description string description of organization + --fullName string full name of the organization + -h, --help help for add + --shortName string short name of the organization + --url string url of organization +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin organization](vf-admin_organization.md) - Manage organizations + diff --git a/docs/refs/heads/main/vf-admin_organization_get.md b/docs/refs/heads/main/vf-admin_organization_get.md new file mode 100644 index 0000000..a2c5546 --- /dev/null +++ b/docs/refs/heads/main/vf-admin_organization_get.md @@ -0,0 +1,32 @@ +## vf-admin organization get + +Retrieve an organization with a specified id + +``` +vf-admin organization get [flags] +``` + +### Examples + +``` +# Get the organization with id 1. +$ vf-admin organization get 1 + +``` + +### Options + +``` + -h, --help help for get +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin organization](vf-admin_organization.md) - Manage organizations + diff --git a/docs/refs/heads/main/vf-admin_organization_list.md b/docs/refs/heads/main/vf-admin_organization_list.md new file mode 100644 index 0000000..0fd3396 --- /dev/null +++ b/docs/refs/heads/main/vf-admin_organization_list.md @@ -0,0 +1,32 @@ +## vf-admin organization list + +Retrieve a list of organizations + +``` +vf-admin organization list [flags] +``` + +### Examples + +``` +# List the organizations. +$ vf-admin organization list + +``` + +### Options + +``` + -h, --help help for list +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin organization](vf-admin_organization.md) - Manage organizations + diff --git a/docs/refs/heads/main/vf-admin_organization_remove.md b/docs/refs/heads/main/vf-admin_organization_remove.md new file mode 100644 index 0000000..4117f8e --- /dev/null +++ b/docs/refs/heads/main/vf-admin_organization_remove.md @@ -0,0 +1,32 @@ +## vf-admin organization remove + +Remove an organization with a specified id + +``` +vf-admin organization remove [flags] +``` + +### Examples + +``` +# Remove the organization with id 20. +$ vf-admin organization remove 20 + +``` + +### Options + +``` + -h, --help help for remove +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin organization](vf-admin_organization.md) - Manage organizations + diff --git a/docs/refs/heads/main/vf-admin_organization_update.md b/docs/refs/heads/main/vf-admin_organization_update.md new file mode 100644 index 0000000..06af939 --- /dev/null +++ b/docs/refs/heads/main/vf-admin_organization_update.md @@ -0,0 +1,36 @@ +## vf-admin organization update + +Update an organization with a specified id + +``` +vf-admin organization update [flags] +``` + +### Examples + +``` +# Update the organization with id 20 to have short name "WHO", full name "World Health Organization", description "The World Health Organization is a specialized agency of the United Nations responsible for international public health." and url "https://www.who.int/" +$ vf-admin organization update 20 --shortName WHO --fullName "World Health Organization" --description "The World Health Organization is a specialized agency of the United Nations responsible for international public health." --url "https://www.who.int/" + +``` + +### Options + +``` + --description string description of organization + --fullName string full name of the organization + -h, --help help for update + --shortName string short name of the organization + --url string url of organization +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin organization](vf-admin_organization.md) - Manage organizations + diff --git a/docs/refs/heads/main/vf-admin_requirement.md b/docs/refs/heads/main/vf-admin_requirement.md new file mode 100644 index 0000000..86a8909 --- /dev/null +++ b/docs/refs/heads/main/vf-admin_requirement.md @@ -0,0 +1,25 @@ +## vf-admin requirement + +Manage requirements + +### Options + +``` + -h, --help help for requirement +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin](vf-admin.md) - vf-admin is a CLI to manage vaccine availabilities and other data for the Vaccine Hunters Finder tool. +* [vf-admin requirement add](vf-admin_requirement_add.md) - Add a new requirement +* [vf-admin requirement get](vf-admin_requirement_get.md) - Retrieve a requirement with a specified id +* [vf-admin requirement list](vf-admin_requirement_list.md) - Retrieve a list of requirements +* [vf-admin requirement remove](vf-admin_requirement_remove.md) - Remove a requirement with a specified id +* [vf-admin requirement update](vf-admin_requirement_update.md) - Update a requirement with a specified id + diff --git a/docs/refs/heads/main/vf-admin_requirement_add.md b/docs/refs/heads/main/vf-admin_requirement_add.md new file mode 100644 index 0000000..2f89a08 --- /dev/null +++ b/docs/refs/heads/main/vf-admin_requirement_add.md @@ -0,0 +1,34 @@ +## vf-admin requirement add + +Add a new requirement + +``` +vf-admin requirement add [flags] +``` + +### Examples + +``` +# Add a new requirement with name "18+" and description "Any individual older than 18 years of age.". +$ vf-admin requirement add --name "18+" --description "Any individual older than 18 years of age." + +``` + +### Options + +``` + --description string description of requirement + -h, --help help for add + --name string name of requirement +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin requirement](vf-admin_requirement.md) - Manage requirements + diff --git a/docs/refs/heads/main/vf-admin_requirement_get.md b/docs/refs/heads/main/vf-admin_requirement_get.md new file mode 100644 index 0000000..ee09af9 --- /dev/null +++ b/docs/refs/heads/main/vf-admin_requirement_get.md @@ -0,0 +1,32 @@ +## vf-admin requirement get + +Retrieve a requirement with a specified id + +``` +vf-admin requirement get [flags] +``` + +### Examples + +``` +# Get the requirement with id 1. +$ vf-admin requirement get 1 + +``` + +### Options + +``` + -h, --help help for get +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin requirement](vf-admin_requirement.md) - Manage requirements + diff --git a/docs/refs/heads/main/vf-admin_requirement_list.md b/docs/refs/heads/main/vf-admin_requirement_list.md new file mode 100644 index 0000000..dbc97e4 --- /dev/null +++ b/docs/refs/heads/main/vf-admin_requirement_list.md @@ -0,0 +1,24 @@ +## vf-admin requirement list + +Retrieve a list of requirements + +``` +vf-admin requirement list [flags] +``` + +### Options + +``` + -h, --help help for list +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin requirement](vf-admin_requirement.md) - Manage requirements + diff --git a/docs/refs/heads/main/vf-admin_requirement_remove.md b/docs/refs/heads/main/vf-admin_requirement_remove.md new file mode 100644 index 0000000..129d4ed --- /dev/null +++ b/docs/refs/heads/main/vf-admin_requirement_remove.md @@ -0,0 +1,32 @@ +## vf-admin requirement remove + +Remove a requirement with a specified id + +``` +vf-admin requirement remove [flags] +``` + +### Examples + +``` +# Remove the requirement with id 8. +$ vf-admin requirement remove 8 + +``` + +### Options + +``` + -h, --help help for remove +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin requirement](vf-admin_requirement.md) - Manage requirements + diff --git a/docs/refs/heads/main/vf-admin_requirement_update.md b/docs/refs/heads/main/vf-admin_requirement_update.md new file mode 100644 index 0000000..2989d7a --- /dev/null +++ b/docs/refs/heads/main/vf-admin_requirement_update.md @@ -0,0 +1,34 @@ +## vf-admin requirement update + +Update a requirement with a specified id + +``` +vf-admin requirement update [flags] +``` + +### Examples + +``` +# Update the requirement with id 8 to have name "High-Risk" and description "Highest- and High-Risk Health Conditions.". +$ vf-admin requirement update 8 --name "High-Risk" --description "Highest- and High-Risk Health Conditions." + +``` + +### Options + +``` + --description string description of requirement + -h, --help help for update + --name string name of requirement +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin requirement](vf-admin_requirement.md) - Manage requirements + diff --git a/docs/refs/heads/main/vf-admin_version.md b/docs/refs/heads/main/vf-admin_version.md new file mode 100644 index 0000000..cfdecc7 --- /dev/null +++ b/docs/refs/heads/main/vf-admin_version.md @@ -0,0 +1,24 @@ +## vf-admin version + +Returns the current version of the CLI + +``` +vf-admin version [flags] +``` + +### Options + +``` + -h, --help help for version +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin](vf-admin.md) - vf-admin is a CLI to manage vaccine availabilities and other data for the Vaccine Hunters Finder tool. + From ce60274e52fcbec83280d96eca9d1d7067bb576d Mon Sep 17 00:00:00 2001 From: Alvin Tang Date: Tue, 18 May 2021 13:46:23 -0400 Subject: [PATCH 12/32] Updated `docs.yml` to utilize `GITHUB_TOKEN` instead --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 9cccd87..72c3e0c 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -18,7 +18,7 @@ jobs: - name: Checkout code uses: actions/checkout@v2 with: - token: ${{ secrets.ADMIN_ACCESS_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} - name: Generate docs run: go run ./scripts/gen-docs/main.go ${GITHUB_REF/refs\/tags\//} From 59b83f196426fa468c73d554e6da62e9b0c5bc18 Mon Sep 17 00:00:00 2001 From: Alvin Tang Date: Tue, 18 May 2021 13:48:58 -0400 Subject: [PATCH 13/32] Updated `docs.yml` so success if nothing to commit --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 72c3e0c..d63dcb1 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -18,7 +18,7 @@ jobs: - name: Checkout code uses: actions/checkout@v2 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} || true - name: Generate docs run: go run ./scripts/gen-docs/main.go ${GITHUB_REF/refs\/tags\//} From cf0407078ef0cb64f933677ddb5c966ed83a3f55 Mon Sep 17 00:00:00 2001 From: Eric St-Georges Date: Tue, 18 May 2021 21:30:21 -0400 Subject: [PATCH 14/32] Fixed some doc for add commands --- cmd/address.go | 2 +- cmd/organization.go | 2 +- cmd/requirement.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/address.go b/cmd/address.go index 9b4520f..5eee847 100644 --- a/cmd/address.go +++ b/cmd/address.go @@ -41,7 +41,7 @@ var addressListCmd = &cobra.Command{ RunE: list.CmdRunE, } -// Command: `vf-admin address add ` +// Command: `vf-admin address add` var addressAddCmd = &cobra.Command{ Use: "add", Short: "Add a new address", diff --git a/cmd/organization.go b/cmd/organization.go index b8005f3..a2cea7d 100644 --- a/cmd/organization.go +++ b/cmd/organization.go @@ -41,7 +41,7 @@ var organizationListCmd = &cobra.Command{ RunE: list.CmdRunE, } -// Command: `vf-admin organization add ` +// Command: `vf-admin organization add` var organizationAddCmd = &cobra.Command{ Use: "add", Short: "Add a new organization", diff --git a/cmd/requirement.go b/cmd/requirement.go index cda34ee..6e30aad 100644 --- a/cmd/requirement.go +++ b/cmd/requirement.go @@ -37,7 +37,7 @@ var requirementListCmd = &cobra.Command{ Run: list.CmdRun, } -// Command: `vf-admin requirement add ` +// Command: `vf-admin requirement add` var requirementAddCmd = &cobra.Command{ Use: "add", Short: "Add a new requirement", From 71f6cdda3699eca73ba954e13dcbd7fbbf562e00 Mon Sep 17 00:00:00 2001 From: Eric St-Georges Date: Tue, 18 May 2021 22:02:03 -0400 Subject: [PATCH 15/32] Added vaccine availability requirements --- cmd/va.go | 2 +- cmd/vaRequirement.go | 87 +++++++++++++++++++ internal/cmdrun/va/requirement/add/add.go | 69 +++++++++++++++ internal/cmdrun/va/requirement/list/list.go | 58 +++++++++++++ .../cmdrun/va/requirement/remove/remove.go | 56 ++++++++++++ .../cmdrun/va/requirement/update/update.go | 72 +++++++++++++++ 6 files changed, 343 insertions(+), 1 deletion(-) create mode 100644 cmd/vaRequirement.go create mode 100644 internal/cmdrun/va/requirement/add/add.go create mode 100644 internal/cmdrun/va/requirement/list/list.go create mode 100644 internal/cmdrun/va/requirement/remove/remove.go create mode 100644 internal/cmdrun/va/requirement/update/update.go diff --git a/cmd/va.go b/cmd/va.go index 4de62f0..8977ff7 100644 --- a/cmd/va.go +++ b/cmd/va.go @@ -24,7 +24,7 @@ var vaListCmd = &cobra.Command{ Args: cobra.ExactArgs(0), } -// Command: `vf-admin va add ` +// Command: `vf-admin va add` var vaAddCmd = &cobra.Command{ Use: "add", Short: "Add a new vaccine availability", diff --git a/cmd/vaRequirement.go b/cmd/vaRequirement.go new file mode 100644 index 0000000..2173e46 --- /dev/null +++ b/cmd/vaRequirement.go @@ -0,0 +1,87 @@ +package cmd + +import ( + "vf-admin/internal/cmdrun/va/requirement/add" + "vf-admin/internal/cmdrun/va/requirement/list" + "vf-admin/internal/cmdrun/va/requirement/remove" + "vf-admin/internal/cmdrun/va/requirement/update" + + "github.com/MakeNowJust/heredoc" + "github.com/spf13/cobra" +) + +// Command: `vf-admin va requirement` +var vaRequirementCmd = &cobra.Command{ + Use: "requirement", + Short: "Manage requirements for vaccine availability", +} + +// Command: `vf-admin va requirement list ` +var vaRequirementListCmd = &cobra.Command{ + Use: "list", + Short: "Retrieve a list of requirements for a vaccine availability", + Example: heredoc.Doc(` + # List the requirements for a vaccine availability. + $ vf-admin va requirement list + `), + Args: cobra.ExactArgs(1), + RunE: list.CmdRunE, +} + +// Command: `vf-admin va add ` +var vaRequirementAddCmd = &cobra.Command{ + Use: "add", + Short: "Add a new requirement for vaccine availability", + Example: heredoc.Doc(` + # Add a new requirement 10 for a vaccine availability c7bc794c-9905-4588-81e6-e557e1a494c4 + $ vf-admin va requirement add c7bc794c-9905-4588-81e6-e557e1a494c4 --requirement 10 + `), + Args: cobra.ExactArgs(1), + RunE: add.CmdRunE, +} + +// Command: `vf-admin va update ` +var vaRequirementUpdateCmd = &cobra.Command{ + Use: "update", + Short: "Update a requirement for vaccine availability with specified ids", + Example: heredoc.Doc(` + # update vaccine availability c7bc794c-9905-4588-81e6-e557e1a494c4 and requirement id a9620b24-0dc4-4c7d-8ca2-a9b06d627d82 with requirement id 10 and active false + $ vf-admin va requirement update c7bc794c-9905-4588-81e6-e557e1a494c4 a9620b24-0dc4-4c7d-8ca2-a9b06d627d82 --requirement 10 --active=false + `), + Args: cobra.ExactArgs(2), + RunE: update.CmdRunE, +} + +// Command: `vf-admin va remove ` +var vaRequirementRemoveCmd = &cobra.Command{ + Use: "remove", + Short: "Remove a requirement from a vaccine availability with specified ids", + Example: heredoc.Doc(` + # Remove vaccine availability c7bc794c-9905-4588-81e6-e557e1a494c4 and requirement id a9620b24-0dc4-4c7d-8ca2-a9b06d627d82 + $ vf-admin va requirement remove c7bc794c-9905-4588-81e6-e557e1a494c4 a9620b24-0dc4-4c7d-8ca2-a9b06d627d82 + `), + Args: cobra.ExactArgs(2), + RunE: remove.CmdRunE, +} + +func init() { + vaCmd.AddCommand(vaRequirementCmd) + + // List command + vaRequirementCmd.AddCommand(vaRequirementListCmd) + + // Add command + vaRequirementAddCmd.Flags().Int("requirement", 0, "id of requirement") + _ = vaRequirementAddCmd.MarkFlagRequired("requirement") + vaRequirementCmd.AddCommand(vaRequirementAddCmd) + + // Update command + vaRequirementUpdateCmd.Flags().Int("requirement", 0, "id of requirement") + _ = vaRequirementUpdateCmd.MarkFlagRequired("requirement") + vaRequirementUpdateCmd.Flags().Bool("active", false, "if the requirement is active or not") + _ = vaRequirementUpdateCmd.MarkFlagRequired("active") + vaRequirementCmd.AddCommand(vaRequirementUpdateCmd) + + // Remove command + vaRequirementCmd.AddCommand(vaRequirementRemoveCmd) +} diff --git a/internal/cmdrun/va/requirement/add/add.go b/internal/cmdrun/va/requirement/add/add.go new file mode 100644 index 0000000..177ac39 --- /dev/null +++ b/internal/cmdrun/va/requirement/add/add.go @@ -0,0 +1,69 @@ +package add + +import ( + "context" + "strconv" + "vf-admin/internal/api" + "vf-admin/internal/utils" + + "github.com/fatih/color" + "github.com/spf13/cobra" +) + +// CmdRunE is what's executed when running `vf-admin va requirement add ` +func CmdRunE(cmd *cobra.Command, args []string) error { + id := args[0] + + // Retrieve the authentication key from configuration file + key, kErr := utils.GetKeyFromProfile(cmd) + if kErr != nil { + color.Red(kErr.Error()) + return nil + } + + // Create the API client using the authentication key for requests + client, cErr := utils.GetAPIClientFromKey(key) + if cErr != nil { + color.Red(cErr.Error()) + return nil + } + + flags := cmd.Flags() + requirement, _ := flags.GetInt("requirement") + body := api.CreateRequirementForVaccineAvailabilityByIdApiV1VaccineAvailabilityVaccineAvailabilityIdRequirementsPostJSONRequestBody{Requirement: requirement} + + // Create spinner + spinner, sErr := utils.GetDefaultSpinnerForHTTPOp("add", "added", "va requirement") + if sErr != nil { + color.Red(sErr.Error()) + return nil + } + _ = spinner.Start() + + res, rErr := client.CreateRequirementForVaccineAvailabilityByIdApiV1VaccineAvailabilityVaccineAvailabilityIdRequirementsPostWithResponse(context.Background(), id, body) + + if rErr != nil { + spinner.StopFailMessage(rErr.Error()) + _ = spinner.StopFail() + return nil + } + + if res.StatusCode() != 200 { + spinner.StopFailMessage(res.Status() + ": " + string(res.Body)) + _ = spinner.StopFail() + return nil + } + + _ = spinner.Stop() + + colNames := []string{"id", "vaccine availability", "requirement", "active", "name", "description", "created at"} + json := res.JSON200 + data := [][]string{ + { + json.Id, json.VaccineAvailability, strconv.Itoa(json.Requirement), strconv.FormatBool(json.Active), json.Name, json.Description, json.CreatedAt.String(), + }, + } + utils.RenderDefaultTable(colNames, data) + + return nil +} diff --git a/internal/cmdrun/va/requirement/list/list.go b/internal/cmdrun/va/requirement/list/list.go new file mode 100644 index 0000000..5429501 --- /dev/null +++ b/internal/cmdrun/va/requirement/list/list.go @@ -0,0 +1,58 @@ +package list + +import ( + "context" + "strconv" + "vf-admin/internal/utils" + + "github.com/fatih/color" + "github.com/spf13/cobra" +) + +// CmdRunE is what's executed when running `vf-admin va requirement list >` +func CmdRunE(cmd *cobra.Command, args []string) error { + id := args[0] + + // Create the API client + client, cErr := utils.GetAPIClient() + if cErr != nil { + color.Red(cErr.Error()) + return nil + } + + // Create spinner + spinner, sErr := utils.GetDefaultSpinnerForHTTPOp("list", "got", "va requirement") + if sErr != nil { + color.Red(sErr.Error()) + return nil + } + _ = spinner.Start() + + res, rErr := client.ListRequirementsForVaccineAvailabilityByIdApiV1VaccineAvailabilityVaccineAvailabilityIdRequirementsGetWithResponse(context.Background(), id) + + if rErr != nil { + spinner.StopFailMessage(rErr.Error()) + _ = spinner.StopFail() + return nil + } + + if res.StatusCode() != 200 { + spinner.StopFailMessage(res.Status() + ": " + string(res.Body)) + _ = spinner.StopFail() + return nil + } + + _ = spinner.Stop() + + colNames := []string{"id", "vaccine availability", "requirement", "active", "name", "description", "created at"} + var data [][]string + for _, row := range *res.JSON200 { + data = append(data, []string{ + row.Id, row.VaccineAvailability, strconv.Itoa(row.Requirement), strconv.FormatBool(row.Active), row.Name, row.Description, row.CreatedAt.String(), + }) + } + + utils.RenderDefaultTable(colNames, data) + + return nil +} diff --git a/internal/cmdrun/va/requirement/remove/remove.go b/internal/cmdrun/va/requirement/remove/remove.go new file mode 100644 index 0000000..ae7b7ce --- /dev/null +++ b/internal/cmdrun/va/requirement/remove/remove.go @@ -0,0 +1,56 @@ +package remove + +import ( + "context" + "fmt" + "vf-admin/internal/utils" + + "github.com/fatih/color" + "github.com/spf13/cobra" +) + +// CmdRunE is what's executed when running `vf-admin va requirement remove ` +func CmdRunE(cmd *cobra.Command, args []string) error { + vaID := args[0] + reqID := args[1] + + // Retrieve the authentication key from configuration file + key, kErr := utils.GetKeyFromProfile(cmd) + if kErr != nil { + color.Red(kErr.Error()) + return nil + } + + // Create the API client using the authentication key for requests + client, cErr := utils.GetAPIClientFromKey(key) + if cErr != nil { + color.Red(cErr.Error()) + return nil + } + + // Create spinner + spinner, sErr := utils.GetDefaultSpinnerForHTTPOp("remove", "removed", fmt.Sprint("vaccine availability ", vaID, " requirement id ", reqID)) + if sErr != nil { + color.Red(sErr.Error()) + return nil + } + _ = spinner.Start() + + res, rErr := client.DeleteRequirementForVaccineAvailabilityByIdApiV1VaccineAvailabilityVaccineAvailabilityIdRequirementsRequirementIdDeleteWithResponse(context.Background(), vaID, reqID) + + if rErr != nil { + spinner.StopFailMessage(rErr.Error()) + _ = spinner.StopFail() + return nil + } + + if res.StatusCode() != 204 { + spinner.StopFailMessage(res.Status() + ": " + string(res.Body)) + _ = spinner.StopFail() + return nil + } + + _ = spinner.Stop() + + return nil +} diff --git a/internal/cmdrun/va/requirement/update/update.go b/internal/cmdrun/va/requirement/update/update.go new file mode 100644 index 0000000..6e3d48b --- /dev/null +++ b/internal/cmdrun/va/requirement/update/update.go @@ -0,0 +1,72 @@ +package update + +import ( + "context" + "strconv" + "vf-admin/internal/api" + "vf-admin/internal/utils" + + "github.com/fatih/color" + "github.com/spf13/cobra" +) + +// CmdRunE is what's executed when running `vf-admin va requirement update ` +func CmdRunE(cmd *cobra.Command, args []string) error { + vaID := args[0] + reqID := args[1] + + // Retrieve the authentication key from configuration file + key, kErr := utils.GetKeyFromProfile(cmd) + if kErr != nil { + color.Red(kErr.Error()) + return nil + } + + // Create the API client using the authentication key for requests + client, cErr := utils.GetAPIClientFromKey(key) + if cErr != nil { + color.Red(cErr.Error()) + return nil + } + + flags := cmd.Flags() + requirement, _ := flags.GetInt("requirement") + active, _ := flags.GetBool("active") + + body := api.UpdateRequirementForVaccineAvailabilityByIdApiV1VaccineAvailabilityVaccineAvailabilityIdRequirementsRequirementIdPutJSONRequestBody{Requirement: requirement, Active: active} + + // Create spinner + spinner, sErr := utils.GetDefaultSpinnerForHTTPOp("update", "updated", "va requirement") + if sErr != nil { + color.Red(sErr.Error()) + return nil + } + _ = spinner.Start() + + res, rErr := client.UpdateRequirementForVaccineAvailabilityByIdApiV1VaccineAvailabilityVaccineAvailabilityIdRequirementsRequirementIdPutWithResponse(context.Background(), vaID, reqID, body) + + if rErr != nil { + spinner.StopFailMessage(rErr.Error()) + _ = spinner.StopFail() + return nil + } + + if res.StatusCode() != 200 { + spinner.StopFailMessage(res.Status() + ": " + string(res.Body)) + _ = spinner.StopFail() + return nil + } + + _ = spinner.Stop() + + colNames := []string{"id", "vaccine availability", "requirement", "active", "name", "description", "created at"} + json := res.JSON200 + data := [][]string{ + { + json.Id, json.VaccineAvailability, strconv.Itoa(json.Requirement), strconv.FormatBool(json.Active), json.Name, json.Description, json.CreatedAt.String(), + }, + } + utils.RenderDefaultTable(colNames, data) + + return nil +} From 46e81cbab76eab026f526ea32dca3dcb689f638c Mon Sep 17 00:00:00 2001 From: Alvin Tang Date: Thu, 20 May 2021 15:00:22 -0400 Subject: [PATCH 16/32] Added more badges for the new Github workflows and the releases we will have. --- README.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bb8a93c..d594cfc 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,20 @@
+ + Latest Release + - Go v1.15 + Go v1.15 - Go Report Card + Go Report Card + + + Tests + + + Build Docs Discord: #vax-ui-backend From 35925f1404fd0ffd71f16c45036728db2ed23d55 Mon Sep 17 00:00:00 2001 From: Eric St-Georges Date: Thu, 20 May 2021 16:35:12 -0400 Subject: [PATCH 17/32] va-timeslots: Added va timeslots commands --- cmd/vaTimeslot.go | 90 +++++++++++++++++++ internal/cmdrun/va/timeslot/add/add.go | 81 +++++++++++++++++ internal/cmdrun/va/timeslot/list/list.go | 63 ++++++++++++++ internal/cmdrun/va/timeslot/remove/remove.go | 56 ++++++++++++ internal/cmdrun/va/timeslot/update/update.go | 92 ++++++++++++++++++++ 5 files changed, 382 insertions(+) create mode 100644 cmd/vaTimeslot.go create mode 100644 internal/cmdrun/va/timeslot/add/add.go create mode 100644 internal/cmdrun/va/timeslot/list/list.go create mode 100644 internal/cmdrun/va/timeslot/remove/remove.go create mode 100644 internal/cmdrun/va/timeslot/update/update.go diff --git a/cmd/vaTimeslot.go b/cmd/vaTimeslot.go new file mode 100644 index 0000000..a9555fd --- /dev/null +++ b/cmd/vaTimeslot.go @@ -0,0 +1,90 @@ +package cmd + +import ( + "vf-admin/internal/cmdrun/va/timeslot/add" + "vf-admin/internal/cmdrun/va/timeslot/list" + "vf-admin/internal/cmdrun/va/timeslot/remove" + "vf-admin/internal/cmdrun/va/timeslot/update" + + "github.com/MakeNowJust/heredoc" + "github.com/spf13/cobra" +) + +// Command: `vf-admin va timeslot` +var vaTimeslotCmd = &cobra.Command{ + Use: "timeslot", + Short: "Manage timeslots for vaccine availability", +} + +// Command: `vf-admin va timeslot list ` +var vaTimeslotListCmd = &cobra.Command{ + Use: "list", + Short: "Retrieve a list of timeslots for a vaccine availability", + Example: heredoc.Doc(` + # List the timeslots for a vaccine availability. + $ vf-admin va timeslot list + `), + Args: cobra.ExactArgs(1), + RunE: list.CmdRunE, +} + +// Command: `vf-admin va add ` +var vaTimeslotAddCmd = &cobra.Command{ + Use: "add", + Short: "Add a new timeslot for vaccine availability", + /* + Example: heredoc.Doc(` + # Add a new timeslot 10 for a vaccine availability c7bc794c-9905-4588-81e6-e557e1a494c4 with time "2006-01-02T15:04:05Z07:00" + $ vf-admin va timeslot add c7bc794c-9905-4588-81e6-e557e1a494c4 --time "2006-01-02T15:04:05Z07:00" + `), + */ + Args: cobra.ExactArgs(1), + RunE: add.CmdRunE, +} + +// Command: `vf-admin va update ` +var vaTimeslotUpdateCmd = &cobra.Command{ + Use: "update", + Short: "Update a timeslot for vaccine availability with specified ids", + /* + Example: heredoc.Doc(` + # update vaccine availability c7bc794c-9905-4588-81e6-e557e1a494c4 and timeslot id a9620b24-0dc4-4c7d-8ca2-a9b06d627d82 with time "2006-01-02T15:04:05Z07:00" + $ vf-admin va timeslot update c7bc794c-9905-4588-81e6-e557e1a494c4 a9620b24-0dc4-4c7d-8ca2-a9b06d627d82 --time "2006-01-02T15:04:05Z07:00" + `), + */ + Args: cobra.ExactArgs(2), + RunE: update.CmdRunE, +} + +// Command: `vf-admin va remove ` +var vaTimeslotRemoveCmd = &cobra.Command{ + Use: "remove", + Short: "Remove a timeslot from a vaccine availability with specified ids", + Example: heredoc.Doc(` + # Remove vaccine availability c7bc794c-9905-4588-81e6-e557e1a494c4 and timeslot id a9620b24-0dc4-4c7d-8ca2-a9b06d627d82 + $ vf-admin va timeslot remove c7bc794c-9905-4588-81e6-e557e1a494c4 a9620b24-0dc4-4c7d-8ca2-a9b06d627d82 + `), + Args: cobra.ExactArgs(2), + RunE: remove.CmdRunE, +} + +func init() { + vaCmd.AddCommand(vaTimeslotCmd) + + // List command + vaTimeslotCmd.AddCommand(vaTimeslotListCmd) + + // Add command + vaTimeslotAddCmd.Flags().String("time", "", "time of the slot (RFC 3339)") + _ = vaTimeslotAddCmd.MarkFlagRequired("time") + vaTimeslotCmd.AddCommand(vaTimeslotAddCmd) + + // Update command + vaTimeslotUpdateCmd.Flags().String("time", "", "time of the slot (RFC 3339)") + _ = vaTimeslotUpdateCmd.MarkFlagRequired("time") + vaTimeslotUpdateCmd.Flags().String("takenAt", "", "time of the slot was taken (RFC 3339)") + vaTimeslotCmd.AddCommand(vaTimeslotUpdateCmd) + + // Remove command + vaTimeslotCmd.AddCommand(vaTimeslotRemoveCmd) +} diff --git a/internal/cmdrun/va/timeslot/add/add.go b/internal/cmdrun/va/timeslot/add/add.go new file mode 100644 index 0000000..b6f6f7a --- /dev/null +++ b/internal/cmdrun/va/timeslot/add/add.go @@ -0,0 +1,81 @@ +package add + +import ( + "context" + "time" + "vf-admin/internal/api" + "vf-admin/internal/utils" + + "github.com/fatih/color" + "github.com/spf13/cobra" +) + +// CmdRunE is what's executed when running `vf-admin va timeslot add ` +func CmdRunE(cmd *cobra.Command, args []string) error { + id := args[0] + + // Retrieve the authentication key from configuration file + key, kErr := utils.GetKeyFromProfile(cmd) + if kErr != nil { + color.Red(kErr.Error()) + return nil + } + + // Create the API client using the authentication key for requests + client, cErr := utils.GetAPIClientFromKey(key) + if cErr != nil { + color.Red(cErr.Error()) + return nil + } + + flags := cmd.Flags() + timeString, _ := flags.GetString("time") + time, tErr := time.Parse(time.RFC3339, timeString) + if tErr != nil { + color.Red(tErr.Error()) + return nil + } + body := api.CreateTimeslotForVaccineAvailabilityByIdApiV1VaccineAvailabilityVaccineAvailabilityIdTimeslotsPostJSONRequestBody{Time: time} + + // Create spinner + spinner, sErr := utils.GetDefaultSpinnerForHTTPOp("add", "added", "va timeslot") + if sErr != nil { + color.Red(sErr.Error()) + return nil + } + + _ = spinner.Start() + + res, rErr := client.CreateTimeslotForVaccineAvailabilityByIdApiV1VaccineAvailabilityVaccineAvailabilityIdTimeslotsPostWithResponse(context.Background(), id, body) + + if rErr != nil { + spinner.StopFailMessage(rErr.Error()) + _ = spinner.StopFail() + return nil + } + + if res.StatusCode() != 200 { + spinner.StopFailMessage(res.Status() + ": " + string(res.Body)) + _ = spinner.StopFail() + return nil + } + + _ = spinner.Stop() + + colNames := []string{"id", "vaccine availability", "time", "taken at", "created at"} + json := res.JSON200 + var takenAt string + if json.TakenAt == nil { + takenAt = "" + } else { + takenAt = json.TakenAt.String() + } + data := [][]string{ + { + json.Id, json.VaccineAvailability, json.Time.String(), takenAt, json.CreatedAt.String(), + }, + } + utils.RenderDefaultTable(colNames, data) + + return nil +} diff --git a/internal/cmdrun/va/timeslot/list/list.go b/internal/cmdrun/va/timeslot/list/list.go new file mode 100644 index 0000000..86f55ec --- /dev/null +++ b/internal/cmdrun/va/timeslot/list/list.go @@ -0,0 +1,63 @@ +package list + +import ( + "context" + "vf-admin/internal/utils" + + "github.com/fatih/color" + "github.com/spf13/cobra" +) + +// CmdRunE is what's executed when running `vf-admin va timelist list >` +func CmdRunE(cmd *cobra.Command, args []string) error { + id := args[0] + + // Create the API client + client, cErr := utils.GetAPIClient() + if cErr != nil { + color.Red(cErr.Error()) + return nil + } + + // Create spinner + spinner, sErr := utils.GetDefaultSpinnerForHTTPOp("list", "got", "va requirement") + if sErr != nil { + color.Red(sErr.Error()) + return nil + } + _ = spinner.Start() + + res, rErr := client.ListTimeslotsForVaccineAvailabilityByIdApiV1VaccineAvailabilityVaccineAvailabilityIdTimeslotsGetWithResponse(context.Background(), id) + + if rErr != nil { + spinner.StopFailMessage(rErr.Error()) + _ = spinner.StopFail() + return nil + } + + if res.StatusCode() != 200 { + spinner.StopFailMessage(res.Status() + ": " + string(res.Body)) + _ = spinner.StopFail() + return nil + } + + _ = spinner.Stop() + + colNames := []string{"id", "vaccine availability", "time", "taken at", "created at"} + var data [][]string + for _, row := range *res.JSON200 { + var takenAt string + if row.TakenAt == nil { + takenAt = "" + } else { + takenAt = row.TakenAt.String() + } + data = append(data, []string{ + row.Id, row.VaccineAvailability, row.Time.String(), takenAt, row.CreatedAt.String(), + }) + } + + utils.RenderDefaultTable(colNames, data) + + return nil +} diff --git a/internal/cmdrun/va/timeslot/remove/remove.go b/internal/cmdrun/va/timeslot/remove/remove.go new file mode 100644 index 0000000..33f4308 --- /dev/null +++ b/internal/cmdrun/va/timeslot/remove/remove.go @@ -0,0 +1,56 @@ +package remove + +import ( + "context" + "fmt" + "vf-admin/internal/utils" + + "github.com/fatih/color" + "github.com/spf13/cobra" +) + +// CmdRunE is what's executed when running `vf-admin va timeslot remove ` +func CmdRunE(cmd *cobra.Command, args []string) error { + vaID := args[0] + slotID := args[1] + + // Retrieve the authentication key from configuration file + key, kErr := utils.GetKeyFromProfile(cmd) + if kErr != nil { + color.Red(kErr.Error()) + return nil + } + + // Create the API client using the authentication key for requests + client, cErr := utils.GetAPIClientFromKey(key) + if cErr != nil { + color.Red(cErr.Error()) + return nil + } + + // Create spinner + spinner, sErr := utils.GetDefaultSpinnerForHTTPOp("remove", "removed", fmt.Sprint("vaccine availability ", vaID, " timeslot id ", slotID)) + if sErr != nil { + color.Red(sErr.Error()) + return nil + } + _ = spinner.Start() + + res, rErr := client.DeleteTimeslotForVaccineAvailabilityByIdApiV1VaccineAvailabilityVaccineAvailabilityIdTimeslotsTimeslotIdDeleteWithResponse(context.Background(), vaID, slotID) + + if rErr != nil { + spinner.StopFailMessage(rErr.Error()) + _ = spinner.StopFail() + return nil + } + + if res.StatusCode() != 204 { + spinner.StopFailMessage(res.Status() + ": " + string(res.Body)) + _ = spinner.StopFail() + return nil + } + + _ = spinner.Stop() + + return nil +} diff --git a/internal/cmdrun/va/timeslot/update/update.go b/internal/cmdrun/va/timeslot/update/update.go new file mode 100644 index 0000000..5533c9c --- /dev/null +++ b/internal/cmdrun/va/timeslot/update/update.go @@ -0,0 +1,92 @@ +package update + +import ( + "context" + "time" + "vf-admin/internal/api" + "vf-admin/internal/utils" + + "github.com/fatih/color" + "github.com/spf13/cobra" +) + +// CmdRunE is what's executed when running `vf-admin va timeslot update ` +func CmdRunE(cmd *cobra.Command, args []string) error { + vaID := args[0] + slotID := args[1] + + // Retrieve the authentication key from configuration file + key, kErr := utils.GetKeyFromProfile(cmd) + if kErr != nil { + color.Red(kErr.Error()) + return nil + } + + // Create the API client using the authentication key for requests + client, cErr := utils.GetAPIClientFromKey(key) + if cErr != nil { + color.Red(cErr.Error()) + return nil + } + + flags := cmd.Flags() + timeString, _ := flags.GetString("time") + slotTime, tErr := time.Parse(time.RFC3339, timeString) + if tErr != nil { + color.Red(tErr.Error()) + return nil + } + + var takenAtBody interface{} + if flags.Changed("takenAt") { + t, _ := flags.GetString("takenAt") + t2, tErr := time.Parse(time.RFC3339, t) + if tErr != nil { + color.Red(tErr.Error()) + return nil + } + takenAtBody = t2 + } + body := api.UpdateTimeslotForVaccineAvailabilityByIdApiV1VaccineAvailabilityVaccineAvailabilityIdTimeslotsTimeslotIdPutJSONRequestBody{Time: slotTime, TakenAt: &takenAtBody} + + // Create spinner + spinner, sErr := utils.GetDefaultSpinnerForHTTPOp("update", "updated", "va timeslot") + if sErr != nil { + color.Red(sErr.Error()) + return nil + } + _ = spinner.Start() + + res, rErr := client.UpdateTimeslotForVaccineAvailabilityByIdApiV1VaccineAvailabilityVaccineAvailabilityIdTimeslotsTimeslotIdPutWithResponse(context.Background(), vaID, slotID, body) + + if rErr != nil { + spinner.StopFailMessage(rErr.Error()) + _ = spinner.StopFail() + return nil + } + + if res.StatusCode() != 200 { + spinner.StopFailMessage(res.Status() + ": " + string(res.Body)) + _ = spinner.StopFail() + return nil + } + + _ = spinner.Stop() + + colNames := []string{"id", "vaccine availability", "time", "taken at", "created at"} + json := res.JSON200 + var takenAt string + if json.TakenAt == nil { + takenAt = "" + } else { + takenAt = json.TakenAt.String() + } + data := [][]string{ + { + json.Id, json.VaccineAvailability, json.Time.String(), takenAt, json.CreatedAt.String(), + }, + } + utils.RenderDefaultTable(colNames, data) + + return nil +} From 7b3b5406ce874acbd6db7c2f5009a2c8889ee5a6 Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 20 May 2021 21:34:31 +0000 Subject: [PATCH 18/32] :memo: Auto generated docs in `docs/source`. --- docs/source/vf-admin.md | 1 + docs/source/vf-admin_va.md | 21 ++++++++++++ docs/source/vf-admin_va_requirement.md | 24 +++++++++++++ docs/source/vf-admin_va_requirement_add.md | 33 ++++++++++++++++++ docs/source/vf-admin_va_requirement_list.md | 32 +++++++++++++++++ docs/source/vf-admin_va_requirement_remove.md | 32 +++++++++++++++++ docs/source/vf-admin_va_requirement_update.md | 34 +++++++++++++++++++ 7 files changed, 177 insertions(+) create mode 100644 docs/source/vf-admin_va.md create mode 100644 docs/source/vf-admin_va_requirement.md create mode 100644 docs/source/vf-admin_va_requirement_add.md create mode 100644 docs/source/vf-admin_va_requirement_list.md create mode 100644 docs/source/vf-admin_va_requirement_remove.md create mode 100644 docs/source/vf-admin_va_requirement_update.md diff --git a/docs/source/vf-admin.md b/docs/source/vf-admin.md index 374c891..6054920 100644 --- a/docs/source/vf-admin.md +++ b/docs/source/vf-admin.md @@ -15,5 +15,6 @@ vf-admin is a CLI to manage vaccine availabilities and other data for the Vaccin * [vf-admin configure](vf-admin_configure.md) - Configure a named profile with credentials * [vf-admin organization](vf-admin_organization.md) - Manage organizations * [vf-admin requirement](vf-admin_requirement.md) - Manage requirements +* [vf-admin va](vf-admin_va.md) - Manage vaccine availabilities * [vf-admin version](vf-admin_version.md) - Returns the current version of the CLI diff --git a/docs/source/vf-admin_va.md b/docs/source/vf-admin_va.md new file mode 100644 index 0000000..eea1d4d --- /dev/null +++ b/docs/source/vf-admin_va.md @@ -0,0 +1,21 @@ +## vf-admin va + +Manage vaccine availabilities + +### Options + +``` + -h, --help help for va +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin](vf-admin.md) - vf-admin is a CLI to manage vaccine availabilities and other data for the Vaccine Hunters Finder tool. +* [vf-admin va requirement](vf-admin_va_requirement.md) - Manage requirements for vaccine availability + diff --git a/docs/source/vf-admin_va_requirement.md b/docs/source/vf-admin_va_requirement.md new file mode 100644 index 0000000..8c37361 --- /dev/null +++ b/docs/source/vf-admin_va_requirement.md @@ -0,0 +1,24 @@ +## vf-admin va requirement + +Manage requirements for vaccine availability + +### Options + +``` + -h, --help help for requirement +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin va](vf-admin_va.md) - Manage vaccine availabilities +* [vf-admin va requirement add](vf-admin_va_requirement_add.md) - Add a new requirement for vaccine availability +* [vf-admin va requirement list](vf-admin_va_requirement_list.md) - Retrieve a list of requirements for a vaccine availability +* [vf-admin va requirement remove](vf-admin_va_requirement_remove.md) - Remove a requirement from a vaccine availability with specified ids +* [vf-admin va requirement update](vf-admin_va_requirement_update.md) - Update a requirement for vaccine availability with specified ids + diff --git a/docs/source/vf-admin_va_requirement_add.md b/docs/source/vf-admin_va_requirement_add.md new file mode 100644 index 0000000..d999526 --- /dev/null +++ b/docs/source/vf-admin_va_requirement_add.md @@ -0,0 +1,33 @@ +## vf-admin va requirement add + +Add a new requirement for vaccine availability + +``` +vf-admin va requirement add [flags] +``` + +### Examples + +``` +# Add a new requirement 10 for a vaccine availability c7bc794c-9905-4588-81e6-e557e1a494c4 +$ vf-admin va requirement add c7bc794c-9905-4588-81e6-e557e1a494c4 --requirement 10 + +``` + +### Options + +``` + -h, --help help for add + --requirement int id of requirement +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin va requirement](vf-admin_va_requirement.md) - Manage requirements for vaccine availability + diff --git a/docs/source/vf-admin_va_requirement_list.md b/docs/source/vf-admin_va_requirement_list.md new file mode 100644 index 0000000..a4d4be7 --- /dev/null +++ b/docs/source/vf-admin_va_requirement_list.md @@ -0,0 +1,32 @@ +## vf-admin va requirement list + +Retrieve a list of requirements for a vaccine availability + +``` +vf-admin va requirement list [flags] +``` + +### Examples + +``` +# List the requirements for a vaccine availability. +$ vf-admin va requirement list + +``` + +### Options + +``` + -h, --help help for list +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin va requirement](vf-admin_va_requirement.md) - Manage requirements for vaccine availability + diff --git a/docs/source/vf-admin_va_requirement_remove.md b/docs/source/vf-admin_va_requirement_remove.md new file mode 100644 index 0000000..b95ad28 --- /dev/null +++ b/docs/source/vf-admin_va_requirement_remove.md @@ -0,0 +1,32 @@ +## vf-admin va requirement remove + +Remove a requirement from a vaccine availability with specified ids + +``` +vf-admin va requirement remove [flags] +``` + +### Examples + +``` +# Remove vaccine availability c7bc794c-9905-4588-81e6-e557e1a494c4 and requirement id a9620b24-0dc4-4c7d-8ca2-a9b06d627d82 +$ vf-admin va requirement remove c7bc794c-9905-4588-81e6-e557e1a494c4 a9620b24-0dc4-4c7d-8ca2-a9b06d627d82 + +``` + +### Options + +``` + -h, --help help for remove +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin va requirement](vf-admin_va_requirement.md) - Manage requirements for vaccine availability + diff --git a/docs/source/vf-admin_va_requirement_update.md b/docs/source/vf-admin_va_requirement_update.md new file mode 100644 index 0000000..cf81cc1 --- /dev/null +++ b/docs/source/vf-admin_va_requirement_update.md @@ -0,0 +1,34 @@ +## vf-admin va requirement update + +Update a requirement for vaccine availability with specified ids + +``` +vf-admin va requirement update [flags] +``` + +### Examples + +``` +# update vaccine availability c7bc794c-9905-4588-81e6-e557e1a494c4 and requirement id a9620b24-0dc4-4c7d-8ca2-a9b06d627d82 with requirement id 10 and active false +$ vf-admin va requirement update c7bc794c-9905-4588-81e6-e557e1a494c4 a9620b24-0dc4-4c7d-8ca2-a9b06d627d82 --requirement 10 --active=false + +``` + +### Options + +``` + --active if the requirement is active or not + -h, --help help for update + --requirement int id of requirement +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin va requirement](vf-admin_va_requirement.md) - Manage requirements for vaccine availability + From 61c39a78c6cf1d04a003507fd0fbb528c4801757 Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 20 May 2021 21:49:04 +0000 Subject: [PATCH 19/32] :memo: Auto generated docs in `docs/source`. --- docs/source/vf-admin_va.md | 1 + docs/source/vf-admin_va_timeslot.md | 24 ++++++++++++++++ docs/source/vf-admin_va_timeslot_add.md | 25 +++++++++++++++++ docs/source/vf-admin_va_timeslot_list.md | 32 ++++++++++++++++++++++ docs/source/vf-admin_va_timeslot_remove.md | 32 ++++++++++++++++++++++ docs/source/vf-admin_va_timeslot_update.md | 26 ++++++++++++++++++ 6 files changed, 140 insertions(+) create mode 100644 docs/source/vf-admin_va_timeslot.md create mode 100644 docs/source/vf-admin_va_timeslot_add.md create mode 100644 docs/source/vf-admin_va_timeslot_list.md create mode 100644 docs/source/vf-admin_va_timeslot_remove.md create mode 100644 docs/source/vf-admin_va_timeslot_update.md diff --git a/docs/source/vf-admin_va.md b/docs/source/vf-admin_va.md index eea1d4d..cf78bb3 100644 --- a/docs/source/vf-admin_va.md +++ b/docs/source/vf-admin_va.md @@ -18,4 +18,5 @@ Manage vaccine availabilities * [vf-admin](vf-admin.md) - vf-admin is a CLI to manage vaccine availabilities and other data for the Vaccine Hunters Finder tool. * [vf-admin va requirement](vf-admin_va_requirement.md) - Manage requirements for vaccine availability +* [vf-admin va timeslot](vf-admin_va_timeslot.md) - Manage timeslots for vaccine availability diff --git a/docs/source/vf-admin_va_timeslot.md b/docs/source/vf-admin_va_timeslot.md new file mode 100644 index 0000000..5e96325 --- /dev/null +++ b/docs/source/vf-admin_va_timeslot.md @@ -0,0 +1,24 @@ +## vf-admin va timeslot + +Manage timeslots for vaccine availability + +### Options + +``` + -h, --help help for timeslot +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin va](vf-admin_va.md) - Manage vaccine availabilities +* [vf-admin va timeslot add](vf-admin_va_timeslot_add.md) - Add a new timeslot for vaccine availability +* [vf-admin va timeslot list](vf-admin_va_timeslot_list.md) - Retrieve a list of timeslots for a vaccine availability +* [vf-admin va timeslot remove](vf-admin_va_timeslot_remove.md) - Remove a timeslot from a vaccine availability with specified ids +* [vf-admin va timeslot update](vf-admin_va_timeslot_update.md) - Update a timeslot for vaccine availability with specified ids + diff --git a/docs/source/vf-admin_va_timeslot_add.md b/docs/source/vf-admin_va_timeslot_add.md new file mode 100644 index 0000000..63a7fb9 --- /dev/null +++ b/docs/source/vf-admin_va_timeslot_add.md @@ -0,0 +1,25 @@ +## vf-admin va timeslot add + +Add a new timeslot for vaccine availability + +``` +vf-admin va timeslot add [flags] +``` + +### Options + +``` + -h, --help help for add + --time string time of the slot (RFC 3339) +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin va timeslot](vf-admin_va_timeslot.md) - Manage timeslots for vaccine availability + diff --git a/docs/source/vf-admin_va_timeslot_list.md b/docs/source/vf-admin_va_timeslot_list.md new file mode 100644 index 0000000..04a6eb4 --- /dev/null +++ b/docs/source/vf-admin_va_timeslot_list.md @@ -0,0 +1,32 @@ +## vf-admin va timeslot list + +Retrieve a list of timeslots for a vaccine availability + +``` +vf-admin va timeslot list [flags] +``` + +### Examples + +``` +# List the timeslots for a vaccine availability. +$ vf-admin va timeslot list + +``` + +### Options + +``` + -h, --help help for list +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin va timeslot](vf-admin_va_timeslot.md) - Manage timeslots for vaccine availability + diff --git a/docs/source/vf-admin_va_timeslot_remove.md b/docs/source/vf-admin_va_timeslot_remove.md new file mode 100644 index 0000000..08d2bb1 --- /dev/null +++ b/docs/source/vf-admin_va_timeslot_remove.md @@ -0,0 +1,32 @@ +## vf-admin va timeslot remove + +Remove a timeslot from a vaccine availability with specified ids + +``` +vf-admin va timeslot remove [flags] +``` + +### Examples + +``` +# Remove vaccine availability c7bc794c-9905-4588-81e6-e557e1a494c4 and timeslot id a9620b24-0dc4-4c7d-8ca2-a9b06d627d82 +$ vf-admin va timeslot remove c7bc794c-9905-4588-81e6-e557e1a494c4 a9620b24-0dc4-4c7d-8ca2-a9b06d627d82 + +``` + +### Options + +``` + -h, --help help for remove +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin va timeslot](vf-admin_va_timeslot.md) - Manage timeslots for vaccine availability + diff --git a/docs/source/vf-admin_va_timeslot_update.md b/docs/source/vf-admin_va_timeslot_update.md new file mode 100644 index 0000000..3207304 --- /dev/null +++ b/docs/source/vf-admin_va_timeslot_update.md @@ -0,0 +1,26 @@ +## vf-admin va timeslot update + +Update a timeslot for vaccine availability with specified ids + +``` +vf-admin va timeslot update [flags] +``` + +### Options + +``` + -h, --help help for update + --takenAt string time of the slot was taken (RFC 3339) + --time string time of the slot (RFC 3339) +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin va timeslot](vf-admin_va_timeslot.md) - Manage timeslots for vaccine availability + From 984f3788eb8274148e218e763894b685a480b4f6 Mon Sep 17 00:00:00 2001 From: gesarki Date: Thu, 20 May 2021 19:57:11 -0400 Subject: [PATCH 20/32] feat(loc): implemented location commands --- .github/workflows/docs.yml | 19 +++- cmd/location.go | 117 +++++++++++++++++++++ internal/cmdrun/location/add/add.go | 111 ++++++++++++++++++++ internal/cmdrun/location/get/get.go | 62 +++++++++++ internal/cmdrun/location/list/list.go | 50 +++++++++ internal/cmdrun/location/locationutils.go | 76 ++++++++++++++ internal/cmdrun/location/remove/remove.go | 60 +++++++++++ internal/cmdrun/location/update/update.go | 119 ++++++++++++++++++++++ test.txt | 23 +++++ test_req.txt | 18 ++++ 10 files changed, 650 insertions(+), 5 deletions(-) create mode 100644 cmd/location.go create mode 100644 internal/cmdrun/location/add/add.go create mode 100644 internal/cmdrun/location/get/get.go create mode 100644 internal/cmdrun/location/list/list.go create mode 100644 internal/cmdrun/location/locationutils.go create mode 100644 internal/cmdrun/location/remove/remove.go create mode 100644 internal/cmdrun/location/update/update.go create mode 100644 test.txt create mode 100644 test_req.txt diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index d63dcb1..c59d8b0 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,21 +13,30 @@ jobs: uses: actions/setup-go@v2 with: go-version: "1.16" - + # Checkout the commit SHA that triggered the workflow - name: Checkout code uses: actions/checkout@v2 with: token: ${{ secrets.GITHUB_TOKEN }} || true - + + # Get version for generated docs + - name: Get version + run: | + case $GITHUB_REF in refs/heads/*) + echo "DOCS_VERSION=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV;; + case $GITHUB_REF in refs/tags/*) + echo "DOCS_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV;; + esac + - name: Generate docs - run: go run ./scripts/gen-docs/main.go ${GITHUB_REF/refs\/tags\//} - + run: go run ./scripts/gen-docs/main.go ${{ env.DOCS_VERSION }} + - name: Commit and push docs run: | git config --global user.name "Alvin Tang (via GH Actions)" git config --global user.email "alvintangz@users.noreply.github.com" git add . git status - git commit -m ":memo: Auto generated docs for ${GITHUB_REF/refs\/tags\//}" + git commit -m ":memo: Auto generated docs for ${{ env.DOCS_VERSION }}" git push diff --git a/cmd/location.go b/cmd/location.go new file mode 100644 index 0000000..249bb93 --- /dev/null +++ b/cmd/location.go @@ -0,0 +1,117 @@ +package cmd + +import ( + "vf-admin/internal/cmdrun/location/add" + "vf-admin/internal/cmdrun/location/get" + "vf-admin/internal/cmdrun/location/list" + "vf-admin/internal/cmdrun/location/remove" + "vf-admin/internal/cmdrun/location/update" + + "github.com/MakeNowJust/heredoc" + "github.com/spf13/cobra" +) + +// Command: `vf-admin location` +var locationCmd = &cobra.Command{ + Use: "location", + Short: "Manage locations", +} + +// Command: `vf-admin location get ` +var locationGetCmd = &cobra.Command{ + Use: "get", + Short: "Retrieve a location with a specified id", + Example: heredoc.Doc(` + # Get the location with id 1. + $ vf-admin location get 1 + `), + Args: cobra.ExactArgs(1), + RunE: get.CmdRunE, +} + +// Command: `vf-admin location list` +var locationListCmd = &cobra.Command{ + Use: "list", + Short: "Retrieve a list of locations", + Args: cobra.ExactArgs(0), + Run: list.CmdRun, +} + +// Command: `vf-admin location add ` +var locationAddCmd = &cobra.Command{ + Use: "add", + Short: "Add a new location", + Example: heredoc.Doc(` + # Add a new active location with name "Guelph Hospital", postal code "N1E 4J4", website URL "http://www.gghorg.ca/", phone "(519) 822-5350", notes "Please call ahead to make an appointment.", tags "Guelph, Appointment", organization id 23 and address id 352. + $ vf-admin location add --active 1 --name "Guelph Hospital" --postcode "N1E4J4" --url "http://www.gghorg.ca" --phone "(519) 822-5350" --notes "Please call ahead to make an appointment." --tags "Guelph, Appointment" --organization 23 --address 352 + `), + Args: cobra.ExactArgs(0), + RunE: add.CmdRunE, +} + +// Command: `vf-admin location update ` +var locationUpdateCmd = &cobra.Command{ + Use: "update", + Short: "Update a location with a specified id", + Example: heredoc.Doc(` + # Add the location with id 15 to be active, have name "Guelph Hospital", postal code "N1E 4J4", website URL "http://www.gghorg.ca/", phone "(519) 822-5350", notes "Please call ahead to make an appointment.", tags "Guelph, Appointment", organization id 23 and address id 352. + $ vf-admin location update 15 --active 1 --name "Guelph Hospital" --postcode "N1E4J4" --url "http://www.gghorg.ca" --phone "(519) 822-5350" --notes "Please call ahead to make an appointment." --tags "Guelph, Appointment" --organization 23 --address 352 + `), + Args: cobra.ExactArgs(1), + RunE: update.CmdRunE, +} + +// Command: `vf-admin location remove ` +var locationRemoveCmd = &cobra.Command{ + Use: "remove", + Short: "Remove a location with a specified id", + Example: heredoc.Doc(` + # Remove the location with id 8. + $ vf-admin location remove 8 + `), + Args: cobra.ExactArgs(1), + RunE: remove.CmdRunE, +} + +func init() { + RootCmd.AddCommand(locationCmd) + + // Get command + locationCmd.AddCommand(locationGetCmd) + + // List command + locationCmd.AddCommand(locationListCmd) + + // Add command + locationAddCmd.Flags().String("name", "", "name of location") + _ = locationAddCmd.MarkFlagRequired("name") + locationAddCmd.Flags().Int("active", 1, "is this location active? 1 or 0") + _ = locationAddCmd.MarkFlagRequired("active") + locationAddCmd.Flags().String("postcode", "", "postal code of location") + locationAddCmd.Flags().String("phone", "", "phone number of location") + locationAddCmd.Flags().String("notes", "", "notes about location") + locationAddCmd.Flags().String("url", "", "website URL of location") + locationAddCmd.Flags().String("tags", "", "search tags of location") + locationAddCmd.Flags().Int("organization", 0, "id of organization running location") + locationAddCmd.Flags().Int("address", 0, "id of address of location") + + locationCmd.AddCommand(locationAddCmd) + + // // Update command + locationUpdateCmd.Flags().String("name", "", "name of location") + _ = locationUpdateCmd.MarkFlagRequired("name") + locationUpdateCmd.Flags().Int("active", 1, "is this location active? 1 or 0") + _ = locationUpdateCmd.MarkFlagRequired("active") + locationUpdateCmd.Flags().String("postcode", "", "postal code of location") + locationUpdateCmd.Flags().String("phone", "", "phone number of location") + locationUpdateCmd.Flags().String("notes", "", "notes about location") + locationUpdateCmd.Flags().String("url", "", "website URL of location") + locationUpdateCmd.Flags().String("tags", "", "search tags of location") + locationUpdateCmd.Flags().Int("organization", 0, "id of organization running location") + locationUpdateCmd.Flags().Int("address", 0, "id of address of location") + + locationCmd.AddCommand(locationUpdateCmd) + + // Remove command + locationCmd.AddCommand(locationRemoveCmd) +} diff --git a/internal/cmdrun/location/add/add.go b/internal/cmdrun/location/add/add.go new file mode 100644 index 0000000..dd26400 --- /dev/null +++ b/internal/cmdrun/location/add/add.go @@ -0,0 +1,111 @@ +package add + +import ( + "context" + "vf-admin/internal/api" + locationutils "vf-admin/internal/cmdrun/location" + "vf-admin/internal/utils" + + "github.com/fatih/color" + "github.com/spf13/cobra" +) + +// CmdRunE is what's executed when running `vf-admin location add` +func CmdRunE(cmd *cobra.Command, args []string) error { + // Retrieve the authentication key from configuration file + key, kErr := utils.GetKeyFromProfile(cmd) + if kErr != nil { + color.Red(kErr.Error()) + return nil + } + + // Create the API client using the authentication key for requests + client, cErr := utils.GetAPIClientFromKey(key) + if cErr != nil { + color.Red(cErr.Error()) + return nil + } + + flags := cmd.Flags() + active, _ := flags.GetInt("active") + name, _ := flags.GetString("name") + var postcode, phone, notes, url, tags *string + var org, address *int + if flags.Changed("postcode") { + t, _ := flags.GetString("postcode") + postcode = &t + } else { + postcode = nil + } + if flags.Changed("phone") { + t, _ := flags.GetString("phone") + phone = &t + } else { + phone = nil + } + if flags.Changed("notes") { + t, _ := flags.GetString("notes") + notes = &t + } else { + notes = nil + } + if flags.Changed("url") { + t, _ := flags.GetString("url") + url = &t + } else { + url = nil + } + if flags.Changed("tags") { + t, _ := flags.GetString("tags") + tags = &t + } else { + tags = nil + } + if flags.Changed("organization") { + t, _ := flags.GetInt("organization") + org = &t + } else { + org = nil + } + if flags.Changed("address") { + t, _ := flags.GetInt("address") + address = &t + } else { + address = nil + } + + body := api.CreateLocationApiV1LocationsPostJSONRequestBody{Active: active, Name: name, Postcode: postcode, Phone: phone, Notes: notes, Url: url, Tags: tags, Organization: org, Address: address} + + // Create spinner + spinner, sErr := utils.GetDefaultSpinnerForHTTPOp("add", "added", "location") + if sErr != nil { + color.Red(sErr.Error()) + return nil + } + _ = spinner.Start() + + res, rErr := client.CreateLocationApiV1LocationsPostWithResponse(context.Background(), body) + + if rErr != nil { + spinner.StopFailMessage(rErr.Error()) + _ = spinner.StopFail() + return nil + } + + if res.StatusCode() != 200 { + spinner.StopFailMessage(res.Status() + ": " + string(res.Body)) + _ = spinner.StopFail() + return nil + } + + _ = spinner.Stop() + + colNames := []string{"id", "name", "active", "postcode", "phone", "notes", "url", "tags", "org", "address", "created at"} + json := res.JSON200 + data := [][]string{ + locationutils.ConvertLocationJSONToTableRow(json), + } + utils.RenderDefaultTable(colNames, data) + + return nil +} diff --git a/internal/cmdrun/location/get/get.go b/internal/cmdrun/location/get/get.go new file mode 100644 index 0000000..eda5f1e --- /dev/null +++ b/internal/cmdrun/location/get/get.go @@ -0,0 +1,62 @@ +package get + +import ( + "context" + "errors" + "fmt" + "strconv" + locationutils "vf-admin/internal/cmdrun/location" + "vf-admin/internal/utils" + + "github.com/fatih/color" + "github.com/spf13/cobra" +) + +// CmdRunE is what's executed when running `vf-admin location get ` +func CmdRunE(cmd *cobra.Command, args []string) error { + id, aErr := strconv.Atoi(args[0]) + if aErr != nil { + return errors.New("expecting id as integer") + } + + // Create the API client + client, cErr := utils.GetAPIClient() + if cErr != nil { + color.Red(cErr.Error()) + return nil + } + + // Create spinner + spinner, sErr := utils.GetDefaultSpinnerForHTTPOp("get", "got", "location") + if sErr != nil { + color.Red(sErr.Error()) + return nil + } + _ = spinner.Start() + + res, rErr := client.RetrieveLocationByIdApiV1LocationsLocationIdGetWithResponse(context.Background(), id) + + if rErr != nil { + spinner.StopFailMessage(rErr.Error()) + _ = spinner.StopFail() + return nil + } + + if res.StatusCode() != 200 { + spinner.StopFailMessage(res.Status() + ": " + string(res.Body)) + _ = spinner.StopFail() + return nil + } + + _ = spinner.Stop() + + colNames := []string{"id", "name", "active", "postcode", "phone", "notes", "url", "tags", "org", "address", "created at"} + json := res.JSON200 + fmt.Print(json) + data := [][]string{ + locationutils.ConvertExpandedLocationJSONToTableRow(json), + } + utils.RenderDefaultTable(colNames, data) + + return nil +} diff --git a/internal/cmdrun/location/list/list.go b/internal/cmdrun/location/list/list.go new file mode 100644 index 0000000..5da3916 --- /dev/null +++ b/internal/cmdrun/location/list/list.go @@ -0,0 +1,50 @@ +package list + +import ( + "context" + locationutils "vf-admin/internal/cmdrun/location" + "vf-admin/internal/utils" + + "github.com/fatih/color" + "github.com/spf13/cobra" +) + +// CmdRun is what's executed when running `vf-admin location list` +func CmdRun(cmd *cobra.Command, args []string) { + // Create the API client + client, cErr := utils.GetAPIClient() + if cErr != nil { + color.Red(cErr.Error()) + } + + // Create spinner + spinner, sErr := utils.GetDefaultSpinnerForHTTPOp("list", "got", "locations") + if sErr != nil { + color.Red(sErr.Error()) + } + _ = spinner.Start() + + res, rErr := client.ListLocationsApiV1LocationsGetWithResponse(context.Background()) + + if rErr != nil { + spinner.StopFailMessage(rErr.Error()) + _ = spinner.StopFail() + } + + if res.StatusCode() != 200 { + spinner.StopFailMessage(res.Status() + ": " + string(res.Body)) + _ = spinner.StopFail() + } + + _ = spinner.Stop() + + colNames := []string{"id", "name", "active", "postcode", "phone", "notes", "url", "tags", "org", "address", "created at"} + + var data [][]string + for _, row := range *res.JSON200 { + data = append(data, locationutils.ConvertExpandedLocationJSONToTableRow(&row)) + } + + utils.RenderDefaultTable(colNames, data) + +} diff --git a/internal/cmdrun/location/locationutils.go b/internal/cmdrun/location/locationutils.go new file mode 100644 index 0000000..7041984 --- /dev/null +++ b/internal/cmdrun/location/locationutils.go @@ -0,0 +1,76 @@ +package locationutils + +import ( + "fmt" + "strconv" + "vf-admin/internal/api" + "vf-admin/internal/utils" +) + +// ConvertExpandedLocationJSONToTableRow returns a list of strings for the table row of an expanded location JSON response +func ConvertExpandedLocationJSONToTableRow(json *api.LocationExpandedResponse) []string { + data := []string{ + strconv.Itoa(json.Id), + json.Name, + strconv.FormatBool(json.Active != 0), + utils.CoalesceString(json.Postcode), + utils.CoalesceString(json.Phone), + utils.CoalesceString(json.Notes), + utils.CoalesceString(json.Url), + utils.CoalesceString(json.Tags), + } + + orgString := "" + if json.Organization != nil { + orgString = fmt.Sprintf("organization id: %d\n %s", json.Organization.Id, utils.CoalesceString(&json.Organization.ShortName)) + } + data = append(data, orgString) + + addrString := "" + if json.Address != nil { + addrString = fmt.Sprintf("address id: %d\n%s\n%s\n%s\n%s", + json.Address.Id, utils.CoalesceString(json.Address.Line1), + utils.CoalesceString(json.Address.City), + utils.CoalesceString(&json.Address.Province), + utils.CoalesceString(&json.Address.Postcode), + ) + } + + data = append(data, addrString) + + data = append(data, json.CreatedAt.String()) + + return data +} + +// ConvertLocationJSONToTableRow returns a list of strings for the table row of a location JSON response +func ConvertLocationJSONToTableRow(json *api.LocationResponse) []string { + data := []string{ + strconv.Itoa(json.Id), + json.Name, + strconv.FormatBool(json.Active != 0), + utils.CoalesceString(json.Postcode), + utils.CoalesceString(json.Phone), + utils.CoalesceString(json.Notes), + utils.CoalesceString(json.Url), + utils.CoalesceString(json.Tags), + } + + orgString := "" + if json.Organization != nil { + orgString = fmt.Sprintf("org id: %d", *json.Organization) + } + data = append(data, orgString) + + addrString := "" + + if json.Address != nil { + addrString = fmt.Sprintf("address id: %d", *json.Address) + } + + data = append(data, addrString) + + data = append(data, json.CreatedAt.String()) + + return data +} diff --git a/internal/cmdrun/location/remove/remove.go b/internal/cmdrun/location/remove/remove.go new file mode 100644 index 0000000..b76c017 --- /dev/null +++ b/internal/cmdrun/location/remove/remove.go @@ -0,0 +1,60 @@ +package remove + +import ( + "context" + "errors" + "fmt" + "strconv" + "vf-admin/internal/utils" + + "github.com/fatih/color" + "github.com/spf13/cobra" +) + +// CmdRunE is what's executed when running `vf-admin location remove ` +func CmdRunE(cmd *cobra.Command, args []string) error { + id, aErr := strconv.Atoi(args[0]) + if aErr != nil { + return errors.New("expecting id as integer") + } + + // Retrieve the authentication key from configuration file + key, kErr := utils.GetKeyFromProfile(cmd) + if kErr != nil { + color.Red(kErr.Error()) + return nil + } + + // Create the API client using the authentication key for requests + client, cErr := utils.GetAPIClientFromKey(key) + if cErr != nil { + color.Red(cErr.Error()) + return nil + } + + // Create spinner + spinner, sErr := utils.GetDefaultSpinnerForHTTPOp("remove", "removed", fmt.Sprintf("location %d", id)) + if sErr != nil { + color.Red(sErr.Error()) + return nil + } + _ = spinner.Start() + + res, rErr := client.DeleteLocationByIdApiV1LocationsLocationIdDeleteWithResponse(context.Background(), id) + + if rErr != nil { + spinner.StopFailMessage(rErr.Error()) + _ = spinner.StopFail() + return nil + } + + if res.StatusCode() != 204 { + spinner.StopFailMessage(res.Status() + ": " + string(res.Body)) + _ = spinner.StopFail() + return nil + } + + _ = spinner.Stop() + + return nil +} diff --git a/internal/cmdrun/location/update/update.go b/internal/cmdrun/location/update/update.go new file mode 100644 index 0000000..97c970f --- /dev/null +++ b/internal/cmdrun/location/update/update.go @@ -0,0 +1,119 @@ +package update + +import ( + "context" + "errors" + "strconv" + "vf-admin/internal/api" + locationutils "vf-admin/internal/cmdrun/location" + "vf-admin/internal/utils" + + "github.com/fatih/color" + "github.com/spf13/cobra" +) + +// CmdRunE is what's executed when running `vf-admin location update` +func CmdRunE(cmd *cobra.Command, args []string) error { + + id, aErr := strconv.Atoi(args[0]) + if aErr != nil { + return errors.New("expecting id as integer") + } + + // Retrieve the authentication key from configuration file + key, kErr := utils.GetKeyFromProfile(cmd) + if kErr != nil { + color.Red(kErr.Error()) + return nil + } + + // Create the API client using the authentication key for requests + client, cErr := utils.GetAPIClientFromKey(key) + if cErr != nil { + color.Red(cErr.Error()) + return nil + } + + flags := cmd.Flags() + active, _ := flags.GetInt("active") + name, _ := flags.GetString("name") + var postcode, phone, notes, url, tags *string + var org, address *int + if flags.Changed("postcode") { + t, _ := flags.GetString("postcode") + postcode = &t + } else { + postcode = nil + } + if flags.Changed("phone") { + t, _ := flags.GetString("phone") + phone = &t + } else { + phone = nil + } + if flags.Changed("notes") { + t, _ := flags.GetString("notes") + notes = &t + } else { + notes = nil + } + if flags.Changed("url") { + t, _ := flags.GetString("url") + url = &t + } else { + url = nil + } + if flags.Changed("tags") { + t, _ := flags.GetString("tags") + tags = &t + } else { + tags = nil + } + if flags.Changed("organization") { + t, _ := flags.GetInt("organization") + org = &t + } else { + org = nil + } + if flags.Changed("address") { + t, _ := flags.GetInt("address") + address = &t + } else { + address = nil + } + + body := api.UpdateLocationApiV1LocationsLocationIdPutJSONRequestBody{Active: active, Name: name, Postcode: postcode, Phone: phone, Notes: notes, Url: url, Tags: tags, Organization: org, Address: address} + + // Create spinner + spinner, sErr := utils.GetDefaultSpinnerForHTTPOp("update", "updated", "location") + if sErr != nil { + color.Red(sErr.Error()) + return nil + } + _ = spinner.Start() + + res, rErr := client.UpdateLocationApiV1LocationsLocationIdPutWithResponse(context.Background(), id, body) + + if rErr != nil { + spinner.StopFailMessage(rErr.Error()) + _ = spinner.StopFail() + return nil + } + + if res.StatusCode() != 200 { + spinner.StopFailMessage(res.Status() + ": " + string(res.Body)) + _ = spinner.StopFail() + return nil + } + + _ = spinner.Stop() + + colNames := []string{"id", "name", "active", "postcode", "phone", "notes", "url", "tags", "org", "address", "created at"} + json := res.JSON200 + data := [][]string{ + locationutils.ConvertLocationJSONToTableRow(json), + } + utils.RenderDefaultTable(colNames, data) + + return nil +} diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..2cc0dc3 --- /dev/null +++ b/test.txt @@ -0,0 +1,23 @@ +1 Active int `json:"active"` + Address *AddressResponse `json:"address,omitempty"` +2021-05-20 15:53:29.213 +0000 +0000 CreatedAt time.Time `json:"createdAt"` +1642 Id int `json:"id"` +Testing location Name string `json:"name"` + Notes *string `json:"notes,omitempty"` + Organization *OrganizationResponse `json:"organization,omitempty"` + Phone *string `json:"phone,omitempty"` + Postcode *string `json:"postcode,omitempty"` + Tags *string `json:"tags,omitempty"` + Url *string + + Active int `json:"active"` + Address *AddressResponse `json:"address,omitempty"` + CreatedAt time.Time `json:"createdAt"` + Id int `json:"id"` + Name string `json:"name"` + Notes *string `json:"notes,omitempty"` + Organization *OrganizationResponse `json:"organization,omitempty"` + Phone *string `json:"phone,omitempty"` + Postcode *string `json:"postcode,omitempty"` + Tags *string `json:"tags,omitempty"` + Url *string `json:"url,omitempty"` diff --git a/test_req.txt b/test_req.txt new file mode 100644 index 0000000..347b8dc --- /dev/null +++ b/test_req.txt @@ -0,0 +1,18 @@ +Using config file: /home/gary/.vf-admin.json +  [?25l . List requirements: Making request to server  [?25l .. List requirements: Making request to server  [?25l ... List requirements: Making request to server  [?25l .. List requirements: Making request to server  [?25h Successfully got requirements + + ID | NAME | DESCRIPTION | CREATED AT +-----+--------------------+--------------------------------+--------------------------------- + 1 | High-Risk | Highest- and High-Risk Health | 2021-05-02 03:50:10.143 +0000 + | | Conditions | +0000 + 2 | Medical Conditions | Organ Transplant Recipients | 2021-05-02 03:50:10.167 +0000 + | | and Individuals Receiving | +0000 + | | Active Cancer Treatment | + 3 | Healthcare Workers | Healthcare Workers and | 2021-05-02 03:50:10.17 +0000 + | | Community Providers | +0000 + 4 | HotSpot | 18+ in Specific Postal Codes | 2021-05-02 03:50:10.177 +0000 + | | | +0000 + 5 | Indigenous Adults | Indigenous Adults | 2021-05-02 03:50:10.18 +0000 + | | | +0000 + 6 | Caregivers | Caregivers | 2021-05-02 03:50:10.19 +0000 + | | | +0000 From c171c05525e95ad8f4b0d042159754ed1e49e796 Mon Sep 17 00:00:00 2001 From: gesarki Date: Fri, 21 May 2021 01:03:46 -0400 Subject: [PATCH 21/32] fix(loc): removed accidentally committed files --- test.txt | 23 ----------------------- test_req.txt | 18 ------------------ 2 files changed, 41 deletions(-) delete mode 100644 test.txt delete mode 100644 test_req.txt diff --git a/test.txt b/test.txt deleted file mode 100644 index 2cc0dc3..0000000 --- a/test.txt +++ /dev/null @@ -1,23 +0,0 @@ -1 Active int `json:"active"` - Address *AddressResponse `json:"address,omitempty"` -2021-05-20 15:53:29.213 +0000 +0000 CreatedAt time.Time `json:"createdAt"` -1642 Id int `json:"id"` -Testing location Name string `json:"name"` - Notes *string `json:"notes,omitempty"` - Organization *OrganizationResponse `json:"organization,omitempty"` - Phone *string `json:"phone,omitempty"` - Postcode *string `json:"postcode,omitempty"` - Tags *string `json:"tags,omitempty"` - Url *string - - Active int `json:"active"` - Address *AddressResponse `json:"address,omitempty"` - CreatedAt time.Time `json:"createdAt"` - Id int `json:"id"` - Name string `json:"name"` - Notes *string `json:"notes,omitempty"` - Organization *OrganizationResponse `json:"organization,omitempty"` - Phone *string `json:"phone,omitempty"` - Postcode *string `json:"postcode,omitempty"` - Tags *string `json:"tags,omitempty"` - Url *string `json:"url,omitempty"` diff --git a/test_req.txt b/test_req.txt deleted file mode 100644 index 347b8dc..0000000 --- a/test_req.txt +++ /dev/null @@ -1,18 +0,0 @@ -Using config file: /home/gary/.vf-admin.json -  [?25l . List requirements: Making request to server  [?25l .. List requirements: Making request to server  [?25l ... List requirements: Making request to server  [?25l .. List requirements: Making request to server  [?25h Successfully got requirements - - ID | NAME | DESCRIPTION | CREATED AT ------+--------------------+--------------------------------+--------------------------------- - 1 | High-Risk | Highest- and High-Risk Health | 2021-05-02 03:50:10.143 +0000 - | | Conditions | +0000 - 2 | Medical Conditions | Organ Transplant Recipients | 2021-05-02 03:50:10.167 +0000 - | | and Individuals Receiving | +0000 - | | Active Cancer Treatment | - 3 | Healthcare Workers | Healthcare Workers and | 2021-05-02 03:50:10.17 +0000 - | | Community Providers | +0000 - 4 | HotSpot | 18+ in Specific Postal Codes | 2021-05-02 03:50:10.177 +0000 - | | | +0000 - 5 | Indigenous Adults | Indigenous Adults | 2021-05-02 03:50:10.18 +0000 - | | | +0000 - 6 | Caregivers | Caregivers | 2021-05-02 03:50:10.19 +0000 - | | | +0000 From 689d42e85865d9cba67d2f8ac19e4a8e77c92343 Mon Sep 17 00:00:00 2001 From: gesarki Date: Fri, 21 May 2021 01:12:35 -0400 Subject: [PATCH 22/32] feat(loc): removed bad merged files --- docs/refs/heads/main/vf-admin.md | 18 -------- docs/refs/heads/main/vf-admin_configure.md | 44 ------------------- docs/refs/heads/main/vf-admin_organization.md | 25 ----------- .../heads/main/vf-admin_organization_add.md | 36 --------------- .../heads/main/vf-admin_organization_get.md | 32 -------------- .../heads/main/vf-admin_organization_list.md | 32 -------------- .../main/vf-admin_organization_remove.md | 32 -------------- .../main/vf-admin_organization_update.md | 36 --------------- docs/refs/heads/main/vf-admin_requirement.md | 25 ----------- .../heads/main/vf-admin_requirement_add.md | 34 -------------- .../heads/main/vf-admin_requirement_get.md | 32 -------------- .../heads/main/vf-admin_requirement_list.md | 24 ---------- .../heads/main/vf-admin_requirement_remove.md | 32 -------------- .../heads/main/vf-admin_requirement_update.md | 34 -------------- docs/refs/heads/main/vf-admin_version.md | 24 ---------- 15 files changed, 460 deletions(-) delete mode 100644 docs/refs/heads/main/vf-admin.md delete mode 100644 docs/refs/heads/main/vf-admin_configure.md delete mode 100644 docs/refs/heads/main/vf-admin_organization.md delete mode 100644 docs/refs/heads/main/vf-admin_organization_add.md delete mode 100644 docs/refs/heads/main/vf-admin_organization_get.md delete mode 100644 docs/refs/heads/main/vf-admin_organization_list.md delete mode 100644 docs/refs/heads/main/vf-admin_organization_remove.md delete mode 100644 docs/refs/heads/main/vf-admin_organization_update.md delete mode 100644 docs/refs/heads/main/vf-admin_requirement.md delete mode 100644 docs/refs/heads/main/vf-admin_requirement_add.md delete mode 100644 docs/refs/heads/main/vf-admin_requirement_get.md delete mode 100644 docs/refs/heads/main/vf-admin_requirement_list.md delete mode 100644 docs/refs/heads/main/vf-admin_requirement_remove.md delete mode 100644 docs/refs/heads/main/vf-admin_requirement_update.md delete mode 100644 docs/refs/heads/main/vf-admin_version.md diff --git a/docs/refs/heads/main/vf-admin.md b/docs/refs/heads/main/vf-admin.md deleted file mode 100644 index 4cd9b43..0000000 --- a/docs/refs/heads/main/vf-admin.md +++ /dev/null @@ -1,18 +0,0 @@ -## vf-admin - -vf-admin is a CLI to manage vaccine availabilities and other data for the Vaccine Hunters Finder tool. - -### Options - -``` - -h, --help help for vf-admin - --profile string specifies the named profile to use for this command (default "default") -``` - -### SEE ALSO - -* [vf-admin configure](vf-admin_configure.md) - Configure a named profile with credentials -* [vf-admin organization](vf-admin_organization.md) - Manage organizations -* [vf-admin requirement](vf-admin_requirement.md) - Manage requirements -* [vf-admin version](vf-admin_version.md) - Returns the current version of the CLI - diff --git a/docs/refs/heads/main/vf-admin_configure.md b/docs/refs/heads/main/vf-admin_configure.md deleted file mode 100644 index 1fde961..0000000 --- a/docs/refs/heads/main/vf-admin_configure.md +++ /dev/null @@ -1,44 +0,0 @@ -## vf-admin configure - -Configure a named profile with credentials - -### Synopsis - -Configure the default profile or simply create new named profiles with an authentication key. - -A named profile is a set of settings and credentials that you can apply to a vf-admin CLI command. - - -``` -vf-admin configure [flags] -``` - -### Examples - -``` -z -# set up authentication key for default profile -$ vf-admin configure --key 7260841f-b47a-4b5c-9830-585af07c4405 - -# set up authentication key for a custom profile -$ vf-admin configure --profile alvin --key 7260841f-b47a-4b5c-9830-585af07c4405 - -``` - -### Options - -``` - -h, --help help for configure - -k, --key string The authentication key for future requests. -``` - -### Options inherited from parent commands - -``` - --profile string specifies the named profile to use for this command (default "default") -``` - -### SEE ALSO - -* [vf-admin](vf-admin.md) - vf-admin is a CLI to manage vaccine availabilities and other data for the Vaccine Hunters Finder tool. - diff --git a/docs/refs/heads/main/vf-admin_organization.md b/docs/refs/heads/main/vf-admin_organization.md deleted file mode 100644 index 58eabd6..0000000 --- a/docs/refs/heads/main/vf-admin_organization.md +++ /dev/null @@ -1,25 +0,0 @@ -## vf-admin organization - -Manage organizations - -### Options - -``` - -h, --help help for organization -``` - -### Options inherited from parent commands - -``` - --profile string specifies the named profile to use for this command (default "default") -``` - -### SEE ALSO - -* [vf-admin](vf-admin.md) - vf-admin is a CLI to manage vaccine availabilities and other data for the Vaccine Hunters Finder tool. -* [vf-admin organization add](vf-admin_organization_add.md) - Add a new organization -* [vf-admin organization get](vf-admin_organization_get.md) - Retrieve an organization with a specified id -* [vf-admin organization list](vf-admin_organization_list.md) - Retrieve a list of organizations -* [vf-admin organization remove](vf-admin_organization_remove.md) - Remove an organization with a specified id -* [vf-admin organization update](vf-admin_organization_update.md) - Update an organization with a specified id - diff --git a/docs/refs/heads/main/vf-admin_organization_add.md b/docs/refs/heads/main/vf-admin_organization_add.md deleted file mode 100644 index 8833ed1..0000000 --- a/docs/refs/heads/main/vf-admin_organization_add.md +++ /dev/null @@ -1,36 +0,0 @@ -## vf-admin organization add - -Add a new organization - -``` -vf-admin organization add [flags] -``` - -### Examples - -``` -# Add a new organization with short name "WHO", full name "World Health Organization", description "The World Health Organization is a specialized agency of the United Nations responsible for international public health." and url "https://www.who.int/" -$ vf-admin organization add --shortName WHO --fullName "World Health Organization" --description "The World Health Organization is a specialized agency of the United Nations responsible for international public health." --url "https://www.who.int/" - -``` - -### Options - -``` - --description string description of organization - --fullName string full name of the organization - -h, --help help for add - --shortName string short name of the organization - --url string url of organization -``` - -### Options inherited from parent commands - -``` - --profile string specifies the named profile to use for this command (default "default") -``` - -### SEE ALSO - -* [vf-admin organization](vf-admin_organization.md) - Manage organizations - diff --git a/docs/refs/heads/main/vf-admin_organization_get.md b/docs/refs/heads/main/vf-admin_organization_get.md deleted file mode 100644 index a2c5546..0000000 --- a/docs/refs/heads/main/vf-admin_organization_get.md +++ /dev/null @@ -1,32 +0,0 @@ -## vf-admin organization get - -Retrieve an organization with a specified id - -``` -vf-admin organization get [flags] -``` - -### Examples - -``` -# Get the organization with id 1. -$ vf-admin organization get 1 - -``` - -### Options - -``` - -h, --help help for get -``` - -### Options inherited from parent commands - -``` - --profile string specifies the named profile to use for this command (default "default") -``` - -### SEE ALSO - -* [vf-admin organization](vf-admin_organization.md) - Manage organizations - diff --git a/docs/refs/heads/main/vf-admin_organization_list.md b/docs/refs/heads/main/vf-admin_organization_list.md deleted file mode 100644 index 0fd3396..0000000 --- a/docs/refs/heads/main/vf-admin_organization_list.md +++ /dev/null @@ -1,32 +0,0 @@ -## vf-admin organization list - -Retrieve a list of organizations - -``` -vf-admin organization list [flags] -``` - -### Examples - -``` -# List the organizations. -$ vf-admin organization list - -``` - -### Options - -``` - -h, --help help for list -``` - -### Options inherited from parent commands - -``` - --profile string specifies the named profile to use for this command (default "default") -``` - -### SEE ALSO - -* [vf-admin organization](vf-admin_organization.md) - Manage organizations - diff --git a/docs/refs/heads/main/vf-admin_organization_remove.md b/docs/refs/heads/main/vf-admin_organization_remove.md deleted file mode 100644 index 4117f8e..0000000 --- a/docs/refs/heads/main/vf-admin_organization_remove.md +++ /dev/null @@ -1,32 +0,0 @@ -## vf-admin organization remove - -Remove an organization with a specified id - -``` -vf-admin organization remove [flags] -``` - -### Examples - -``` -# Remove the organization with id 20. -$ vf-admin organization remove 20 - -``` - -### Options - -``` - -h, --help help for remove -``` - -### Options inherited from parent commands - -``` - --profile string specifies the named profile to use for this command (default "default") -``` - -### SEE ALSO - -* [vf-admin organization](vf-admin_organization.md) - Manage organizations - diff --git a/docs/refs/heads/main/vf-admin_organization_update.md b/docs/refs/heads/main/vf-admin_organization_update.md deleted file mode 100644 index 06af939..0000000 --- a/docs/refs/heads/main/vf-admin_organization_update.md +++ /dev/null @@ -1,36 +0,0 @@ -## vf-admin organization update - -Update an organization with a specified id - -``` -vf-admin organization update [flags] -``` - -### Examples - -``` -# Update the organization with id 20 to have short name "WHO", full name "World Health Organization", description "The World Health Organization is a specialized agency of the United Nations responsible for international public health." and url "https://www.who.int/" -$ vf-admin organization update 20 --shortName WHO --fullName "World Health Organization" --description "The World Health Organization is a specialized agency of the United Nations responsible for international public health." --url "https://www.who.int/" - -``` - -### Options - -``` - --description string description of organization - --fullName string full name of the organization - -h, --help help for update - --shortName string short name of the organization - --url string url of organization -``` - -### Options inherited from parent commands - -``` - --profile string specifies the named profile to use for this command (default "default") -``` - -### SEE ALSO - -* [vf-admin organization](vf-admin_organization.md) - Manage organizations - diff --git a/docs/refs/heads/main/vf-admin_requirement.md b/docs/refs/heads/main/vf-admin_requirement.md deleted file mode 100644 index 86a8909..0000000 --- a/docs/refs/heads/main/vf-admin_requirement.md +++ /dev/null @@ -1,25 +0,0 @@ -## vf-admin requirement - -Manage requirements - -### Options - -``` - -h, --help help for requirement -``` - -### Options inherited from parent commands - -``` - --profile string specifies the named profile to use for this command (default "default") -``` - -### SEE ALSO - -* [vf-admin](vf-admin.md) - vf-admin is a CLI to manage vaccine availabilities and other data for the Vaccine Hunters Finder tool. -* [vf-admin requirement add](vf-admin_requirement_add.md) - Add a new requirement -* [vf-admin requirement get](vf-admin_requirement_get.md) - Retrieve a requirement with a specified id -* [vf-admin requirement list](vf-admin_requirement_list.md) - Retrieve a list of requirements -* [vf-admin requirement remove](vf-admin_requirement_remove.md) - Remove a requirement with a specified id -* [vf-admin requirement update](vf-admin_requirement_update.md) - Update a requirement with a specified id - diff --git a/docs/refs/heads/main/vf-admin_requirement_add.md b/docs/refs/heads/main/vf-admin_requirement_add.md deleted file mode 100644 index 2f89a08..0000000 --- a/docs/refs/heads/main/vf-admin_requirement_add.md +++ /dev/null @@ -1,34 +0,0 @@ -## vf-admin requirement add - -Add a new requirement - -``` -vf-admin requirement add [flags] -``` - -### Examples - -``` -# Add a new requirement with name "18+" and description "Any individual older than 18 years of age.". -$ vf-admin requirement add --name "18+" --description "Any individual older than 18 years of age." - -``` - -### Options - -``` - --description string description of requirement - -h, --help help for add - --name string name of requirement -``` - -### Options inherited from parent commands - -``` - --profile string specifies the named profile to use for this command (default "default") -``` - -### SEE ALSO - -* [vf-admin requirement](vf-admin_requirement.md) - Manage requirements - diff --git a/docs/refs/heads/main/vf-admin_requirement_get.md b/docs/refs/heads/main/vf-admin_requirement_get.md deleted file mode 100644 index ee09af9..0000000 --- a/docs/refs/heads/main/vf-admin_requirement_get.md +++ /dev/null @@ -1,32 +0,0 @@ -## vf-admin requirement get - -Retrieve a requirement with a specified id - -``` -vf-admin requirement get [flags] -``` - -### Examples - -``` -# Get the requirement with id 1. -$ vf-admin requirement get 1 - -``` - -### Options - -``` - -h, --help help for get -``` - -### Options inherited from parent commands - -``` - --profile string specifies the named profile to use for this command (default "default") -``` - -### SEE ALSO - -* [vf-admin requirement](vf-admin_requirement.md) - Manage requirements - diff --git a/docs/refs/heads/main/vf-admin_requirement_list.md b/docs/refs/heads/main/vf-admin_requirement_list.md deleted file mode 100644 index dbc97e4..0000000 --- a/docs/refs/heads/main/vf-admin_requirement_list.md +++ /dev/null @@ -1,24 +0,0 @@ -## vf-admin requirement list - -Retrieve a list of requirements - -``` -vf-admin requirement list [flags] -``` - -### Options - -``` - -h, --help help for list -``` - -### Options inherited from parent commands - -``` - --profile string specifies the named profile to use for this command (default "default") -``` - -### SEE ALSO - -* [vf-admin requirement](vf-admin_requirement.md) - Manage requirements - diff --git a/docs/refs/heads/main/vf-admin_requirement_remove.md b/docs/refs/heads/main/vf-admin_requirement_remove.md deleted file mode 100644 index 129d4ed..0000000 --- a/docs/refs/heads/main/vf-admin_requirement_remove.md +++ /dev/null @@ -1,32 +0,0 @@ -## vf-admin requirement remove - -Remove a requirement with a specified id - -``` -vf-admin requirement remove [flags] -``` - -### Examples - -``` -# Remove the requirement with id 8. -$ vf-admin requirement remove 8 - -``` - -### Options - -``` - -h, --help help for remove -``` - -### Options inherited from parent commands - -``` - --profile string specifies the named profile to use for this command (default "default") -``` - -### SEE ALSO - -* [vf-admin requirement](vf-admin_requirement.md) - Manage requirements - diff --git a/docs/refs/heads/main/vf-admin_requirement_update.md b/docs/refs/heads/main/vf-admin_requirement_update.md deleted file mode 100644 index 2989d7a..0000000 --- a/docs/refs/heads/main/vf-admin_requirement_update.md +++ /dev/null @@ -1,34 +0,0 @@ -## vf-admin requirement update - -Update a requirement with a specified id - -``` -vf-admin requirement update [flags] -``` - -### Examples - -``` -# Update the requirement with id 8 to have name "High-Risk" and description "Highest- and High-Risk Health Conditions.". -$ vf-admin requirement update 8 --name "High-Risk" --description "Highest- and High-Risk Health Conditions." - -``` - -### Options - -``` - --description string description of requirement - -h, --help help for update - --name string name of requirement -``` - -### Options inherited from parent commands - -``` - --profile string specifies the named profile to use for this command (default "default") -``` - -### SEE ALSO - -* [vf-admin requirement](vf-admin_requirement.md) - Manage requirements - diff --git a/docs/refs/heads/main/vf-admin_version.md b/docs/refs/heads/main/vf-admin_version.md deleted file mode 100644 index cfdecc7..0000000 --- a/docs/refs/heads/main/vf-admin_version.md +++ /dev/null @@ -1,24 +0,0 @@ -## vf-admin version - -Returns the current version of the CLI - -``` -vf-admin version [flags] -``` - -### Options - -``` - -h, --help help for version -``` - -### Options inherited from parent commands - -``` - --profile string specifies the named profile to use for this command (default "default") -``` - -### SEE ALSO - -* [vf-admin](vf-admin.md) - vf-admin is a CLI to manage vaccine availabilities and other data for the Vaccine Hunters Finder tool. - From 1d0ceb9a14e3c82c6390e663dec49805170be8e0 Mon Sep 17 00:00:00 2001 From: gesarki Date: Fri, 21 May 2021 01:25:16 -0400 Subject: [PATCH 23/32] feat(loc): fixed spacing in org column --- internal/cmdrun/location/locationutils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cmdrun/location/locationutils.go b/internal/cmdrun/location/locationutils.go index 7041984..c347ccc 100644 --- a/internal/cmdrun/location/locationutils.go +++ b/internal/cmdrun/location/locationutils.go @@ -22,7 +22,7 @@ func ConvertExpandedLocationJSONToTableRow(json *api.LocationExpandedResponse) [ orgString := "" if json.Organization != nil { - orgString = fmt.Sprintf("organization id: %d\n %s", json.Organization.Id, utils.CoalesceString(&json.Organization.ShortName)) + orgString = fmt.Sprintf("organization id: %d\n%s", json.Organization.Id, utils.CoalesceString(&json.Organization.ShortName)) } data = append(data, orgString) From d9915371de91fc69bfaaf5bc486ab83bae724972 Mon Sep 17 00:00:00 2001 From: gesarki Date: Fri, 21 May 2021 10:09:56 -0400 Subject: [PATCH 24/32] feat(loc): fixed typo in command description --- cmd/location.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/location.go b/cmd/location.go index 249bb93..76e0cbb 100644 --- a/cmd/location.go +++ b/cmd/location.go @@ -54,7 +54,7 @@ var locationUpdateCmd = &cobra.Command{ Use: "update", Short: "Update a location with a specified id", Example: heredoc.Doc(` - # Add the location with id 15 to be active, have name "Guelph Hospital", postal code "N1E 4J4", website URL "http://www.gghorg.ca/", phone "(519) 822-5350", notes "Please call ahead to make an appointment.", tags "Guelph, Appointment", organization id 23 and address id 352. + # Update the location with id 15 to be active, have name "Guelph Hospital", postal code "N1E 4J4", website URL "http://www.gghorg.ca/", phone "(519) 822-5350", notes "Please call ahead to make an appointment.", tags "Guelph, Appointment", organization id 23 and address id 352. $ vf-admin location update 15 --active 1 --name "Guelph Hospital" --postcode "N1E4J4" --url "http://www.gghorg.ca" --phone "(519) 822-5350" --notes "Please call ahead to make an appointment." --tags "Guelph, Appointment" --organization 23 --address 352 `), Args: cobra.ExactArgs(1), From baa83f7af6e651057cb6988e010aac755b3d840c Mon Sep 17 00:00:00 2001 From: Alvin Tang Date: Fri, 21 May 2021 14:26:18 -0400 Subject: [PATCH 25/32] feat(loc): Remove print json when getting location. --- internal/cmdrun/location/get/get.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/cmdrun/location/get/get.go b/internal/cmdrun/location/get/get.go index eda5f1e..04ccf1b 100644 --- a/internal/cmdrun/location/get/get.go +++ b/internal/cmdrun/location/get/get.go @@ -3,7 +3,6 @@ package get import ( "context" "errors" - "fmt" "strconv" locationutils "vf-admin/internal/cmdrun/location" "vf-admin/internal/utils" @@ -52,7 +51,6 @@ func CmdRunE(cmd *cobra.Command, args []string) error { colNames := []string{"id", "name", "active", "postcode", "phone", "notes", "url", "tags", "org", "address", "created at"} json := res.JSON200 - fmt.Print(json) data := [][]string{ locationutils.ConvertExpandedLocationJSONToTableRow(json), } From 24b81cdfa1ba2e0c3142a9a7db8cd9fdf8d789fe Mon Sep 17 00:00:00 2001 From: github-actions Date: Fri, 21 May 2021 18:31:37 +0000 Subject: [PATCH 26/32] :memo: Auto generated docs in `docs/source`. --- docs/source/vf-admin.md | 1 + docs/source/vf-admin_location.md | 25 +++++++++++++++ docs/source/vf-admin_location_add.md | 41 +++++++++++++++++++++++++ docs/source/vf-admin_location_get.md | 32 +++++++++++++++++++ docs/source/vf-admin_location_list.md | 24 +++++++++++++++ docs/source/vf-admin_location_remove.md | 32 +++++++++++++++++++ docs/source/vf-admin_location_update.md | 41 +++++++++++++++++++++++++ 7 files changed, 196 insertions(+) create mode 100644 docs/source/vf-admin_location.md create mode 100644 docs/source/vf-admin_location_add.md create mode 100644 docs/source/vf-admin_location_get.md create mode 100644 docs/source/vf-admin_location_list.md create mode 100644 docs/source/vf-admin_location_remove.md create mode 100644 docs/source/vf-admin_location_update.md diff --git a/docs/source/vf-admin.md b/docs/source/vf-admin.md index 6054920..29763ce 100644 --- a/docs/source/vf-admin.md +++ b/docs/source/vf-admin.md @@ -13,6 +13,7 @@ vf-admin is a CLI to manage vaccine availabilities and other data for the Vaccin * [vf-admin address](vf-admin_address.md) - Manage addresss * [vf-admin configure](vf-admin_configure.md) - Configure a named profile with credentials +* [vf-admin location](vf-admin_location.md) - Manage locations * [vf-admin organization](vf-admin_organization.md) - Manage organizations * [vf-admin requirement](vf-admin_requirement.md) - Manage requirements * [vf-admin va](vf-admin_va.md) - Manage vaccine availabilities diff --git a/docs/source/vf-admin_location.md b/docs/source/vf-admin_location.md new file mode 100644 index 0000000..277273c --- /dev/null +++ b/docs/source/vf-admin_location.md @@ -0,0 +1,25 @@ +## vf-admin location + +Manage locations + +### Options + +``` + -h, --help help for location +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin](vf-admin.md) - vf-admin is a CLI to manage vaccine availabilities and other data for the Vaccine Hunters Finder tool. +* [vf-admin location add](vf-admin_location_add.md) - Add a new location +* [vf-admin location get](vf-admin_location_get.md) - Retrieve a location with a specified id +* [vf-admin location list](vf-admin_location_list.md) - Retrieve a list of locations +* [vf-admin location remove](vf-admin_location_remove.md) - Remove a location with a specified id +* [vf-admin location update](vf-admin_location_update.md) - Update a location with a specified id + diff --git a/docs/source/vf-admin_location_add.md b/docs/source/vf-admin_location_add.md new file mode 100644 index 0000000..0efdc23 --- /dev/null +++ b/docs/source/vf-admin_location_add.md @@ -0,0 +1,41 @@ +## vf-admin location add + +Add a new location + +``` +vf-admin location add [flags] +``` + +### Examples + +``` +# Add a new active location with name "Guelph Hospital", postal code "N1E 4J4", website URL "http://www.gghorg.ca/", phone "(519) 822-5350", notes "Please call ahead to make an appointment.", tags "Guelph, Appointment", organization id 23 and address id 352. +$ vf-admin location add --active 1 --name "Guelph Hospital" --postcode "N1E4J4" --url "http://www.gghorg.ca" --phone "(519) 822-5350" --notes "Please call ahead to make an appointment." --tags "Guelph, Appointment" --organization 23 --address 352 + +``` + +### Options + +``` + --active int is this location active? 1 or 0 (default 1) + --address int id of address of location + -h, --help help for add + --name string name of location + --notes string notes about location + --organization int id of organization running location + --phone string phone number of location + --postcode string postal code of location + --tags string search tags of location + --url string website URL of location +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin location](vf-admin_location.md) - Manage locations + diff --git a/docs/source/vf-admin_location_get.md b/docs/source/vf-admin_location_get.md new file mode 100644 index 0000000..6068f48 --- /dev/null +++ b/docs/source/vf-admin_location_get.md @@ -0,0 +1,32 @@ +## vf-admin location get + +Retrieve a location with a specified id + +``` +vf-admin location get [flags] +``` + +### Examples + +``` +# Get the location with id 1. +$ vf-admin location get 1 + +``` + +### Options + +``` + -h, --help help for get +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin location](vf-admin_location.md) - Manage locations + diff --git a/docs/source/vf-admin_location_list.md b/docs/source/vf-admin_location_list.md new file mode 100644 index 0000000..df83645 --- /dev/null +++ b/docs/source/vf-admin_location_list.md @@ -0,0 +1,24 @@ +## vf-admin location list + +Retrieve a list of locations + +``` +vf-admin location list [flags] +``` + +### Options + +``` + -h, --help help for list +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin location](vf-admin_location.md) - Manage locations + diff --git a/docs/source/vf-admin_location_remove.md b/docs/source/vf-admin_location_remove.md new file mode 100644 index 0000000..fad141e --- /dev/null +++ b/docs/source/vf-admin_location_remove.md @@ -0,0 +1,32 @@ +## vf-admin location remove + +Remove a location with a specified id + +``` +vf-admin location remove [flags] +``` + +### Examples + +``` +# Remove the location with id 8. +$ vf-admin location remove 8 + +``` + +### Options + +``` + -h, --help help for remove +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin location](vf-admin_location.md) - Manage locations + diff --git a/docs/source/vf-admin_location_update.md b/docs/source/vf-admin_location_update.md new file mode 100644 index 0000000..0d4d2e3 --- /dev/null +++ b/docs/source/vf-admin_location_update.md @@ -0,0 +1,41 @@ +## vf-admin location update + +Update a location with a specified id + +``` +vf-admin location update [flags] +``` + +### Examples + +``` +# Update the location with id 15 to be active, have name "Guelph Hospital", postal code "N1E 4J4", website URL "http://www.gghorg.ca/", phone "(519) 822-5350", notes "Please call ahead to make an appointment.", tags "Guelph, Appointment", organization id 23 and address id 352. +$ vf-admin location update 15 --active 1 --name "Guelph Hospital" --postcode "N1E4J4" --url "http://www.gghorg.ca" --phone "(519) 822-5350" --notes "Please call ahead to make an appointment." --tags "Guelph, Appointment" --organization 23 --address 352 + +``` + +### Options + +``` + --active int is this location active? 1 or 0 (default 1) + --address int id of address of location + -h, --help help for update + --name string name of location + --notes string notes about location + --organization int id of organization running location + --phone string phone number of location + --postcode string postal code of location + --tags string search tags of location + --url string website URL of location +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin location](vf-admin_location.md) - Manage locations + From 6cf7125b5e438a0084df0ac432b27451d99881c3 Mon Sep 17 00:00:00 2001 From: Alvin Tang Date: Fri, 21 May 2021 15:10:37 -0400 Subject: [PATCH 27/32] docs: Update issue templates --- .github/ISSUE_TEMPLATE/bug.md | 35 +++++++++++++++++++++ .github/ISSUE_TEMPLATE/bug_report.md | 38 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature-request.md | 25 +++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 25 +++++++++++++++ 4 files changed, 123 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug.md create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature-request.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 0000000..d4760cc --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,35 @@ +--- +name: Bug +about: Report a bug +title: 'Bug: [Short description]' +labels: bug +assignees: alvintangz + +--- + +## Prerequisites + +* [ ] I searched to see if the issue already exists. +* [ ] Are you running the latest version? + +## Description + +[Description of the bug] + +## Steps to Reproduce + +1. [First Step] +2. [Second Step] +3. [and so on...] + +## Expected behaviour + +[What you expected to happen] + +## Actual behaviour + +[What actually happened] + +## Screenshots + +[If applicable, add screenshots to help explain your problem] diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..dd84ea7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md new file mode 100644 index 0000000..b08f480 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.md @@ -0,0 +1,25 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: 'Feature: [Short description]' +labels: enhancement +assignees: alvintangz + +--- + +## Prerequisites + +* [ ] I searched to see if the issue already exists. +* [ ] Are you running the latest version? + +## Description of the problem + +[Description of the problem] + +## Potential Solutions + +[Add potential solutions here] + +## Screenshots + +[If applicable, add screenshots to help explain your problem] diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..b08f480 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,25 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: 'Feature: [Short description]' +labels: enhancement +assignees: alvintangz + +--- + +## Prerequisites + +* [ ] I searched to see if the issue already exists. +* [ ] Are you running the latest version? + +## Description of the problem + +[Description of the problem] + +## Potential Solutions + +[Add potential solutions here] + +## Screenshots + +[If applicable, add screenshots to help explain your problem] From 194e9aaf1a3e4c6e31fa1bd8435e659646cd35dd Mon Sep 17 00:00:00 2001 From: Alvin Tang Date: Fri, 21 May 2021 15:12:22 -0400 Subject: [PATCH 28/32] docs: Remove duplicate issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 38 ----------------------- .github/ISSUE_TEMPLATE/feature_request.md | 25 --------------- 2 files changed, 63 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index dd84ea7..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: '' -assignees: '' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] - -**Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index b08f480..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: 'Feature: [Short description]' -labels: enhancement -assignees: alvintangz - ---- - -## Prerequisites - -* [ ] I searched to see if the issue already exists. -* [ ] Are you running the latest version? - -## Description of the problem - -[Description of the problem] - -## Potential Solutions - -[Add potential solutions here] - -## Screenshots - -[If applicable, add screenshots to help explain your problem] From 470228be334e6cfdef06b4521771aacf7a8ff3f5 Mon Sep 17 00:00:00 2001 From: Eric St-Georges Date: Fri, 21 May 2021 15:15:05 -0400 Subject: [PATCH 29/32] feat(va): Added vaccine availability commands --- cmd/va.go | 67 ++++++++++++++++-- internal/cmdrun/va/add/add.go | 101 +++++++++++++++++++++++++++ internal/cmdrun/va/get/get.go | 77 +++++++++++++++++++++ internal/cmdrun/va/list/list.go | 96 ++++++++++++++++++++++++++ internal/cmdrun/va/remove/remove.go | 55 +++++++++++++++ internal/cmdrun/va/update/update.go | 103 ++++++++++++++++++++++++++++ internal/utils/string.go | 12 ++++ 7 files changed, 506 insertions(+), 5 deletions(-) create mode 100644 internal/cmdrun/va/add/add.go create mode 100644 internal/cmdrun/va/get/get.go create mode 100644 internal/cmdrun/va/list/list.go create mode 100644 internal/cmdrun/va/remove/remove.go create mode 100644 internal/cmdrun/va/update/update.go diff --git a/cmd/va.go b/cmd/va.go index 8977ff7..c6a5602 100644 --- a/cmd/va.go +++ b/cmd/va.go @@ -1,6 +1,13 @@ package cmd import ( + "vf-admin/internal/cmdrun/va/add" + "vf-admin/internal/cmdrun/va/get" + "vf-admin/internal/cmdrun/va/list" + "vf-admin/internal/cmdrun/va/remove" + "vf-admin/internal/cmdrun/va/update" + + "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" ) @@ -14,35 +21,60 @@ var vaCmd = &cobra.Command{ var vaGetCmd = &cobra.Command{ Use: "get", Short: "Retrieve a vaccine availability with a specified id", - Args: cobra.ExactArgs(1), + Example: heredoc.Doc(` + # Get the vaccine availability with id 014cc133-484f-4320-be3b-444e758b64a7 + $ vf-admin va get 014cc133-484f-4320-be3b-444e758b64a7 + `), + Args: cobra.ExactArgs(1), + RunE: get.CmdRunE, } // Command: `vf-admin va list` var vaListCmd = &cobra.Command{ Use: "list", Short: "Retrieve a list of vaccine availabilities within the vicinity of a postal code", - Args: cobra.ExactArgs(0), + Example: heredoc.Doc(` + # List the vaccine availabilities within the vicinity of a postal code. + $ vf-admin va list --postcode K1A + `), + Args: cobra.ExactArgs(0), + RunE: list.CmdRunE, } // Command: `vf-admin va add` var vaAddCmd = &cobra.Command{ Use: "add", Short: "Add a new vaccine availability", - Args: cobra.ExactArgs(0), + Example: heredoc.Doc(` + # Add new vaccine availability on 2021-05-25 with 3 available input type 1 location 1651 and tags vhc + $ vf-admin va add --date "2021-05-25" --numberavailable 3 --inputtype 1 --location 1651 --tags vhc + `), + Args: cobra.ExactArgs(0), + RunE: add.CmdRunE, } // Command: `vf-admin va update ` var vaUpdateCmd = &cobra.Command{ Use: "update", Short: "Update a vaccine availability with a specified id", - Args: cobra.ExactArgs(1), + Example: heredoc.Doc(` + # Update vaccine availability id 7d7488e4-cc26-434d-85c4-b7df2f7e3171to be on 2021-05-25 with 3 available input type 1 location 1651 and tags vhc + $ vf-admin va update 7d7488e4-cc26-434d-85c4-b7df2f7e3171 --date "2021-05-25" --numberavailable 3 --inputtype 1 --location 1651 --tags vhc + `), + Args: cobra.ExactArgs(1), + RunE: update.CmdRunE, } // Command: `vf-admin va remove ` var vaRemoveCmd = &cobra.Command{ Use: "remove", Short: "Remove a vaccine availability with a specified id", - Args: cobra.ExactArgs(1), + Example: heredoc.Doc(` + # Remove vaccine availability id 7d7488e4-cc26-434d-85c4-b7df2f7e3171 + $ vf-admin va remove 7d7488e4-cc26-434d-85c4-b7df2f7e3171 + `), + Args: cobra.ExactArgs(1), + RunE: remove.CmdRunE, } func init() { @@ -52,12 +84,37 @@ func init() { vaCmd.AddCommand(vaGetCmd) // List command + vaListCmd.Flags().String("postcode", "", "postal code to search around") + _ = vaListCmd.MarkFlagRequired("postcode") + vaListCmd.Flags().String("mindate", "", "minimum date for availability (YYYY-MM-DD)") vaCmd.AddCommand(vaListCmd) // Add command + vaAddCmd.Flags().String("date", "", "date for availability (YYYY-MM-DD)") + _ = vaAddCmd.MarkFlagRequired("date") + vaAddCmd.Flags().Int("location", 0, "id of the location") + _ = vaAddCmd.MarkFlagRequired("location") + vaAddCmd.Flags().Int("inputtype", 0, "input type") + _ = vaAddCmd.MarkFlagRequired("inputtype") + vaAddCmd.Flags().Int("numberavailable", 0, "number of vaccines available") + _ = vaAddCmd.MarkFlagRequired("numberavailable") + vaAddCmd.Flags().Int("numbertotal", 0, "total number of vaccines") + vaAddCmd.Flags().Int("vaccine", 0, "id of the vaccine") + vaAddCmd.Flags().String("tags", "", "tags") vaCmd.AddCommand(vaAddCmd) // Update command + vaUpdateCmd.Flags().String("date", "", "date for availability (YYYY-MM-DD)") + _ = vaUpdateCmd.MarkFlagRequired("date") + vaUpdateCmd.Flags().Int("location", 0, "id of the location") + _ = vaUpdateCmd.MarkFlagRequired("location") + vaUpdateCmd.Flags().Int("inputtype", 0, "input type") + _ = vaUpdateCmd.MarkFlagRequired("inputtype") + vaUpdateCmd.Flags().Int("numberavailable", 0, "number of vaccines available") + _ = vaUpdateCmd.MarkFlagRequired("numberavailable") + vaUpdateCmd.Flags().Int("numbertotal", 0, "total number of vaccines") + vaUpdateCmd.Flags().Int("vaccine", 0, "id of the vaccine") + vaUpdateCmd.Flags().String("tags", "", "tags") vaCmd.AddCommand(vaUpdateCmd) // Remove command diff --git a/internal/cmdrun/va/add/add.go b/internal/cmdrun/va/add/add.go new file mode 100644 index 0000000..e1565f2 --- /dev/null +++ b/internal/cmdrun/va/add/add.go @@ -0,0 +1,101 @@ +package add + +import ( + "context" + "strconv" + "time" + "vf-admin/internal/api" + "vf-admin/internal/utils" + + "github.com/fatih/color" + "github.com/spf13/cobra" +) + +// CmdRunE is what's executed when running `vf-admin va add` +func CmdRunE(cmd *cobra.Command, args []string) error { + // Retrieve the authentication key from configuration file + key, kErr := utils.GetKeyFromProfile(cmd) + if kErr != nil { + color.Red(kErr.Error()) + return nil + } + + // Create the API client using the authentication key for requests + client, cErr := utils.GetAPIClientFromKey(key) + if cErr != nil { + color.Red(cErr.Error()) + return nil + } + + flags := cmd.Flags() + t, _ := flags.GetString("date") + date, tErr := time.Parse("2006-01-02", t) + if tErr != nil { + color.Red(tErr.Error()) + return nil + } + + location, _ := flags.GetInt("location") + inputTypeInt, _ := flags.GetInt("inputtype") + inputType := api.InputTypeEnum(inputTypeInt) + numberAvailable, _ := flags.GetInt("numberavailable") + + var numberTotal, vaccine *int + var tags *string + + if flags.Changed("numberTotal") { + t, _ := flags.GetInt("numberTotal") + numberTotal = &t + } else { + numberTotal = nil + } + if flags.Changed("vaccine") { + t, _ := flags.GetInt("vaccine") + vaccine = &t + } else { + vaccine = nil + } + if flags.Changed("tags") { + t, _ := flags.GetString("tags") + tags = &t + } else { + tags = nil + } + + body := api.CreateVaccineAvailabilityApiV1VaccineAvailabilityPostJSONRequestBody{Date: date, Location: location, InputType: inputType, NumberAvailable: numberAvailable, NumberTotal: numberTotal, Vaccine: vaccine, Tags: tags} + + // Create spinner + spinner, sErr := utils.GetDefaultSpinnerForHTTPOp("add", "added", "va") + if sErr != nil { + color.Red(sErr.Error()) + return nil + } + _ = spinner.Start() + + res, rErr := client.CreateVaccineAvailabilityApiV1VaccineAvailabilityPostWithResponse(context.Background(), body) + + if rErr != nil { + spinner.StopFailMessage(rErr.Error()) + _ = spinner.StopFail() + return nil + } + + if res.StatusCode() != 200 { + spinner.StopFailMessage(res.Status() + ": " + string(res.Body)) + _ = spinner.StopFail() + return nil + } + + _ = spinner.Stop() + + colNames := []string{"id", "date", "number available", "number total", "vaccine", "input type", "tags", "location", "created at"} + json := res.JSON200 + data := [][]string{ + { + json.Id, json.Date.String(), strconv.Itoa(json.NumberAvailable), utils.CoalesceInt(json.NumberTotal), utils.CoalesceInt(json.Vaccine), strconv.Itoa(int(json.InputType)), utils.CoalesceString(json.Tags), strconv.Itoa(json.Location), json.CreatedAt.String(), + }, + } + utils.RenderDefaultTable(colNames, data) + + return nil +} diff --git a/internal/cmdrun/va/get/get.go b/internal/cmdrun/va/get/get.go new file mode 100644 index 0000000..37b63bc --- /dev/null +++ b/internal/cmdrun/va/get/get.go @@ -0,0 +1,77 @@ +package get + +import ( + "context" + "fmt" + "strconv" + "vf-admin/internal/utils" + + "github.com/fatih/color" + "github.com/spf13/cobra" +) + +// CmdRunE is what's executed when running `vf-admin va get ` +func CmdRunE(cmd *cobra.Command, args []string) error { + id := args[0] + + // Create the API client + client, cErr := utils.GetAPIClient() + if cErr != nil { + color.Red(cErr.Error()) + return nil + } + + // Create spinner + spinner, sErr := utils.GetDefaultSpinnerForHTTPOp("get", "got", "va") + if sErr != nil { + color.Red(sErr.Error()) + return nil + } + _ = spinner.Start() + + res, rErr := client.RetrieveVaccineAvailabilityByIdApiV1VaccineAvailabilityVaccineAvailabilityIdGetWithResponse(context.Background(), id) + + if rErr != nil { + spinner.StopFailMessage(rErr.Error()) + _ = spinner.StopFail() + return nil + } + + if res.StatusCode() != 200 { + spinner.StopFailMessage(res.Status() + ": " + string(res.Body)) + _ = spinner.StopFail() + return nil + } + + _ = spinner.Stop() + + colNames := []string{"id", "date", "number available", "number total", "vaccine", "input type", "tags", "location", "organization", "created at"} + json := res.JSON200 + var locationLine1, locationLine2, locationProvince, org *string + if json.Location.Address != nil { + locationLine1 = json.Location.Address.Line1 + locationLine2 = json.Location.Address.Line2 + locationProvince = &json.Location.Address.Province + if json.Location.Organization != nil { + org = json.Location.Organization.FullName + } + } + data := [][]string{ + { + json.Id, + json.Date.String(), + strconv.Itoa(json.NumberAvailable), + utils.CoalesceInt(json.NumberTotal), + utils.CoalesceInt(json.Vaccine), + strconv.Itoa(int(json.InputType)), + utils.CoalesceString(json.Tags), + strconv.Itoa(json.Location.Id), + fmt.Sprintf("%d - %s %s %s %s", json.Location.Id, json.Location.Name, utils.CoalesceString(locationLine1), utils.CoalesceString(locationLine2), utils.CoalesceString(locationProvince)), + utils.CoalesceString(org), + json.CreatedAt.String(), + }, + } + utils.RenderDefaultTable(colNames, data) + + return nil +} diff --git a/internal/cmdrun/va/list/list.go b/internal/cmdrun/va/list/list.go new file mode 100644 index 0000000..05e7ccc --- /dev/null +++ b/internal/cmdrun/va/list/list.go @@ -0,0 +1,96 @@ +package list + +import ( + "context" + "fmt" + "strconv" + "time" + "vf-admin/internal/api" + "vf-admin/internal/utils" + + openapi_types "github.com/deepmap/oapi-codegen/pkg/types" + "github.com/fatih/color" + "github.com/spf13/cobra" +) + +// CmdRunE is what's executed when running `vf-admin va list` +func CmdRunE(cmd *cobra.Command, args []string) error { + flags := cmd.Flags() + postcode, _ := flags.GetString("postcode") + + var minDate *openapi_types.Date + + if flags.Changed("mindate") { + t, _ := flags.GetString("mindate") + t2, tErr := time.Parse("2006-01-02", t) + if tErr != nil { + color.Red(tErr.Error()) + return nil + } + minDate = &openapi_types.Date{Time: t2} + } + + params := api.ListVaccineAvailabilityApiV1VaccineAvailabilityGetParams{PostalCode: postcode, MinDate: minDate} + + // Create the API client + client, cErr := utils.GetAPIClient() + if cErr != nil { + color.Red(cErr.Error()) + return nil + } + + // Create spinner + spinner, sErr := utils.GetDefaultSpinnerForHTTPOp("list", "got", "va") + if sErr != nil { + color.Red(sErr.Error()) + return nil + } + _ = spinner.Start() + + res, rErr := client.ListVaccineAvailabilityApiV1VaccineAvailabilityGetWithResponse(context.Background(), ¶ms) + + if rErr != nil { + spinner.StopFailMessage(rErr.Error()) + _ = spinner.StopFail() + return nil + } + + if res.StatusCode() != 200 { + spinner.StopFailMessage(res.Status() + ": " + string(res.Body)) + _ = spinner.StopFail() + return nil + } + + _ = spinner.Stop() + + colNames := []string{"id", "date", "number available", "number total", "vaccine", "input type", "tags", "location", "organization", "created at"} + var data [][]string + for _, row := range *res.JSON200 { + var locationLine1, locationLine2, locationProvince, org *string + if row.Location.Address != nil { + locationLine1 = row.Location.Address.Line1 + locationLine2 = row.Location.Address.Line2 + locationProvince = &row.Location.Address.Province + if row.Location.Organization != nil { + org = row.Location.Organization.FullName + } + } + + data = append(data, []string{ + row.Id, + row.Date.String(), + strconv.Itoa(row.NumberAvailable), + utils.CoalesceInt(row.NumberTotal), + utils.CoalesceInt(row.Vaccine), + strconv.Itoa(int(row.InputType)), + utils.CoalesceString(row.Tags), + fmt.Sprintf("%d - %s %s %s %s", row.Location.Id, row.Location.Name, utils.CoalesceString(locationLine1), utils.CoalesceString(locationLine2), utils.CoalesceString(locationProvince)), + utils.CoalesceString(org), + row.CreatedAt.String(), + }) + } + + utils.RenderDefaultTable(colNames, data) + + return nil +} diff --git a/internal/cmdrun/va/remove/remove.go b/internal/cmdrun/va/remove/remove.go new file mode 100644 index 0000000..540a0e4 --- /dev/null +++ b/internal/cmdrun/va/remove/remove.go @@ -0,0 +1,55 @@ +package remove + +import ( + "context" + "fmt" + "vf-admin/internal/utils" + + "github.com/fatih/color" + "github.com/spf13/cobra" +) + +// CmdRunE is what's executed when running `vf-admin va remove ` +func CmdRunE(cmd *cobra.Command, args []string) error { + id := args[0] + + // Retrieve the authentication key from configuration file + key, kErr := utils.GetKeyFromProfile(cmd) + if kErr != nil { + color.Red(kErr.Error()) + return nil + } + + // Create the API client using the authentication key for requests + client, cErr := utils.GetAPIClientFromKey(key) + if cErr != nil { + color.Red(cErr.Error()) + return nil + } + + // Create spinner + spinner, sErr := utils.GetDefaultSpinnerForHTTPOp("remove", "removed", fmt.Sprint("va ", id)) + if sErr != nil { + color.Red(sErr.Error()) + return nil + } + _ = spinner.Start() + + res, rErr := client.DeleteVaccineAvailabilityByIdApiV1VaccineAvailabilityVaccineAvailabilityIdDeleteWithResponse(context.Background(), id) + + if rErr != nil { + spinner.StopFailMessage(rErr.Error()) + _ = spinner.StopFail() + return nil + } + + if res.StatusCode() != 204 { + spinner.StopFailMessage(res.Status() + ": " + string(res.Body)) + _ = spinner.StopFail() + return nil + } + + _ = spinner.Stop() + + return nil +} diff --git a/internal/cmdrun/va/update/update.go b/internal/cmdrun/va/update/update.go new file mode 100644 index 0000000..7d9d579 --- /dev/null +++ b/internal/cmdrun/va/update/update.go @@ -0,0 +1,103 @@ +package update + +import ( + "context" + "strconv" + "time" + "vf-admin/internal/api" + "vf-admin/internal/utils" + + "github.com/fatih/color" + "github.com/spf13/cobra" +) + +// CmdRunE is what's executed when running `vf-admin va update ` +func CmdRunE(cmd *cobra.Command, args []string) error { + id := args[0] + + // Retrieve the authentication key from configuration file + key, kErr := utils.GetKeyFromProfile(cmd) + if kErr != nil { + color.Red(kErr.Error()) + return nil + } + + // Create the API client using the authentication key for requests + client, cErr := utils.GetAPIClientFromKey(key) + if cErr != nil { + color.Red(cErr.Error()) + return nil + } + + flags := cmd.Flags() + t, _ := flags.GetString("date") + date, tErr := time.Parse("2006-01-02", t) + if tErr != nil { + color.Red(tErr.Error()) + return nil + } + + location, _ := flags.GetInt("location") + inputTypeInt, _ := flags.GetInt("inputtype") + inputType := api.InputTypeEnum(inputTypeInt) + numberAvailable, _ := flags.GetInt("numberavailable") + + var numberTotal, vaccine *int + var tags *string + + if flags.Changed("numbertotal") { + t, _ := flags.GetInt("numbertotal") + numberTotal = &t + } else { + numberTotal = nil + } + if flags.Changed("vaccine") { + t, _ := flags.GetInt("vaccine") + vaccine = &t + } else { + vaccine = nil + } + if flags.Changed("tags") { + t, _ := flags.GetString("tags") + tags = &t + } else { + tags = nil + } + + body := api.UpdateVaccineAvailabilityApiV1VaccineAvailabilityVaccineAvailabilityIdPutJSONRequestBody{Date: date, Location: location, InputType: inputType, NumberAvailable: numberAvailable, NumberTotal: numberTotal, Vaccine: vaccine, Tags: tags} + + // Create spinner + spinner, sErr := utils.GetDefaultSpinnerForHTTPOp("add", "added", "va") + if sErr != nil { + color.Red(sErr.Error()) + return nil + } + _ = spinner.Start() + + res, rErr := client.UpdateVaccineAvailabilityApiV1VaccineAvailabilityVaccineAvailabilityIdPutWithResponse(context.Background(), id, body) + + if rErr != nil { + spinner.StopFailMessage(rErr.Error()) + _ = spinner.StopFail() + return nil + } + + if res.StatusCode() != 200 { + spinner.StopFailMessage(res.Status() + ": " + string(res.Body)) + _ = spinner.StopFail() + return nil + } + + _ = spinner.Stop() + + colNames := []string{"id", "date", "number available", "number total", "vaccine", "input type", "tags", "location", "created at"} + json := res.JSON200 + data := [][]string{ + { + json.Id, json.Date.String(), strconv.Itoa(json.NumberAvailable), utils.CoalesceInt(json.NumberTotal), utils.CoalesceInt(json.Vaccine), strconv.Itoa(int(json.InputType)), utils.CoalesceString(json.Tags), strconv.Itoa(json.Location), json.CreatedAt.String(), + }, + } + utils.RenderDefaultTable(colNames, data) + + return nil +} diff --git a/internal/utils/string.go b/internal/utils/string.go index bd00c0a..66a2144 100644 --- a/internal/utils/string.go +++ b/internal/utils/string.go @@ -1,5 +1,9 @@ package utils +import ( + "strconv" +) + // CoalesceString returns empty string on null, otherwise returns the value func CoalesceString(value *string) string { if value == nil { @@ -7,3 +11,11 @@ func CoalesceString(value *string) string { } return *value } + +// CoalesceInt returns empty string on null, otherwise returns the value as string +func CoalesceInt(value *int) string { + if value == nil { + return "" + } + return strconv.Itoa(*value) +} From aae1ef57b4aa1516dfb8c5b2ac6a7dd61a84c7a7 Mon Sep 17 00:00:00 2001 From: Alvin Tang Date: Fri, 21 May 2021 15:18:57 -0400 Subject: [PATCH 30/32] docs: Create pull_request_template.md --- .github/pull_request_template.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..07a9d73 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,3 @@ +[Description of commits made] + +**Related issue:** [issue (e.g. #1)] From 54032b3827797b64f6fef4de49450cc232744d73 Mon Sep 17 00:00:00 2001 From: github-actions Date: Fri, 21 May 2021 19:36:57 +0000 Subject: [PATCH 31/32] :memo: Auto generated docs in `docs/source`. --- docs/source/vf-admin_va.md | 5 ++++ docs/source/vf-admin_va_add.md | 39 +++++++++++++++++++++++++++++++ docs/source/vf-admin_va_get.md | 32 +++++++++++++++++++++++++ docs/source/vf-admin_va_list.md | 34 +++++++++++++++++++++++++++ docs/source/vf-admin_va_remove.md | 32 +++++++++++++++++++++++++ docs/source/vf-admin_va_update.md | 39 +++++++++++++++++++++++++++++++ 6 files changed, 181 insertions(+) create mode 100644 docs/source/vf-admin_va_add.md create mode 100644 docs/source/vf-admin_va_get.md create mode 100644 docs/source/vf-admin_va_list.md create mode 100644 docs/source/vf-admin_va_remove.md create mode 100644 docs/source/vf-admin_va_update.md diff --git a/docs/source/vf-admin_va.md b/docs/source/vf-admin_va.md index cf78bb3..81389a4 100644 --- a/docs/source/vf-admin_va.md +++ b/docs/source/vf-admin_va.md @@ -17,6 +17,11 @@ Manage vaccine availabilities ### SEE ALSO * [vf-admin](vf-admin.md) - vf-admin is a CLI to manage vaccine availabilities and other data for the Vaccine Hunters Finder tool. +* [vf-admin va add](vf-admin_va_add.md) - Add a new vaccine availability +* [vf-admin va get](vf-admin_va_get.md) - Retrieve a vaccine availability with a specified id +* [vf-admin va list](vf-admin_va_list.md) - Retrieve a list of vaccine availabilities within the vicinity of a postal code +* [vf-admin va remove](vf-admin_va_remove.md) - Remove a vaccine availability with a specified id * [vf-admin va requirement](vf-admin_va_requirement.md) - Manage requirements for vaccine availability * [vf-admin va timeslot](vf-admin_va_timeslot.md) - Manage timeslots for vaccine availability +* [vf-admin va update](vf-admin_va_update.md) - Update a vaccine availability with a specified id diff --git a/docs/source/vf-admin_va_add.md b/docs/source/vf-admin_va_add.md new file mode 100644 index 0000000..5d7f7da --- /dev/null +++ b/docs/source/vf-admin_va_add.md @@ -0,0 +1,39 @@ +## vf-admin va add + +Add a new vaccine availability + +``` +vf-admin va add [flags] +``` + +### Examples + +``` +# Add new vaccine availability on 2021-05-25 with 3 available input type 1 location 1651 and tags vhc +$ vf-admin va add --date "2021-05-25" --numberavailable 3 --inputtype 1 --location 1651 --tags vhc + +``` + +### Options + +``` + --date string date for availability (YYYY-MM-DD) + -h, --help help for add + --inputtype int input type + --location int id of the location + --numberavailable int number of vaccines available + --numbertotal int total number of vaccines + --tags string tags + --vaccine int id of the vaccine +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin va](vf-admin_va.md) - Manage vaccine availabilities + diff --git a/docs/source/vf-admin_va_get.md b/docs/source/vf-admin_va_get.md new file mode 100644 index 0000000..3a3d05f --- /dev/null +++ b/docs/source/vf-admin_va_get.md @@ -0,0 +1,32 @@ +## vf-admin va get + +Retrieve a vaccine availability with a specified id + +``` +vf-admin va get [flags] +``` + +### Examples + +``` +# Get the vaccine availability with id 014cc133-484f-4320-be3b-444e758b64a7 +$ vf-admin va get 014cc133-484f-4320-be3b-444e758b64a7 + +``` + +### Options + +``` + -h, --help help for get +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin va](vf-admin_va.md) - Manage vaccine availabilities + diff --git a/docs/source/vf-admin_va_list.md b/docs/source/vf-admin_va_list.md new file mode 100644 index 0000000..e3b089c --- /dev/null +++ b/docs/source/vf-admin_va_list.md @@ -0,0 +1,34 @@ +## vf-admin va list + +Retrieve a list of vaccine availabilities within the vicinity of a postal code + +``` +vf-admin va list [flags] +``` + +### Examples + +``` +# List the vaccine availabilities within the vicinity of a postal code. +$ vf-admin va list --postcode K1A + +``` + +### Options + +``` + -h, --help help for list + --mindate string minimum date for availability (YYYY-MM-DD) + --postcode string postal code to search around +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin va](vf-admin_va.md) - Manage vaccine availabilities + diff --git a/docs/source/vf-admin_va_remove.md b/docs/source/vf-admin_va_remove.md new file mode 100644 index 0000000..da13c40 --- /dev/null +++ b/docs/source/vf-admin_va_remove.md @@ -0,0 +1,32 @@ +## vf-admin va remove + +Remove a vaccine availability with a specified id + +``` +vf-admin va remove [flags] +``` + +### Examples + +``` +# Remove vaccine availability id 7d7488e4-cc26-434d-85c4-b7df2f7e3171 +$ vf-admin va remove 7d7488e4-cc26-434d-85c4-b7df2f7e3171 + +``` + +### Options + +``` + -h, --help help for remove +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin va](vf-admin_va.md) - Manage vaccine availabilities + diff --git a/docs/source/vf-admin_va_update.md b/docs/source/vf-admin_va_update.md new file mode 100644 index 0000000..664b0ce --- /dev/null +++ b/docs/source/vf-admin_va_update.md @@ -0,0 +1,39 @@ +## vf-admin va update + +Update a vaccine availability with a specified id + +``` +vf-admin va update [flags] +``` + +### Examples + +``` +# Update vaccine availability id 7d7488e4-cc26-434d-85c4-b7df2f7e3171to be on 2021-05-25 with 3 available input type 1 location 1651 and tags vhc +$ vf-admin va update 7d7488e4-cc26-434d-85c4-b7df2f7e3171 --date "2021-05-25" --numberavailable 3 --inputtype 1 --location 1651 --tags vhc + +``` + +### Options + +``` + --date string date for availability (YYYY-MM-DD) + -h, --help help for update + --inputtype int input type + --location int id of the location + --numberavailable int number of vaccines available + --numbertotal int total number of vaccines + --tags string tags + --vaccine int id of the vaccine +``` + +### Options inherited from parent commands + +``` + --profile string specifies the named profile to use for this command (default "default") +``` + +### SEE ALSO + +* [vf-admin va](vf-admin_va.md) - Manage vaccine availabilities + From 402b0c8ea66365cca73183080b760db4881d3c28 Mon Sep 17 00:00:00 2001 From: Alvin Tang Date: Fri, 21 May 2021 15:57:47 -0400 Subject: [PATCH 32/32] ci: Updated ci configs with conventional commit styling and configured Git user for automated git actions. --- .github/workflows/build.yml | 12 +++++++++++- .github/workflows/docs.yml | 2 +- .goreleaser.yml | 9 ++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d00e637..853e69a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,6 +39,11 @@ jobs: ref: main token: ${{ secrets.ADMIN_ACCESS_TOKEN }} + - name: Configure Git user + run: | + git config --global user.name github-actions + git config --global user.email github-actions@github.com + - name: Merge main into stable branch uses: devmasx/merge-branch@v1.3.1 with: @@ -73,7 +78,7 @@ jobs: git add . git status if [ -n "$(git status --porcelain)" ]; then - git commit -m ':memo: Auto generated docs in `docs/${{ github.event.inputs.version }}`.' + git commit -m 'docs: Auto generated CLI docs in `docs/${{ github.event.inputs.version }}`.' git push fi @@ -96,6 +101,11 @@ jobs: fetch-depth: 0 token: ${{ secrets.ADMIN_ACCESS_TOKEN }} + - name: Configure Git user + run: | + git config --global user.name github-actions + git config --global user.email github-actions@github.com + - name: Merge stable into main branch uses: devmasx/merge-branch@v1.3.1 with: diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index f913518..0b7587f 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -31,6 +31,6 @@ jobs: git add . git status if [ -n "$(git status --porcelain)" ]; then - git commit -m ':memo: Auto generated docs in `docs/source`.' + git commit -m 'docs: Auto generated CLI docs in `docs/source`.' git push fi diff --git a/.goreleaser.yml b/.goreleaser.yml index e076e29..a89eae1 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -38,11 +38,10 @@ changelog: sort: asc filters: exclude: - - '\bdocs?\b' - - '\btests?\b' - - '\bworkflows?\b' - - '\bactions?\b' - - '\bREADME\b' + - '^docs' + - '^test' + - '^ci' + - '^Merge' - Merge pull request - Merge branch release: