Aura.Packages (Aura v0.9.1)
View SourceService module for interacting with Hex Packages
📖 Resources
- 💬 Contact the maintainer (he's happy to help!)
Summary
Functions
Adds a new owner to the list of package owners
Grabs a package given its name
Grabs a single package owner by their username
Grabs all owners of a given package
Removes an existing owner from the list of package owners
Streams Aura.Model.HexAuditLog
, scoped to a package
Grabs a stream of packages, given optional criteria
Functions
@spec add_package_owner( package_name :: Aura.Common.package_name(), owner_email :: Aura.Common.email(), opts :: list() ) :: :ok | {:error, any()}
Adds a new owner to the list of package owners
🏷️ Params
- package_name ::
Aura.Common.package_name/0
- owner_email ::
Aura.Common.email/0
- opts :: option parameters used to modify requests
⤵️ Returns
✅ On Success
:ok
❌ On Failure
{:error, (some failure)}
@spec get_package(name :: Aura.Common.package_name(), opts :: list()) :: {:ok, Aura.Model.HexPackage.t()} | {:error, any()}
Grabs a package given its name
🏷️ Params
- package_name ::
Aura.Common.package_name/0
- opts :: option parameters used to modify requests
⤵️ Returns
✅ On Success
{:ok, %HexPackage{}}
❌ On Failure
{:error, (some failure)}
💻 Examples
iex> alias Aura.Packages
iex> {:ok, pkg} = Packages.get_package("decimal", repo_url: "http://localhost:4000/api")
iex> pkg.name
"decimal"
@spec get_package_owner( package_name :: Aura.Common.package_name(), username :: Aura.Common.username(), opts :: list() ) :: {:ok, Aura.Model.HexPackageOwner.t()} | {:error, any()}
Grabs a single package owner by their username
🏷️ Params
- package_name ::
Aura.Common.package_name/0
- username ::
Aura.Common.username/0
- opts :: option parameters used to modify requests
⤵️ Returns
✅ On Success
{:ok, %HexPackageOwner{}}
❌ On Failure
{:error, (some failure)}
💻 Examples
iex> alias Aura.Packages
iex> {:ok, owner} = Packages.get_package_owner("decimal", "eric", repo_url: "http://localhost:4000/api")
iex> owner.email
"eric@example.com"
@spec list_package_owners(name :: Aura.Common.package_name(), opts :: list()) :: {:ok, [Aura.Model.HexPackageOwner.t()]} | {:error, any()}
Grabs all owners of a given package
🏷️ Params
- name ::
Aura.Common.package_name/0
- opts :: option parameters used to modify requests
⤵️ Returns
✅ On Success
{:ok, [%HexPackageOwner{}...]}
❌ On Failure
{:error, (some failure)}
💻 Examples
iex> alias Aura.Packages
iex> {:ok, [owner | _]} =
...> Packages.list_package_owners("decimal", repo_url: "http://localhost:4000/api")
iex> owner.email
"eric@example.com"
@spec remove_package_owner( package_name :: Aura.Common.package_name(), owner_email :: Aura.Common.email(), opts :: list() ) :: :ok | {:error, any()}
Removes an existing owner from the list of package owners
🏷️ Params
- package_name ::
Aura.Common.package_name/0
- owner_email ::
Aura.Common.email/0
- opts :: option parameters used to modify requests
⤵️ Returns
✅ On Success
:ok
❌ On Failure
{:error, (some failure)}
@spec stream_audit_logs(package_name :: Aura.Common.package_name(), opts :: list()) :: Enumerable.t()
Streams Aura.Model.HexAuditLog
, scoped to a package
🏷️ Params
- package_name ::
Aura.Common.package_name/0
- opts :: option parameters used to modify requests
⤵️ Returns
✅ On Success
Stream.resource/3
💻 Examples
iex> alias Aura.Packages
iex> audit_logs = Packages.stream_audit_logs("decimal", repo_url: "http://localhost:4000/api")
iex> _actions = Enum.map(audit_logs, fn audit_log -> audit_log.action end)
@spec stream_packages(opts :: list()) :: Enumerable.t()
Grabs a stream of packages, given optional criteria
🏷️ Params
- opts :: option parameters used to modify requests
⤵️ Returns
✅ On Success
Stream.resource/3
💻 Examples
# request packages,
# from the local test instance
# scoped to the repo "hexpm"
# starting with page 2
# sorted by total downloads
iex> alias Aura.Packages
iex> packages = Packages.stream_packages(
...> repo_url: "http://localhost:4000/api",
...> repo: "hexpm",
...> page: 2,
...> sort: :total_downloads)
iex> Enum.empty?(packages)
false