Class: Api::V2::AssetAuditResource

Inherits:
BaseResource
  • Object
show all
Defined in:
app/resources/api/v2/asset_audit_resource.rb

Overview

Note:

This resource cannot be modified after creation: its endpoint will not accept PATCH requests.

Note:

Access this resource via the /api/v2/asset_audits/ endpoint.

Provides a JSON:API representation of AssetAudit, which records audit events related to assets.

For more information about JSON:API see the JSON:API Specifications or look at the JSONAPI::Resources package for Sequencescape's implementation of the JSON:API standard.

Examples:

GET request for all AssetAudit resources

GET /api/v2/asset_audits/

GET request for a specific AssetAudit by ID

GET /api/v2/asset_audits/123/

POST request to create a new AssetAudit

POST /api/v2/asset_audits/
{
  "data": {
    "type": "asset_audits",
    "attributes": {
      "key": "asset_audit_key",
      "message": "Asset audit message",
      "created_by": "user_uuid",
      "witnessed_by": "witness_user_uuid",
      "metadata": null
    }
  }
}

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from BaseResource

apply_includes, creatable_fields, default_includes, #fetchable_fields, inclusions, resolve_relationship_names_to_relations

Instance Attribute Details

#asset_uuidString

Transforms the Asset into its UUID when generating an API query response.

Returns:

  • (String)

    the uuid of the associated asset



90
91
92
# File 'app/resources/api/v2/asset_audit_resource.rb', line 90

def asset_uuid
  @model.asset.uuid
end

#created_by=(value) ⇒ String (writeonly)

Returns The user who created the asset audit.

Parameters:

  • value (String)

    The user who created the asset audit.

Returns:

  • (String)

    The user who created the asset audit.



55
# File 'app/resources/api/v2/asset_audit_resource.rb', line 55

attribute :created_by

#key=(value) ⇒ String (writeonly)

Note:

This field is required.

Returns The key of the asset audit event.

Parameters:

  • value (String)

    The key of the asset audit event.

Returns:

  • (String)

    The key of the asset audit event.



45
# File 'app/resources/api/v2/asset_audit_resource.rb', line 45

attribute :key

#message=(value) ⇒ String (writeonly)

Returns The message describing the audit event.

Parameters:

  • value (String)

    The message describing the audit event.

Returns:

  • (String)

    The message describing the audit event.



50
# File 'app/resources/api/v2/asset_audit_resource.rb', line 50

attribute :message

#metadata=(value) ⇒ Hash (writeonly)

Note:

Currently known clients (Asset Audits App) are sending null; unsure of the expected format.

Returns Additional metadata associated with the asset audit.

Parameters:

  • value (String)

    Additional metadata associated with the asset audit.

Returns:

  • (Hash)

    Additional metadata associated with the asset audit.



73
# File 'app/resources/api/v2/asset_audit_resource.rb', line 73

attribute :metadata

#witnessed_by=(value) ⇒ String (writeonly)

Returns The user who witnessed the asset audit.

Parameters:

  • value (String)

    The user who witnessed the asset audit.

Returns:

  • (String)

    The user who witnessed the asset audit.



67
# File 'app/resources/api/v2/asset_audit_resource.rb', line 67

attribute :witnessed_by

Class Method Details

.updatable_fields(_context) ⇒ Object

Gets the list of fields that are updatable on an existing AssetAudit. AssetAudits cannot be modified after creation. @param _context [JSONAPI::Resource::Context] Not used. @return [Array<Symbol>] The list of updatable fields.



102
103
104
# File 'app/resources/api/v2/asset_audit_resource.rb', line 102

def self.updatable_fields(_context)
  [] # Do not allow updating any fields.
end