<commit_before>all: package-lambda

help:
	@echo "Please use \`make <target>' where <target> is one of"
	@echo "  package-lambda      to package the lambda function"
	@echo "  package-config      to package the NetScaler Terraform config"
	@echo "  create-lambda       to create the lambda function in AWS"
	@echo "  update-lambda       to update the lambda function in AWS"

bundle.zip: handler.py bin/terraform-provider-netscaler
	zip  bundle.zip handler.py bin/*

config.zip: config/*
	zip  config.zip config/*

package-lambda: bundle.zip
	@echo "create/update lambda deployment package (bundle.zip)"

package-config: config.zip
	@echo "create/update NetScaler Terraform files (config.zip)"

update-config: package-config
	@echo "update config in S3 bucket"
	aws s3 cp config.zip s3://${S3_TFCONFIG_BUCKET}

update-lambda:  package-lambda
	@echo "update lambda deployment package"
	aws lambda update-function-code  --function-name ConfigureNetScaler --zip-file fileb://${PWD}/bundle.zip

create-lambda:  package-lambda
	@echo "create lambda deployment package in AWS"
	setup/create_lambda.sh


create-lambda-role:
	@echo "create lambda execution role"
	setup/create_lambda_role.sh

test-local:
	@echo "Testing locally"
	python-lambda-local -l lib/ -f handler -t 50 handler.py event.json
<commit_msg>Invoke from cli<commit_after>all: package-lambda

help:
	@echo "Please use \`make <target>' where <target> is one of"
	@echo "  package-lambda      to package the lambda function"
	@echo "  package-config      to package the NetScaler Terraform config"
	@echo "  create-lambda       to create the lambda function in AWS"
	@echo "  update-lambda       to update the lambda function in AWS"
	@echo "  test-local          to test locally"

bundle.zip: handler.py bin/terraform-provider-netscaler
	zip  bundle.zip handler.py bin/*

config.zip: config/*
	zip  config.zip config/*

package-lambda: bundle.zip
	@echo "create/update lambda deployment package (bundle.zip)"

package-config: config.zip
	@echo "create/update NetScaler Terraform files (config.zip)"

update-config: package-config
	@echo "update config in S3 bucket"
	aws s3 cp config.zip s3://${S3_TFCONFIG_BUCKET}

update-lambda:  package-lambda
	@echo "update lambda deployment package"
	aws lambda update-function-code  --function-name ConfigureNetScaler --zip-file fileb://${PWD}/bundle.zip

create-lambda:  package-lambda
	@echo "create lambda deployment package in AWS"
	setup/create_lambda.sh


create-lambda-role:
	@echo "create lambda execution role"
	setup/create_lambda_role.sh

test-local:
	@echo "Testing locally"
	python-lambda-local -l lib/ -f handler -t 50 handler.py event.json

invoke-lambda:
	@echo "Invoking Lambda remote"
	aws lambda invoke --function-name ConfigureNetScaler --log-type Tail outfile.txt | grep LogResult | awk -F" " '{print $$2}' | sed 's/"//g' | sed 's/,//g'  | base64 --decode
{'fraction_non_alphanumeric': 0.10786360473208072, 'fraction_numerical': 0.005219206680584551, 'mean_word_length': 3.889455782312925, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2570134', 'n_tokens_mistral': 917, 'n_tokens_neox': 912, 'n_words': 294}