forked from auchter/haaska
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
75 lines (62 loc) · 2.34 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
SHELL := /bin/bash
# Function name in AWS Lambda:
FUNCTION_NAME=haaska
BUILD_DIR=build
haaska.zip: haaska.py config/*
mkdir -p $(BUILD_DIR)
cp $^ $(BUILD_DIR)
pip install -t $(BUILD_DIR) requests
cd $(BUILD_DIR); zip ../$@ -r *
.PHONY: deploy
deploy: haaska.zip
aws lambda update-function-configuration \
--function-name $(FUNCTION_NAME) \
--handler haaska.event_handler
aws lambda update-function-code \
--function-name $(FUNCTION_NAME) \
--zip-file fileb://$<
TEST_PAYLOAD:=' \
{ \
"header": { \
"payloadVersion": "2", \
"namespace": "Alexa.ConnectedHome.System", \
"name": "HealthCheckRequest" \
}, \
"payload": { \
"accessToken": "..." \
} \
}'
.PHONY: test
test:
@aws lambda invoke \
--function-name $(FUNCTION_NAME) \
--payload ${TEST_PAYLOAD} \
/dev/fd/3 3>&1 >/dev/null | jq -e '., .payload.isHealthy'
DISCOVERY_PAYLOAD:=' \
{ \
"header": { \
"payloadVersion": "2", \
"namespace": "Alexa.ConnectedHome.Discovery", \
"name": "DiscoverAppliancesRequest" \
}, \
"payload": { \
"accessToken": "..." \
} \
}'
.PHONY: discover
discover:
@aws lambda invoke \
--function-name $(FUNCTION_NAME) \
--payload ${DISCOVERY_PAYLOAD} \
/dev/fd/3 3>&1 >/dev/null | jq '.'
.PHONY: clean
clean:
rm -rf $(BUILD_DIR) haaska.zip
.PHONY: sample_config
sample_config:
python -c 'from haaska import Configuration; print(Configuration().dump())' > config/config.json.sample
.PHONY: modernize_config
modernize_config: config/config.json
@python -c 'from haaska import Configuration; print(Configuration("config/config.json").dump())' > config/config.json.modernized
@echo Generated config/config.json.modernized from your existing config/config.json
@echo Inspect that file and replace config/config.json with it to update your configuration