<commit_before># edge-node-manager [![Go Report Card](https://goreportcard.com/badge/github.com/resin-io/edge-node-manager)](https://goreportcard.com/report/github.com/resin-io/edge-node-manager) [![Build Status](https://travis-ci.com/resin-io/edge-node-manager.svg?token=SsmNYChpKvn5yEXMkM2D&branch=master)](https://travis-ci.com/resin-io/edge-node-manager)
resin.io dependent device edge-node-manager written in Go.

## Getting started
 - Sign up on [resin.io](https://dashboard.resin.io/signup)
 - Work through the [getting started guide](https://docs.resin.io/raspberrypi3/nodejs/getting-started/)
 - Create a new Raspberry Pi 3 application called `EdgeNodeManager`
 - Set these variables in the `Fleet Configuration` application side tab
    - `RESIN_SUPERVISOR_DELTA=1`
    - `RESIN_UI_ENABLE_DEPENDENT_APPLICATIONS=1`
 - Clone this repository to your local workspace
 - Add the dependent application `resin remote` to your local workspace
 - Provision a Raspberry Pi 3 gateway device
 - Push code to resin as normal :)
 - Follow the readme of the [supported dependent device](#supported-dependent-devices) you would like to use

## Supported dependent devices
 - [micro:bit](https://github.com/resin-io-projects/micro-bit)
 - [nRF51822-DK](https://github.com/resin-io-projects/nRF51822-DK)

## API
The edge-node-manager provides an API that allows the user to set the target status of the main process and to check whether there are updates pending. This can be useful for a couple of reasons:
 - Ensure the edge-node-manager process is not running during an update of the user container
 - Free up the on-board radios to allow user code to interact directly with the dependent devices e.g. to collect sensor data

**Warning** - Do not try and interact with the on-board radios whilst the edge-node-manager is running (this leads to inconsistent, unexpected behaviour)

### SET /v1/enm/status
Set the edge-node-manager process status.

#### Example
```
curl -i -H "Content-Type: application/json" -X PUT --data '{"targetStatus":"Paused"}' localhost:1337/v1/enm/status
curl -i -H "Content-Type: application/json" -X PUT --data '{"targetStatus":"Running"}' localhost:1337/v1/enm/status
```

#### Response
```
HTTP/1.1 200 OK
```

### GET /v1/enm/status
Get the edge-node-manager process status.

#### Example
```
curl -i -X GET localhost:1337/v1/enm/status
```

#### Response<commit_msg>Add update lock info to readme<commit_after># edge-node-manager [![Go Report Card](https://goreportcard.com/badge/github.com/resin-io/edge-node-manager)](https://goreportcard.com/report/github.com/resin-io/edge-node-manager) [![Build Status](https://travis-ci.com/resin-io/edge-node-manager.svg?token=SsmNYChpKvn5yEXMkM2D&branch=master)](https://travis-ci.com/resin-io/edge-node-manager)
resin.io dependent device edge-node-manager written in Go.

## Getting started
 - Sign up on [resin.io](https://dashboard.resin.io/signup)
 - Work through the [getting started guide](https://docs.resin.io/raspberrypi3/nodejs/getting-started/)
 - Create a new Raspberry Pi 3 application called `EdgeNodeManager`
 - Set these variables in the `Fleet Configuration` application side tab
    - `RESIN_SUPERVISOR_DELTA=1`
    - `RESIN_UI_ENABLE_DEPENDENT_APPLICATIONS=1`
 - Clone this repository to your local workspace
 - Add the dependent application `resin remote` to your local workspace
 - Provision a Raspberry Pi 3 gateway device
 - Push code to resin as normal :)
 - Follow the readme of the [supported dependent device](#supported-dependent-devices) you would like to use

## Supported dependent devices
 - [micro:bit](https://github.com/resin-io-projects/micro-bit)
 - [nRF51822-DK](https://github.com/resin-io-projects/nRF51822-DK)

## API
The edge-node-manager provides an API that allows the user to set the target status of the main process and to check whether there are updates pending. This can be useful for a couple of reasons:
 - Ensure the edge-node-manager process is not running during an update of the user container
 - Free up the on-board radios to allow user code to interact directly with the dependent devices e.g. to collect sensor data

**Note** - [Update locks](https://github.com/resin-io/resin-supervisor/blob/master/docs/update-locking.md) *are* enabled whilst the process is running. This means that you will need to pause the edge-node-manager to update the user container.

**Warning** - Do not try and interact with the on-board radios whilst the edge-node-manager is running (this leads to inconsistent, unexpected behaviour).

### SET /v1/enm/status
Set the edge-node-manager process status.

#### Example
```
curl -i -H "Content-Type: application/json" -X PUT --data '{"targetStatus":"Paused"}' localhost:1337/v1/enm/status
curl -i -H "Content-Type: application/json" -X PUT --data '{"targetStatus":"Running"}' localhost:1337/v1/enm/status
```

#### Response
```
HTTP/1.1 200 OK
```

### GET /v1/enm/status
Get the edge-node-manager process status.

#### Example
```
curl -i -X GET localhost:1337/v1/enm/status
```

#### Response
{'fraction_non_alphanumeric': 0.12405866032500991, 'fraction_numerical': 0.015457788347205707, 'mean_word_length': 4.392094017094017, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 17, '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': '7260652', 'n_tokens_mistral': 1641, 'n_tokens_neox': 1543, 'n_words': 495}