Class: V1::AnnotationResource

Inherits:
JSONAPI::Resource
  • Object
show all
Defined in:
app/resources/v1/annotation_resource.rb

Overview

Provides a JSON:API resource of Annotation model.

AnnotationResource represents a user-supplied comment or note attached to any annotatable resource. It allows creation of annotations, but updates and deletions are not permitted via the API.

Primary relationships:

Examples:


curl -X GET http://localhost:3000/v1/annotations/1
curl -X GET http://localhost:3000/v1/annotations/

curl -X POST "http://yourdomain.com/v1/annotations" \
  -H "accept: application/vnd.api+json" \
  -H "Content-Type: application/vnd.api+json" \
  -d '{
    "data": {
      "type": "annotations",
      "attributes": {
        "comment": "This is a note",
        "user": "jsmith",
        "annotation_type_id": 1,
        "annotatable_type": "Pacbio::Run",
        "annotatable_id": 1
      },
    }
  }'

Direct Known Subclasses

Pacbio::Runs::AnnotationResource

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#annotatable_idInteger

Returns the ID of the resource this annotation is attached to.

Returns:

  • (Integer)

    the ID of the resource this annotation is attached to



51
# File 'app/resources/v1/annotation_resource.rb', line 51

attributes :comment, :user, :created_at, :annotation_type_id, :annotatable_type, :annotatable_id

#annotatable_typeString

Returns the type of the resource this annotation is attached to.

Returns:

  • (String)

    the type of the resource this annotation is attached to



51
# File 'app/resources/v1/annotation_resource.rb', line 51

attributes :comment, :user, :created_at, :annotation_type_id, :annotatable_type, :annotatable_id

#annotation_type_idInteger

Returns the ID of the annotation type.

Returns:

  • (Integer)

    the ID of the annotation type



51
# File 'app/resources/v1/annotation_resource.rb', line 51

attributes :comment, :user, :created_at, :annotation_type_id, :annotatable_type, :annotatable_id

#commentString

Returns the annotation text (required, max 500 chars).

Returns:

  • (String)

    the annotation text (required, max 500 chars)



51
# File 'app/resources/v1/annotation_resource.rb', line 51

attributes :comment, :user, :created_at, :annotation_type_id, :annotatable_type, :annotatable_id

#created_atDateTime

Returns the timestamp when the annotation was created.

Returns:

  • (DateTime)

    the timestamp when the annotation was created



51
# File 'app/resources/v1/annotation_resource.rb', line 51

attributes :comment, :user, :created_at, :annotation_type_id, :annotatable_type, :annotatable_id

#userString

Returns the user who created the annotation (required, max 10 chars).

Returns:

  • (String)

    the user who created the annotation (required, max 10 chars)



51
# File 'app/resources/v1/annotation_resource.rb', line 51

attributes :comment, :user, :created_at, :annotation_type_id, :annotatable_type, :annotatable_id

Instance Method Details

#removeObject

Raises:

  • (JSONAPI::Exceptions::RecordLocked)


64
65
66
# File 'app/resources/v1/annotation_resource.rb', line 64

def remove
  raise JSONAPI::Exceptions::RecordLocked, 'Annotations cannot be deleted'
end

#replace_fields(_fields) ⇒ Object

Prevent updates and deletes through the API

Raises:

  • (JSONAPI::Exceptions::RecordLocked)


60
61
62
# File 'app/resources/v1/annotation_resource.rb', line 60

def replace_fields(_fields)
  raise JSONAPI::Exceptions::RecordLocked, 'Annotations cannot be updated'
end