Class: Core::Endpoint::Base Abstract

Inherits:
Object
  • Object
show all
Extended by:
InstanceBehaviour, ModelBehaviour
Defined in:
app/api/core/endpoint/base.rb

Overview

This class is abstract.

Define new endpoints by specifying ModelBehaviour#model and InstanceBehaviour#instance actions

Core class for API V1 endpoints, which effectively acts as a controller layer. New endpoints should be placed in `app/api/endpoints/` and should inherit from Core::Endpoint::Base. All endpoints are in the Endpoints namespace.

model defines actions on the collection, in the asset audit example a create action on `api/1/asset_audits`

instance defines actions on individual instances, usually accessed via their uuid. In this case each asset audit has an asset action which returns the associated asset. ie. `api/1/000000-0000-0000-0000-000000000000/asset`

There is no need to modify the routes when adding endpoints.

It is not necessary to define index or show endpoints, these are defined by default.

Examples:

Asset Audit

class ::Endpoints::AssetAudits < ::Core::Endpoint::Base
 model do
   action(:create) do |request, _response|
     request.create!
   end
 end

 instance do
   belongs_to(:asset, json: 'asset')
 end
end

See Also:

Direct Known Subclasses

Endpoints::AssetAudits, Endpoints::AssetGroups, Endpoints::Assets, Endpoints::BaitLibraryLayouts, Endpoints::BarcodePrinters, Endpoints::Batches, Endpoints::BulkTransfers, Endpoints::Comments, Endpoints::CustomMetadatumCollections, Endpoints::ExtractionAttributes, Endpoints::Lanes, Endpoints::LibraryEvents, Endpoints::LotTypes, Endpoints::Lots, Endpoints::OrderTemplates, Endpoints::Orders, Endpoints::Pipelines, Endpoints::PlateConversions, Endpoints::PlateCreations, Endpoints::PlatePurposes, Endpoints::PlateTemplates, Endpoints::Plates, Endpoints::PooledPlateCreations, Endpoints::Projects, Endpoints::QcDecisions, Endpoints::QcFiles, Endpoints::QcableCreators, Endpoints::Qcables, Endpoints::ReferenceGenomes, Endpoints::RequestTypes, Endpoints::Requests, Endpoints::Robots, Endpoints::SampleManifests, Endpoints::Samples, Endpoints::Searches, Endpoints::SpecificTubeCreations, Endpoints::Stamps, Endpoints::StateChanges, Endpoints::Studies, Endpoints::SubmissionPools, Endpoints::Submissions, Endpoints::Suppliers, Endpoints::Tag2LayoutTemplates, Endpoints::Tag2Layouts, Endpoints::TagGroups, Endpoints::TagLayoutTemplates, Endpoints::TagLayouts, Endpoints::TransferRequestCollections, Endpoints::TransferRequests, Endpoints::TransferTemplates, Endpoints::Transfers, Endpoints::Tube::Purposes, Endpoints::TubeCreations, Endpoints::TubeFromTubeCreations, Endpoints::Tubes, Endpoints::Users, Endpoints::Uuids, Endpoints::VolumeUpdates, Endpoints::Wells, Endpoints::WorkCompletions

Defined Under Namespace

Modules: InstanceBehaviour, ModelBehaviour

Class Method Summary collapse

Methods included from ModelBehaviour

extended, model

Methods included from InstanceBehaviour

extended, instance

Class Method Details

.rootObject


105
106
107
# File 'app/api/core/endpoint/base.rb', line 105

def self.root
  name.sub(/^(::)?Endpoints::/, '').underscore.pluralize
end