# Module: device

Source:
  - models/device.js, line 2

### Methods

#### (static) get(id, callback)

Get a single device

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | String | Number | device id
`callback` | module:resin.models.device~getCallback | callback

Source:
  - models/device.js, line 129

##### Example

    resin.models.device.get 51, (error, device) ->
    		throw error if error?
    		console.log(device)

#### (static) get(id, callback)

Get a single device

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | String | Number | device id
`callback` | module:resin.models.device~getCallback | callback

Source:
  - resource/models/device.js, line 129

##### Example

    resin.models.device.get 51, (error, device) ->
    		throw error if error?
    		console.log(device)

#### (static) getAll(callback)

Get all devices

##### Parameters:

Name | Type | Description
--- | --- | ---
`callback` | module:resin.models.device~getAllCallback | callback(error, devices)

Source:
  - resource/models/device.js, line 47

##### Example

    resin.models.devices.getAll (error, devices) ->
    		throw error if error?
    		console.log(devices)

#### (static) getAll(callback)

Get all devices

##### Parameters:

Name | Type | Description
--- | --- | ---
`callback` | module:resin.models.device~getAllCallback | callback(error, devices)

Source:
  - models/device.js, line 47

##### Example

    resin.models.devices.getAll (error, devices) ->
    		throw error if error?
    		console.log(devices)

#### (static) getAllByApplication(applicationId, callback)

Get all devices by application

##### Parameters:

Name | Type | Description
--- | --- | ---
`applicationId` | String | Number | application id
`callback` | module:resin.models.device~getAllByApplicationCallback | callback

Source:
  - models/device.js, line 85

##### Example

    resin.models.devices.getAllByApplication (error, devices) ->
    		throw error if error?
    		console.log(devices)

#### (static) getAllByApplication(applicationId, callback)

Get all devices by application

##### Parameters:

Name | Type | Description
--- | --- | ---
`applicationId` | String | Number | application id
`callback` | module:resin.models.device~getAllByApplicationCallback | callback

Source:
  - resource/models/device.js, line 85

##### Example

    resin.models.devices.getAllByApplication (error, devices) ->
    		throw error if error?
    		console.log(devices)

#### (static) getDeviceSlug(deviceTypeName, callback)

Get device slug

##### Parameters:

Name | Type | Description
--- | --- | ---
`deviceTypeName` | String | device type name
`callback` | module:resin.models.device~getDeviceSlug | callback

Source:
  - models/device.js, line 384
See:
  - module:resin.models.device.getSupportedDeviceTypes for a list of supported devices

##### Example

    resin.models.device.getDeviceSlug 'Raspberry Pi', (error, deviceTypeSlug) ->
    		throw error if error?
    		console.log(deviceTypeSlug)
    		# raspberry-pi

#### (static) getDeviceSlug(deviceTypeName, callback)

Get device slug

##### Parameters:

Name | Type | Description
--- | --- | ---
`deviceTypeName` | String | device type name
`callback` | module:resin.models.device~getDeviceSlug | callback

Source:
  - resource/models/device.js, line 384
See:
  - module:resin.models.device.getSupportedDeviceTypes for a list of supported devices

##### Example

    resin.models.device.getDeviceSlug 'Raspberry Pi', (error, deviceTypeSlug) ->
    		throw error if error?
    		console.log(deviceTypeSlug)
    		# raspberry-pi

#### (static) getDisplayName(deviceTypeSlug, callback)

Get display name for a device

##### Parameters:

Name | Type | Description
--- | --- | ---
`deviceTypeSlug` | String | device type slug
`callback` | module:resin.models.device~getDisplayName | callback

Source:
  - resource/models/device.js, line 345
See:
  - module:resin.models.device.getSupportedDeviceTypes for a list of supported devices

##### Example

    resin.models.device.getDisplayName 'raspberry-pi', (error, deviceTypeName) ->
    		throw error if error?
    		console.log(deviceTypeName)
    		# Raspberry Pi

#### (static) getDisplayName(deviceTypeSlug, callback)

Get display name for a device

##### Parameters:

Name | Type | Description
--- | --- | ---
`deviceTypeSlug` | String | device type slug
`callback` | module:resin.models.device~getDisplayName | callback

Source:
  - models/device.js, line 345
See:
  - module:resin.models.device.getSupportedDeviceTypes for a list of supported devices

##### Example

    resin.models.device.getDisplayName 'raspberry-pi', (error, deviceTypeName) ->
    		throw error if error?
    		console.log(deviceTypeName)
    		# Raspberry Pi

#### (static) getSupportedDeviceTypes(callback)

Get supported device types

##### Parameters:

Name | Type | Description
--- | --- | ---
`callback` | module:resin.models.device~getSupportedDeviceTypes | callback

Source:
  - models/device.js, line 421

##### Example

    resin.models.device.getSupportedDeviceTypes (error, supportedDeviceTypes) ->
    		throw error if error?

    		for supportedDeviceType in supportedDeviceTypes
    			console.log("Resin supports: #{supportedDeviceType}")

#### (static) getSupportedDeviceTypes(callback)

Get supported device types

##### Parameters:

Name | Type | Description
--- | --- | ---
`callback` | module:resin.models.device~getSupportedDeviceTypes | callback

Source:
  - resource/models/device.js, line 421

##### Example

    resin.models.device.getSupportedDeviceTypes (error, supportedDeviceTypes) ->
    		throw error if error?

    		for supportedDeviceType in supportedDeviceTypes
    			console.log("Resin supports: #{supportedDeviceType}")

#### (static) identify(uuid, callback)

Identify device

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | device uuid
`callback` | module:resin.models.device~identifyCallback | callback

Source:
  - resource/models/device.js, line 194

##### Example

    resin.models.device.identify '23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a21369ac0f00db828', (error) ->
    		throw error if error?

#### (static) identify(uuid, callback)

Identify device

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | device uuid
`callback` | module:resin.models.device~identifyCallback | callback

Source:
  - models/device.js, line 194

##### Example

    resin.models.device.identify '23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a21369ac0f00db828', (error) ->
    		throw error if error?

#### (static) isValidUUID(uuid, callback)

Checks if a UUID is valid

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | the device uuid
`callback` | module:resin.models.device~isValidUUIDCallback | callback

Source:
  - models/device.js, line 303
To Do:
  - We should get better server side support for this operation to avoid having to get all devices list and check manually.

##### Example

    uuid = 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828
    resin.models.device.isValidUUID uuid, (error, valid) ->
    		throw error if error?

    		if valid
    			console.log('This is a valid UUID')

#### (static) isValidUUID(uuid, callback)

Checks if a UUID is valid

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | the device uuid
`callback` | module:resin.models.device~isValidUUIDCallback | callback

Source:
  - resource/models/device.js, line 303
To Do:
  - We should get better server side support for this operation to avoid having to get all devices list and check manually.

##### Example

    uuid = 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828
    resin.models.device.isValidUUID uuid, (error, valid) ->
    		throw error if error?

    		if valid
    			console.log('This is a valid UUID')

#### (static) note(id, note, callback)

Note a device

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | String | Number | device id
`note` | String | the note
`callback` | module:resin.models.device~noteCallback | callback

Source:
  - models/device.js, line 264

##### Example

    resin.models.device.note 317, 'My useful note', (error) ->
    		throw error if error?
    		console.log("Device has been noted!")

#### (static) note(id, note, callback)

Note a device

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | String | Number | device id
`note` | String | the note
`callback` | module:resin.models.device~noteCallback | callback

Source:
  - resource/models/device.js, line 264

##### Example

    resin.models.device.note 317, 'My useful note', (error) ->
    		throw error if error?
    		console.log("Device has been noted!")

#### (static) remove(id, callback)

Remove device

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | String | Number | device id
`callback` | module:resin.models.device~removeCallback | callback

Source:
  - resource/models/device.js, line 166

##### Example

    resin.models.device.remove 51, (error) ->
    		throw error if error?

#### (static) remove(id, callback)

Remove device

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | String | Number | device id
`callback` | module:resin.models.device~removeCallback | callback

Source:
  - models/device.js, line 166

##### Example

    resin.models.device.remove 51, (error) ->
    		throw error if error?

#### (static) rename(id, name, callback)

Rename device

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | String | Number | device id
`name` | String | the device new name
`callback` | module:resin.models.device~renameCallback | callback

Source:
  - models/device.js, line 231
To Do:
  - This action doesn't return any error if trying to rename a device that does not exists. This should be fixed server side.

##### Example

    resin.models.device.rename 317, 'NewName', (error) ->
    		throw error if error?
    		console.log("Device has been renamed!")

#### (static) rename(id, name, callback)

Rename device

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | String | Number | device id
`name` | String | the device new name
`callback` | module:resin.models.device~renameCallback | callback

Source:
  - resource/models/device.js, line 231
To Do:
  - This action doesn't return any error if trying to rename a device that does not exists. This should be fixed server side.

##### Example

    resin.models.device.rename 317, 'NewName', (error) ->
    		throw error if error?
    		console.log("Device has been renamed!")

### Type Definitions

#### Device

A Resin API device

##### Type:

- Object

Source:
  - models/device.js, line 20

#### Device

A Resin API device

##### Type:

- Object

Source:
  - resource/models/device.js, line 20

Source:
  - resource/models/device.js, line 2

### Methods

#### (static) get(id, callback)

Get a single device

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | String | Number | device id
`callback` | module:resin.models.device~getCallback | callback

Source:
  - models/device.js, line 129

##### Example

    resin.models.device.get 51, (error, device) ->
    		throw error if error?
    		console.log(device)

#### (static) get(id, callback)

Get a single device

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | String | Number | device id
`callback` | module:resin.models.device~getCallback | callback

Source:
  - resource/models/device.js, line 129

##### Example

    resin.models.device.get 51, (error, device) ->
    		throw error if error?
    		console.log(device)

#### (static) getAll(callback)

Get all devices

##### Parameters:

Name | Type | Description
--- | --- | ---
`callback` | module:resin.models.device~getAllCallback | callback(error, devices)

Source:
  - resource/models/device.js, line 47

##### Example

    resin.models.devices.getAll (error, devices) ->
    		throw error if error?
    		console.log(devices)

#### (static) getAll(callback)

Get all devices

##### Parameters:

Name | Type | Description
--- | --- | ---
`callback` | module:resin.models.device~getAllCallback | callback(error, devices)

Source:
  - models/device.js, line 47

##### Example

    resin.models.devices.getAll (error, devices) ->
    		throw error if error?
    		console.log(devices)

#### (static) getAllByApplication(applicationId, callback)

Get all devices by application

##### Parameters:

Name | Type | Description
--- | --- | ---
`applicationId` | String | Number | application id
`callback` | module:resin.models.device~getAllByApplicationCallback | callback

Source:
  - models/device.js, line 85

##### Example

    resin.models.devices.getAllByApplication (error, devices) ->
    		throw error if error?
    		console.log(devices)

#### (static) getAllByApplication(applicationId, callback)

Get all devices by application

##### Parameters:

Name | Type | Description
--- | --- | ---
`applicationId` | String | Number | application id
`callback` | module:resin.models.device~getAllByApplicationCallback | callback

Source:
  - resource/models/device.js, line 85

##### Example

    resin.models.devices.getAllByApplication (error, devices) ->
    		throw error if error?
    		console.log(devices)

#### (static) getDeviceSlug(deviceTypeName, callback)

Get device slug

##### Parameters:

Name | Type | Description
--- | --- | ---
`deviceTypeName` | String | device type name
`callback` | module:resin.models.device~getDeviceSlug | callback

Source:
  - models/device.js, line 384
See:
  - module:resin.models.device.getSupportedDeviceTypes for a list of supported devices

##### Example

    resin.models.device.getDeviceSlug 'Raspberry Pi', (error, deviceTypeSlug) ->
    		throw error if error?
    		console.log(deviceTypeSlug)
    		# raspberry-pi

#### (static) getDeviceSlug(deviceTypeName, callback)

Get device slug

##### Parameters:

Name | Type | Description
--- | --- | ---
`deviceTypeName` | String | device type name
`callback` | module:resin.models.device~getDeviceSlug | callback

Source:
  - resource/models/device.js, line 384
See:
  - module:resin.models.device.getSupportedDeviceTypes for a list of supported devices

##### Example

    resin.models.device.getDeviceSlug 'Raspberry Pi', (error, deviceTypeSlug) ->
    		throw error if error?
    		console.log(deviceTypeSlug)
    		# raspberry-pi

#### (static) getDisplayName(deviceTypeSlug, callback)

Get display name for a device

##### Parameters:

Name | Type | Description
--- | --- | ---
`deviceTypeSlug` | String | device type slug
`callback` | module:resin.models.device~getDisplayName | callback

Source:
  - resource/models/device.js, line 345
See:
  - module:resin.models.device.getSupportedDeviceTypes for a list of supported devices

##### Example

    resin.models.device.getDisplayName 'raspberry-pi', (error, deviceTypeName) ->
    		throw error if error?
    		console.log(deviceTypeName)
    		# Raspberry Pi

#### (static) getDisplayName(deviceTypeSlug, callback)

Get display name for a device

##### Parameters:

Name | Type | Description
--- | --- | ---
`deviceTypeSlug` | String | device type slug
`callback` | module:resin.models.device~getDisplayName | callback

Source:
  - models/device.js, line 345
See:
  - module:resin.models.device.getSupportedDeviceTypes for a list of supported devices

##### Example

    resin.models.device.getDisplayName 'raspberry-pi', (error, deviceTypeName) ->
    		throw error if error?
    		console.log(deviceTypeName)
    		# Raspberry Pi

#### (static) getSupportedDeviceTypes(callback)

Get supported device types

##### Parameters:

Name | Type | Description
--- | --- | ---
`callback` | module:resin.models.device~getSupportedDeviceTypes | callback

Source:
  - models/device.js, line 421

##### Example

    resin.models.device.getSupportedDeviceTypes (error, supportedDeviceTypes) ->
    		throw error if error?

    		for supportedDeviceType in supportedDeviceTypes
    			console.log("Resin supports: #{supportedDeviceType}")

#### (static) getSupportedDeviceTypes(callback)

Get supported device types

##### Parameters:

Name | Type | Description
--- | --- | ---
`callback` | module:resin.models.device~getSupportedDeviceTypes | callback

Source:
  - resource/models/device.js, line 421

##### Example

    resin.models.device.getSupportedDeviceTypes (error, supportedDeviceTypes) ->
    		throw error if error?

    		for supportedDeviceType in supportedDeviceTypes
    			console.log("Resin supports: #{supportedDeviceType}")

#### (static) identify(uuid, callback)

Identify device

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | device uuid
`callback` | module:resin.models.device~identifyCallback | callback

Source:
  - resource/models/device.js, line 194

##### Example

    resin.models.device.identify '23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a21369ac0f00db828', (error) ->
    		throw error if error?

#### (static) identify(uuid, callback)

Identify device

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | device uuid
`callback` | module:resin.models.device~identifyCallback | callback

Source:
  - models/device.js, line 194

##### Example

    resin.models.device.identify '23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a21369ac0f00db828', (error) ->
    		throw error if error?

#### (static) isValidUUID(uuid, callback)

Checks if a UUID is valid

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | the device uuid
`callback` | module:resin.models.device~isValidUUIDCallback | callback

Source:
  - models/device.js, line 303
To Do:
  - We should get better server side support for this operation to avoid having to get all devices list and check manually.

##### Example

    uuid = 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828
    resin.models.device.isValidUUID uuid, (error, valid) ->
    		throw error if error?

    		if valid
    			console.log('This is a valid UUID')

#### (static) isValidUUID(uuid, callback)

Checks if a UUID is valid

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | the device uuid
`callback` | module:resin.models.device~isValidUUIDCallback | callback

Source:
  - resource/models/device.js, line 303
To Do:
  - We should get better server side support for this operation to avoid having to get all devices list and check manually.

##### Example

    uuid = 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828
    resin.models.device.isValidUUID uuid, (error, valid) ->
    		throw error if error?

    		if valid
    			console.log('This is a valid UUID')

#### (static) note(id, note, callback)

Note a device

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | String | Number | device id
`note` | String | the note
`callback` | module:resin.models.device~noteCallback | callback

Source:
  - models/device.js, line 264

##### Example

    resin.models.device.note 317, 'My useful note', (error) ->
    		throw error if error?
    		console.log("Device has been noted!")

#### (static) note(id, note, callback)

Note a device

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | String | Number | device id
`note` | String | the note
`callback` | module:resin.models.device~noteCallback | callback

Source:
  - resource/models/device.js, line 264

##### Example

    resin.models.device.note 317, 'My useful note', (error) ->
    		throw error if error?
    		console.log("Device has been noted!")

#### (static) remove(id, callback)

Remove device

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | String | Number | device id
`callback` | module:resin.models.device~removeCallback | callback

Source:
  - resource/models/device.js, line 166

##### Example

    resin.models.device.remove 51, (error) ->
    		throw error if error?

#### (static) remove(id, callback)

Remove device

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | String | Number | device id
`callback` | module:resin.models.device~removeCallback | callback

Source:
  - models/device.js, line 166

##### Example

    resin.models.device.remove 51, (error) ->
    		throw error if error?

#### (static) rename(id, name, callback)

Rename device

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | String | Number | device id
`name` | String | the device new name
`callback` | module:resin.models.device~renameCallback | callback

Source:
  - models/device.js, line 231
To Do:
  - This action doesn't return any error if trying to rename a device that does not exists. This should be fixed server side.

##### Example

    resin.models.device.rename 317, 'NewName', (error) ->
    		throw error if error?
    		console.log("Device has been renamed!")

#### (static) rename(id, name, callback)

Rename device

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | String | Number | device id
`name` | String | the device new name
`callback` | module:resin.models.device~renameCallback | callback

Source:
  - resource/models/device.js, line 231
To Do:
  - This action doesn't return any error if trying to rename a device that does not exists. This should be fixed server side.

##### Example

    resin.models.device.rename 317, 'NewName', (error) ->
    		throw error if error?
    		console.log("Device has been renamed!")

### Type Definitions

#### Device

A Resin API device

##### Type:

- Object

Source:
  - models/device.js, line 20

#### Device

A Resin API device

##### Type:

- Object

Source:
  - resource/models/device.js, line 20