Ash Resource Fragment which is the point of extension for your TMF Place.
BasePlace is the foundation for domain-specific Place kinds.
Include it as a fragment on an Ash.Resource to get common Place attributes, Neo4j graph
wiring, and the Diffo.Provider.Place.Extension DSL.
Diffo.Provider.Place uses BasePlace directly as the out-of-the-box TMF Place resource.
Domain-specific resources extend it for richer domain identity.
Attributes
id— string primary key (required, no default — set by domain).href— optional URI for the place.name— the place name.type— TMF@type. Defaults to:PlaceRef. One of:PlaceRef,:GeographicSite,:GeographicLocation,:GeographicAddress. Whenreferred_typeis present,typemust be:PlaceRef.referred_type— TMF@referredType. One of:GeographicSite,:GeographicLocation,:GeographicAddress. When present, indicates this is a reference to a place of that kind;typemust be:PlaceRef.
Usage
defmodule MyApp.GeographicSite do
use Ash.Resource, fragments: [BasePlace], domain: MyApp.Domain
resource do
description "A Geographic Site"
plural_name :geographic_sites
end
jason do
pick [:id, :href, :name, :referred_type, :type]
compact true
rename referred_type: "@referredType", type: "@type"
end
outstanding do
expect [:id, :name, :referred_type, :type]
end
actions do
create :build do
accept [:id, :href, :name]
change set_attribute(:type, :GeographicSite)
end
end
endDomain-specific attributes
Add Ash attribute declarations directly to your derived resource for any fields beyond the
base set. Those attributes can only be set via actions you declare on the derived resource —
the base create action provided by BasePlace only accepts the base fields (id, href,
name, type, referred_type). Use your domain API to call the derived resource's action:
defmodule MyApp.DataCentre do
use Ash.Resource, fragments: [BasePlace], domain: MyApp.Domain
attributes do
attribute :tier, :integer, public?: true
attribute :power_capacity_kw, :integer, public?: true
end
actions do
create :build do
accept [:id, :href, :name, :tier, :power_capacity_kw]
change set_attribute(:type, :GeographicSite)
end
end
end
# Use the domain API — Provider.create_place!/1 does not know about :tier
MyApp.Domain.create_data_centre!(%{name: "M2", tier: 3, power_capacity_kw: 40_000})TMF type and referred_type
The type and referred_type attributes map to the TMF @type and @referredType JSON
fields via the jason layer. When referred_type is present, type must be :PlaceRef;
otherwise type must not be :PlaceRef.