Class: Api::V2::QcableCreatorResource

Inherits:
BaseResource
  • Object
show all
Defined in:
app/resources/api/v2/qcable_creator_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/qcable_creators/ endpoint.

Provides a JSON:API representation of QcableCreator which is a factory for creating Qcables (tag plates).

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:

POST request to create a QcableCreator, using 'count'.

POST /api/v2/qcable_creators/
{
  "data": {
    "type": "qcable_creators",
    "attributes": {
      "count": 3
    },
    "relationships": {
      "lot": {
        "data": {
          "type": "lots",
          "id": 1
        }
      },
      "user": {
        "data": {
          "type": "users",
          "id": 1
        }
      }
    }
  }
}

POST request to create a QcableCreator, using 'barcodes'.

POST /api/v2/qcable_creators/
{
  "data": {
    "type": "qcable_creators",
    "attributes": {
      "barcodes": "SQPD-11111,SQPD-22222,SQPD-33333"
    },
    "relationships": {
      "lot": {
        "data": {
          "type": "lots",
          "id": 1
        }
      },
      "user": {
        "data": {
          "type": "users",
          "id": 1
        }
      }
    }
  }
}

GET request for all QcableCreator resources

GET /api/v2/qcable_creators/

GET request for a QcableCreator with ID 123

GET /api/v2/qcable_creators/123/

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseResource

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

Instance Attribute Details

#barcodesString

Either this or 'count' is passed in when creating a QcableCreator.

Returns:

  • (String)

    a string containing the barcodes to use when creating the associated Qcables, or the barcodes of any existing QCables.



84
# File 'app/resources/api/v2/qcable_creator_resource.rb', line 84

attribute :barcodes

#countInteger

Either this or 'barcodes' is passed in when creating a QcableCreator.

Returns:



89
# File 'app/resources/api/v2/qcable_creator_resource.rb', line 89

attribute :count

#lotLotResource

Returns the Lot resource associated with this QcableCreator.

Returns:



97
# File 'app/resources/api/v2/qcable_creator_resource.rb', line 97

has_one :lot

#qcablesArray<QcableResource> (readonly)

Returns the Qcable resources created by this QcableCreator.

Returns:



105
# File 'app/resources/api/v2/qcable_creator_resource.rb', line 105

has_many :qcables, readonly: true

#userUserResource

Returns the User resource associated with this QcableCreator.

Returns:



101
# File 'app/resources/api/v2/qcable_creator_resource.rb', line 101

has_one :user

#uuidString (readonly)

Returns the UUID of this QcableCreator.

Returns:



78
# File 'app/resources/api/v2/qcable_creator_resource.rb', line 78

attribute :uuid, readonly: true

Instance Method Details

#filter_uuidObject

Apply a filter across all QcableCreator resources, matching by UUID.

Examples:

Get all QcableCreator resources with a specific UUID.

/api/v2/qcable_creators?filter[uuid]=12345678-1234-1234-1234-123456789012


115
# File 'app/resources/api/v2/qcable_creator_resource.rb', line 115

filter :uuid, apply: ->(records, value, _options) { records.with_uuid(value) }