updating api routing

This commit is contained in:
ari committed 2022-05-16 15:38:13 -04:00
1 parent dc726ff184
commit 0be03b1536
7 files changed
+53 -63

No files matched your search

+38 -12
View File
@@ -9,44 +9,70 @@ on:
paths:
- 'config.yaml'
jobs:
build:
runs-on: ubuntu-latest
name: Build & Publish
# strategy:
# matrix:
# arch: ["aarch64", "amd64", "armhf", "armv7", "i386"]
metadata:
runs-on: ubuntu-latest
name: Metadata
outputs:
version: ${{ steps.version.outputs.VERSION }}
changlelog: ${{ steps.changlelog.outputs.CHANGELOG }}
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Get Version
id: version
shell: bash
run: |
echo ::set-output name=VERSION::$(cat config.yaml | sed -nr 's/version: (.*)/\1/p')
- name: Get Changelog
id: changlelog
shell: bash
run: |
echo ::set-output name=CHANGELOG::$(cat CHANGELOG.md)
build:
runs-on: ubuntu-latest
name: Build & Publish ${{ matrix.arch }}
needs:
- metadata
strategy:
matrix:
arch: ["aarch64", "amd64", "armhf", "armv7", "i386"]
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Login to DockerHub
uses: docker/login-action@v2.0.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: ${{ steps.version.outputs.VERSION }}
- name: Build & Push to Dockerhub - ${{ matrix.arch }} / ${{ needs.metadata.outputs.version }}
uses: home-assistant/builder@2022.03.1
with:
args: |
--all \
--${{ matrix.arch }} \
--target .
- name: Publish Release ${{ steps.version.outputs.VERSION }}
publish:
runs-on: ubuntu-latest
needs:
- metadata
- build
name: Publish Github Release
steps:
- name: Publish Release ${{ needs.metadata.outputs.version }}
uses: actions/github-script@v6
env:
VERSION: ${{ steps.version.outputs.VERSION }}
VERSION: ${{ needs.metadata.outputs.version }}
CHANGELOG: ${{ needs.metadata.outputs.changlelog }}
with:
script: |
github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: process.env.VERSION,
body: process.env.CHANGELOG,
});
+1 -38
View File
@@ -1,40 +1,3 @@
# Changelog -- [![GitHub version](https://badge.fury.io/gh/asosnovsky%2FShortumation.svg)](https://badge.fury.io/gh/asosnovsky%2FShortumation)
## [0.1.2] - Docker Hub Images
- Publishing images to docker hub is now stable
## [0.0.15] - Publish to dockerhub
- Publishing images to docker hub
## [0.0.14] - Using vanila ha yaml
- Supporing vanilla out of the box HA yaml as oppose to parsing them (no more $smType)
- Conditions have now a more a explicit node
## [0.0.13] - Better Styling with react-flow
- Fixed up styling (using react-flow)
- cleaned up some button styles
## [0.0.12] - Tags
- Added tag management system for automations
## [0.0.11] - Zoom
- Added lazy saving
## [0.0.10] - Zoom
- Introducing Zoom!
## [0.0.9] - First Working Version
- Instalable verion via github
- Initial POC done
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- Updated Api Routing
+2 -2
View File
@@ -25,11 +25,11 @@ def make_automation_router(automations: AutomationManager) -> APIRouter:
),
)
@router.post("")
@router.post("/item")
def upsert_auto(body: UpdateAutoRequest):
automations.update(body.index, body.data)
@router.delete("")
@router.delete("/item")
def delete_auto(body: DeleteAutoRequest):
try:
automations.delete(body.index)
+1 -1
View File
@@ -1,5 +1,5 @@
name: Shortumation
version: 0.1.3
version: 0.1.4
slug: shortumation
image: asosnovsky/shortumation-{arch}
url: "https://github.com/asosnovsky/Shortumation"
+5 -5
View File
@@ -1,7 +1,7 @@
import { AutomationData } from "types/automations";
import { API } from "./base";
import { ListData, ListParams } from "./types";
import { AUTOMTAION_LIST, AUTOMTAION_ROOT } from './paths';
import { AUTOMTAION_LIST, AUTOMTAION_ITEM } from './paths';
export const makeAutomationAPI = (api: API) => ({
@@ -14,19 +14,19 @@ export const makeAutomationAPI = (api: API) => ({
});
return data;
},
async update({index, auto}: {index: number, auto: AutomationData}) {
async update({ index, auto }: { index: number, auto: AutomationData }) {
return await api.makeCall({
path: AUTOMTAION_ROOT,
path: AUTOMTAION_ITEM,
data: {
index,
data: auto
},
})
},
async remove({index}: {index: number}) {
async remove({ index }: { index: number }) {
return await api.makeCall({
method: "DELETE",
path: AUTOMTAION_ROOT,
path: AUTOMTAION_ITEM,
data: {
index,
}
+3 -3
View File
@@ -1,7 +1,7 @@
import { useRef } from 'react';
import { AutomationData } from 'types/automations';
import { API } from './base';
import { AUTOMTAION_LIST, AUTOMTAION_ROOT } from './paths';
import { AUTOMTAION_LIST, AUTOMTAION_ITEM } from './paths';
export const useMockAPI = (
@@ -26,7 +26,7 @@ export const useMockAPI = (
}))
} as any
}
if (path === AUTOMTAION_ROOT) {
if (path === AUTOMTAION_ITEM) {
if (method === 'POST') {
const { index, data: auto } = data as any;
if (index >= automationsRef.current.length) {
@@ -37,7 +37,7 @@ export const useMockAPI = (
auto,
...automationsRef.current.slice(index + 1)
];
}
}
return {
ok: true,
data: {}
+3 -2
View File
@@ -1,4 +1,5 @@
export const AUTOMTAION_ROOT = '' as const;
export const AUTOMTAION_LIST = `${AUTOMTAION_ROOT}/list` as const;
export const AUTOMTAION_ROOT = '/' as const;
export const AUTOMTAION_LIST = `${AUTOMTAION_ROOT}list` as const;
export const AUTOMTAION_ITEM = `${AUTOMTAION_ROOT}item` as const;