fleet/server/datastore
Mike Arpaia 0122f6cb0a Add host_ids and label_ids fields to the packs API (#737)
This PR adds the `host_ids` and `label_ids` field to the packs HTTP API so that one can operate on the hosts/labels which a pack is scheduled to be executed on. This replaces (and deletes) the `/api/v1/kolide/packs/123/labels/456` API in favor of `PATCH /api/v1/packs/123` and specifying the `label_ids` field. This also allows for bulk operations.

Consider the following API examples:

## Creating a pack with a known set of hosts and labels

The key addition is the `host_ids` and `label_ids` field in both the request and the response.

### Request

```
POST /api/v1/kolide/packs
```

```json
{
	"name": "My new pack",
	"description": "The newest of the packs",
	"host_ids": [1, 2, 3],
	"label_ids": [1, 3, 5]
}
```

### Response

```json
{
	"pack": {
		"id": 123,
		"name": "My new pack",
		"description": "The newest of the packs",
		"platform": "",
		"created_by": 1,
		"disabled": false,
		"query_count": 0,
		"total_hosts_count": 5,
		"host_ids": [1, 2, 3],
		"label_ids": [1, 3, 5]
	}
}
```

## Modifying the hosts and/or labels that a pack is scheduled to execute on

### Request

```
PATCH /api/v1/kolide/packs/123
```

```json
{
	"host_ids": [1, 2, 3, 4, 5],
	"label_ids": [1, 3, 5, 7]
}
```

### Response

```json
{
	"pack": {
		"id": 123,
		"name": "My new pack",
		"description": "The newest of the packs",
		"platform": "",
		"created_by": 1,
		"disabled": false,
		"query_count": 0,
		"total_hosts_count": 5,
		"host_ids": [1, 2, 3, 4, 5],
		"label_ids": [1, 3, 5, 7]
	}
}
```

close #633
2017-01-03 10:32:06 -07:00
..
inmem Add host_ids and label_ids fields to the packs API (#737) 2017-01-03 10:32:06 -07:00
internal/appstate Osquery options 365 (#657) 2016-12-29 12:32:28 -06:00
mysql Add host_ids and label_ids fields to the packs API (#737) 2017-01-03 10:32:06 -07:00
datastore_app_test.go App Settings - /admin/settings #363 (#590) 2016-12-20 15:54:30 -06:00
datastore_campaigns_test.go Moving query attributes from the query object to the pack-query relationship (#559) 2016-12-13 14:22:05 -08:00
datastore_hosts_test.go Osquery options 365 (#657) 2016-12-29 12:32:28 -06:00
datastore_invites_test.go Add endpoint to retrieve an invite with the invite token. (#719) 2016-12-29 20:58:12 -05:00
datastore_labels_test.go Add check for all platforms in label query retrieval (#705) 2016-12-29 12:11:26 -08:00
datastore_options_test.go Osquery Options - /config/osquery-options #365 (#729) 2016-12-31 11:56:54 -06:00
datastore_packs_test.go Add host_ids and label_ids fields to the packs API (#737) 2017-01-03 10:32:06 -07:00
datastore_password_reset_test.go Datastore cleaning (#262) 2016-10-04 16:34:36 -04:00
datastore_queries_test.go Moving query attributes from the query object to the pack-query relationship (#559) 2016-12-13 14:22:05 -08:00
datastore_scheduled_queries_test.go Return query and name after creating a scheduled query (#690) 2016-12-22 14:29:29 -05:00
datastore_test.go Add host_ids and label_ids fields to the packs API (#737) 2017-01-03 10:32:06 -07:00
datastore_users_test.go Datastore refactor (#439) 2016-11-16 21:47:49 +08:00
inmem_test.go Added built in labels (#526) 2016-11-26 02:08:22 +08:00
mysql_test.go MySQL's datastore.Drop should drop all tables (#738) 2017-01-03 09:54:24 -07:00