View Source Smee.Entity (Smee v0.5.0)
Smee
wraps up metadata for individual entities in %Entity{} structs, and the Smee.Entity
module contains
functions that may be useful when working with them.
Many of the functions mirror those in the Smee.Metadata
module - the same actions but on a smaller unit of XML.
Like %Metadata{} structs the XML in entities can be compressed and decompressed, but unlike Metadata structs they have parsed xmerl data in them by default too.
Wherever possible use Entity.update/2
to make changes, do not write to the Entity struct directly. If you must write directly
you can use Entity.update/1
to resync the state of the record.
Summary
Functions
Returns the assurance certification URIs of the entity as a list
Returns an entity that contains parsed XML data, greatly increasing its size but possibly making future processing faster.
Returns a list of entity categories for this entity
Returns a list of supported entity categories
Raises an exception if the entity has expired (based on valid_until datetime), otherwise returns the entity.
Returns a compressed entity, containing gzipped XML. This greatly reduces the size of the entity record.
Returns true if the XML data in an entity has been compressed
Returns a decompressed entity, with plain-text XML data. This makes the struct much larger.
Returns a new %Entity{} struct if passed XML data for an entity and parent %Metadata{}.
Returns true if the entity has expired (based on valid_until datetime)
Returns a suggested filename for the entity.
Returns a suggested filename for the entity in the specified format.
Returns the entityID of the entity struct.
Returns true if the entity has an IdP role.
Returns a new %Entity{} struct if passed XML data.
Returns the priority of the entity as a value between 0 and 9
Returns the Date of registration, if present, or nil.
Returns the URI for the entity's registration authority, if available, or nil.
Returns an entity with parsed XML data removed, greatly reducing its size but possibly making future processing slower.
Returns true if the entity has an SP role.
Tags an entity with one or more tags, replacing existing tags.
Returns the tags of the entity struct, a list of binary strings
Returns the MDQ hashed style entityID of the entity struct.
Returns the trustiness level of the entity as a float between 0.0 and 0.9.
Resyncs the internal state of an %Entity{} struct
Returns an updates %Entity{} struct with new XML, refreshing various parts of the struct correctly.
Raises an exception if the entity has invalid XML, otherwise returns the entity.
Returns a parsed Erlang xmerl
structure representing the entities XML, for use with xmerl
, SweetXML
and other
tools.
Returns the plain-text XML of the entity, whether or not it has been compressed.
Types
@type t() :: %Smee.Entity{ changes: integer(), compressed: boolean(), data: nil | binary(), data_hash: nil | binary(), downloaded_at: nil | DateTime.t(), id: nil | binary(), label: nil | binary(), metadata_uri: nil | binary(), metadata_uri_hash: nil | binary(), modified_at: nil | DateTime.t(), priority: integer(), size: integer(), tags: [binary()], trustiness: float(), uri: nil | binary(), uri_hash: nil | binary(), valid_until: nil | DateTime.t(), xdoc: nil | tuple() }
Functions
Returns the assurance certification URIs of the entity as a list
The most common and useful assurance profile is almost certainly SIRTFI, but many others exist.
Returns an entity that contains parsed XML data, greatly increasing its size but possibly making future processing faster.
Returns a list of entity categories for this entity
Entity categories are official tags indicating that a service fits certain criteria. For instance, Research and Scholarship (indicated with the URI "http://refeds.org/category/research-and-scholarship") shows that a service will behave according to certain rules.
You can see a dump of all entity attributes, including entity categories, using Smee.Extract.list_entity_attrs/1
Returns a list of supported entity categories
Category support is the counterpart of entity categories, indicating that a service will make use of those categories if an entity possesses them.
Raises an exception if the entity has expired (based on valid_until datetime), otherwise returns the entity.
If no valid_until has been set (if it's nil) then the entity will always be returned.
Returns a compressed entity, containing gzipped XML. This greatly reduces the size of the entity record.
Returns true if the XML data in an entity has been compressed
Returns a decompressed entity, with plain-text XML data. This makes the struct much larger.
@spec derive(data :: binary(), metadata :: Smee.Metadata.t(), options :: keyword()) :: t()
Returns a new %Entity{} struct if passed XML data for an entity and parent %Metadata{}.
Defaults values are set using the parent metadata where possible.
You can set or override various parts of the struct by passing options:
- md_uri - a URI that identifies a parent
- downloaded_at - A DateTime to record when the record was downloaded
- modified_at - A DateTime to record when the record was updated upstream
- valid_until - A DateTime to indicate when an entity expires
- priority - An integer between 0 and 9 to show priority
- trustiness - a Float between 0.0 and 0.9 to indicate, well, trustiness.
You won't normally need to do this yourself as entities can be extracted from Smee.Metadata
.
Returns true if the entity has expired (based on valid_until datetime)
If no valid_until has been set (if it's nil) then false will be returned
Returns a suggested filename for the entity.
Returns a suggested filename for the entity in the specified format.
Two formats can be specified: :sha1 and :uri
Returns the entityID of the entity struct.
(This is the same as the URI)
Returns true if the entity has an IdP role.
An entity may have more than one role.
Returns a new %Entity{} struct if passed XML data.
You can set or override various parts of the struct by passing options:
- md_uri - a URI that identifies a parent
- downloaded_at - A DateTime to record when the record was downloaded
- modified_at - A DateTime to record when the record was updated upstream
- valid_until - A DateTime to indicate when an entity expires
- priority - An integer between 0 and 9 to show priority
- trustiness - a Float between 0.0 and 0.9 to indicate, well, trustiness.
You won't normally need to do this yourself as entities can be extracted from Smee.Metadata
.
Returns the priority of the entity as a value between 0 and 9
Returns the Date of registration, if present, or nil.
See registration_authority/1
for more information
Returns the URI for the entity's registration authority, if available, or nil.
Interfederation means that entities may be initially published in a different federation to the one this record is currently published in. The registration authority URI, if present, shows that the entity was officially registered elsewhere.
Returns an entity with parsed XML data removed, greatly reducing its size but possibly making future processing slower.
Returns true if the entity has an SP role.
An entity may have more than one role.
Tags an entity with one or more tags, replacing existing tags.
Tags are arbitrary classifiers, initially inherited from source and metadata
Returns the tags of the entity struct, a list of binary strings
Tags are arbitrary strings, which may be initially inherited from source and metadata
Returns the MDQ hashed style entityID of the entity struct.
(This is the same as the URI)
Returns the trustiness level of the entity as a float between 0.0 and 0.9.
Resyncs the internal state of an %Entity{} struct
If changes have been made using Entity.update/2
then this will not be needed - it's there for when the struct
has been changed directly
Returns an updates %Entity{} struct with new XML, refreshing various parts of the struct correctly.
This should be the only way updated Entities are produced - the raw struct should not be changed directly.
Raises an exception if the entity has invalid XML, otherwise returns the entity.
Returns a parsed Erlang xmerl
structure representing the entities XML, for use with xmerl
, SweetXML
and other
tools.
Returns the plain-text XML of the entity, whether or not it has been compressed.