# `Smee.Source`
[🔗](https://github.com/Digital-Identity-Labs/smee/blob/main/lib/smee/source.ex#L1)

Defines sources for metadata, which can then be `Fetch`ed and prodoce Metadata structs. Source structs are the
  usual starting-place for Smee tasks.

 Source structs act as the configuration for metadata creation. They require a URL but various other options can be
   set and their effect will propagate down to Entity records.

# `t`
[🔗](https://github.com/Digital-Identity-Labs/smee/blob/main/lib/smee/source.ex#L16)

```elixir
@type t() :: %Smee.Source{
  auth: nil | keyword(),
  bilateral: boolean(),
  cache: boolean(),
  cert_fingerprint: nil | binary(),
  cert_url: binary(),
  fedid: binary() | atom(),
  id: binary() | atom(),
  label: nil | binary(),
  local: boolean(),
  priority: integer(),
  redirects: integer(),
  retries: integer(),
  strict: boolean(),
  tags: [binary()],
  trustiness: float(),
  type: nil | atom(),
  url: binary()
}
```

# `check`
[🔗](https://github.com/Digital-Identity-Labs/smee/blob/main/lib/smee/source.ex#L115)

```elixir
@spec check(source :: t(), options :: keyword()) :: {:ok, t()} | {:error, binary()}
```

Attempts to validate a source struct, and will return an :ok/:error tuple containing the Source if it passes checks.

# `check!`
[🔗](https://github.com/Digital-Identity-Labs/smee/blob/main/lib/smee/source.ex#L135)

```elixir
@spec check!(source :: t(), options :: keyword()) :: t()
```

Attempts to validate a source struct, and will return the Source if it passes checks, or raise an exception.

# `new`
[🔗](https://github.com/Digital-Identity-Labs/smee/blob/main/lib/smee/source.ex#L88)

```elixir
@spec new(url :: binary(), options :: keyword()) :: t()
```

Creates a new source struct, describing where and how to find metadata.

The only essential parameter is a URL for the metadata. URLs can have `file:`, `http://`, or `https://` schemes.
Bare filesystem paths can also be passed and will be converted to `file:` URLs.

MDQ service clients should be configured with the *base URL* of the service, not the `/entity/` endpoint, and a
 type of :mdq. Alternatively the `Smee.MDQ.source/2` function can be used as a shortcut.

Available options include:

  * type: determines the general type of metadata - :aggregate (the default), :single and :mdq
  * cert_url: location of certificate to use when verifying signed metadata
  * cert_fingerprint: SHA1 fingerprint of the signing certificate
  * cache: should HTTP caching be enabled for downloads. true or false, defaults to true.
  * redirects: maximum number of 302 redirects to follow
  * retries: number of retries to attempt
  * label: a relatively useless label for the metadata
  * priority: integer between 0 and 9, used for comparing metadata
  * trustiness: float between 0.0 and 0.9, for comparing metadata
  * strict: defaults to false. If enabled some stricter checks are enabled
  * fedid - a name or tag for the publishing federation or collection
  * tags - a list of arbitrary tags that you can use for sorting and marking data
  * local - a boolean to indicate local ownership of the metadata (they're *your* services)
  * bilateral - a boolean to indicate that the metadata is not from an external full federation

Where appropriate values from some options are passed down to the metadata and entities derived from a source.

MDQ sources are intended for use with the `Smee.MDQ` API but will also support normal fetch requests.

# `tag`
[🔗](https://github.com/Digital-Identity-Labs/smee/blob/main/lib/smee/source.ex#L158)

```elixir
@spec tag(source :: t(), tags :: list() | nil | binary()) :: t()
```

Tags a source with one or more tags, replacing existing tags.

Tags are arbitrary strings. They will be inherited by metadata and entities derived from this source.

# `tags`
[🔗](https://github.com/Digital-Identity-Labs/smee/blob/main/lib/smee/source.ex#L148)

```elixir
@spec tags(source :: t()) :: [binary()]
```

Returns the tags of the source struct, a list of binary strings

Tags are arbitrary classifiers

---

*Consult [api-reference.md](api-reference.md) for complete listing*
