Skip to content

Commit

Permalink
eslint cleaning and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jupe committed Jan 28, 2019
1 parent 5296565 commit 8526f99
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
26 changes: 12 additions & 14 deletions app/models/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ const {ObjectId} = Types;
*/
const ResourceSchema = new Schema({
name: {type: String}, // Resource Name
type: {
type: { // Resource type
type: String,
required: true,
enum: [ // Resource type
enum: [
'system',
'dut',
'instrument',
Expand Down Expand Up @@ -106,7 +106,7 @@ const ResourceSchema = new Schema({
}
},
network: {
hostname: {type: String, unique: true, sparse: true},
hostname: {type: String},
domain: {type: String},
lan: [{
name: {type: String},
Expand All @@ -117,22 +117,22 @@ const ResourceSchema = new Schema({
mac: {type: String}
}],
remote_connection: {
protocol: {type: String, enum: ['', 'vnc', 'http', 'ssh', 'telnet', 'rdm'], default: ''},
url: {type: String}, // if dedicated
protocol: {type: String, enum: ['vnc', 'http', 'https', 'ssh', 'telnet', 'rdm']},
url: {type: String},
authentication: {
username: {type: String},
password: {type: String}
}
}
},
location: { // Resource physical location
site: {type: String, default: 'unknown'}, // Site
country: {type: String}, // Country
city: {type: String}, // City
adddress: {type: String}, // Street address
postcode: {type: String}, // Postcode
room: {type: String, default: 'unknown'}, // Room
subRoom: {type: String}, // subRoom
site: {type: String, default: 'unknown'},
country: {type: String},
city: {type: String},
adddress: {type: String},
postcode: {type: String},
room: {type: String, default: 'unknown'},
subRoom: {type: String},
geo: {type: [Number], index: '2d'}
},
tags: {
Expand Down Expand Up @@ -190,7 +190,6 @@ const ResourceSchema = new Schema({
rf: { type: Boolean }, // RF shield rack
},
app: [{
type: {type: String, enum: ['application', 'plugin','library']}, // optional
plugin: {
application: {type: String}
Expand All @@ -202,7 +201,6 @@ const ResourceSchema = new Schema({
href: {type: String}, // http url to file
uuid: {type: String} // or uuid to file
}]
events: [ResourceEventSchema], //Events
change_history: []
*/

Expand Down
11 changes: 7 additions & 4 deletions doc/APIs/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
**NOTE** Following API's require authentication token to work.

## Find Resources
Find Events. Data schema available [here](../../app/models/resource.js)
Find Resources. Data schema available [here](../../app/models/resource.js)

* **URL**

Expand Down Expand Up @@ -42,7 +42,9 @@ Find Events. Data schema available [here](../../app/models/resource.js)


**Notes:**
You can use filter results by using url parameters. E.g. <api>/resources?hw.sn=abc
You can use filter results by using url parameters.
E.g. <api>/resources?hw.sn=abc`


## Get single resource
Returns single Resource.
Expand All @@ -51,6 +53,8 @@ Find Events. Data schema available [here](../../app/models/resource.js)

/api/v0/resources/:resource

`hw.sn` can be also used for resource identification

* **Method:**

`GET`
Expand All @@ -62,7 +66,7 @@ Find Events. Data schema available [here](../../app/models/resource.js)
**Content:**
```json
{
"_id" : "5a89c4121a6d6e068a08c60e"),
"_id" : "5a89c4121a6d6e068a08c60e",
"cre" : {
"date" : "2018-02-18T18:21:06.865Z"
},
Expand All @@ -84,6 +88,5 @@ Find Events. Data schema available [here](../../app/models/resource.js)
{"error": "No resources found by id"}
```


## resource events and utilization based on resource id
see documentation from [here](events.md#get-events-based-on-resource-id)
6 changes: 3 additions & 3 deletions test/tests_api/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Events', function () {
const info = {
name: 'events-testing',
type: 'dut',
hw: {sn: 'mysn'},
hw: {sn: 'mysn'}
};
return superagent.post(url, info)
.set('authorization', authString)
Expand Down Expand Up @@ -170,7 +170,7 @@ describe('Events', function () {
expect(body.msgid).to.be.equal(msgid);
});
};
const getEvents = (id) =>
const getEvents = id =>
superagent.get(`${apiV0}/resources/${id}/events`)
.set('authorization', authString)
.end()
Expand Down Expand Up @@ -271,5 +271,5 @@ describe('Events', function () {
expect(stats.summary.allocations.utilization).to.be.below(4.2);
});
});
})
});
});

0 comments on commit 8526f99

Please sign in to comment.