Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs #20

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft

Add docs #20

wants to merge 17 commits into from

Conversation

szakhlypa
Copy link
Collaborator

No description provided.

Signed-off-by: Sergey Zakhlypa <[email protected]>
Signed-off-by: Sergey Zakhlypa <[email protected]>
Signed-off-by: Sergey Zakhlypa <[email protected]>
@coveralls
Copy link

Pull Request Test Coverage Report for Build 9c514c8f0bb208de207b0792d7f8162eb9527c96-PR-20

  • 3 of 3 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 90.506%

Totals Coverage Status
Change from base Build 602e78a22ed45d6731f7d5d4d4f59914a6d60417: 0.0%
Covered Lines: 286
Relevant Lines: 316

💛 - Coveralls

@moduledoc """
Documentation for `Astarte.Client`.
"""
@moduledoc false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's plan to remove this module in a following MR since it's currently useless

Comment on lines +23 to +24
This struct is designed to provide information needed to effectively log and maybe respond
to an error.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> This struct is designed to provide relevant information about the error.

@moduledoc """
Module to configure communication with Astarte AppEngine API.

Most applications would want to use AppEngine to interact with devices, stream and receive data, and oversee their fleet.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oversee their fleet -> interact with the fleet

alias __MODULE__
alias Astarte.Client.Credentials
@doc """
Returns configured `Astarte.Client.AppEngine` struct.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> a configured


@jwt_expiry 5 * 60
This function receives Astarte base API URL and name of the realm alongside authentication options
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

receives the Astarte [...] and the name of [...]

@doc """
Unset a value on a given endpoint path, path is also deleted.

Interface should be an individual server owned property interface and to support unset.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] interface that supports unsets.

It must be a ISO 8601 valid timestamp.
This option is mutually exclusive with `:since`.

* `:to` - query all values up to a certain timestamp.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

up to and including/excluding (not sure what is the actual behaviour tbh)


* `:to` - query all values up to a certain timestamp.
It must be a ISO 8601 valid timestamp.
If `:since` and `:since_after` are not specified first entry date is assumed by default.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we need this line

It must be a ISO 8601 valid timestamp.
If `:since` and `:since_after` are not specified first entry date is assumed by default.

* `:limit` - limit number of retrieved data production entries to `:limit`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

limit the number [...]


* `:query` - list of query params

## Query options
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In all the examples, don't use the atom when using it as value, i.e. remove the : in front.
For example:
query all values since a certain timestamp (all entries where timestamp >= :since
becomes
query all values since a certain timestamp (all entries where timestamp >= since

And so on for all the others


One of `:jwt` and `:private_key` options is required.

* `:jwt` - JWT for Bearer authentication, if used `:private_key` and `:jwt_opts` are ignored
Copy link

@atsetilam atsetilam Oct 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JWT for Bearer authentication ; if used, :private_key and :jwt_opts are ignored


* `:jwt` - JWT for Bearer authentication, if used `:private_key` and `:jwt_opts` are ignored

* `:private_key` - will be used to generate JWT, this option is mutually exclusive
Copy link

@atsetilam atsetilam Oct 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private_key` - will be used to generate JWT ; this option is mutually exclusive

* `:jwt` - JWT for Bearer authentication, if used `:private_key` and `:jwt_opts` are ignored

* `:private_key` - will be used to generate JWT, this option is mutually exclusive
with `:jwt`, if the latter is used, this option will be ignored.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with :jwt . If the latter is used, this option will be ignored.

* `:private_key` - will be used to generate JWT, this option is mutually exclusive
with `:jwt`, if the latter is used, this option will be ignored.

* `:jwt_opts` - will add additional JWT claims to generated JWT, this option is mutually exclusive

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will add additional JWT claims to the generated JWT ; this option is mutually exclusive

with `:jwt`, if the latter is used, this option will be ignored.

* `:jwt_opts` - will add additional JWT claims to generated JWT, this option is mutually exclusive
with `:jwt`, if the latter is used, this option will be ignored.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with :jwt . If the latter is used, this option will be ignored.

Returns a list of interfaces supported by a certain device.

Interfaces that are not reported by the device are not reported here.
If a device stops to advertise a certain interface, it should be retrived from a different API,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a device stops to advertise a certain interface, it should be retrived from a different API .


Interfaces that are not reported by the device are not reported here.
If a device stops to advertise a certain interface, it should be retrived from a different API,
same applies for older versions of a certain interface.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same applies for older versions of a certain interface.

@@ -57,6 +103,18 @@ defmodule Astarte.Client.AppEngine.Devices do
end
end

@doc """
Returns a values snapshot for a given interface without `:path` option, otherwise

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returns a value s snapshot for a given interface without :path option, otherwise

or

Returns a snapshot of values for a given interface without :path option, otherwise

@doc """
Update a property value on a given endpoint path.

Interface should be an individual server owned property interface.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interface should be an individual server owned property interface.

@@ -106,6 +176,36 @@ defmodule Astarte.Client.AppEngine.Devices do
end
end

@doc """
Returns values for a given datastream interface.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It returns values for a given datastream interface.


* `:to` - query all values up to a certain timestamp.
It must be a ISO 8601 valid timestamp.
If `:since` and `:since_after` are not specified first entry date is assumed by default.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] , the specified first entry date is assumed by default.

def append_housekeeping_claim(%Credentials{} = credentials, claim) when is_binary(claim) do
append_claim(credentials, "a_ha", claim)
end

@doc """
Appends claim for Realm Management API

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appends a claim

or

It appends claims

def append_realm_management_claim(%Credentials{} = credentials, claim) when is_binary(claim) do
append_claim(credentials, "a_rma", claim)
end

@doc """
Appends claim for Pairing API

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appends a claim

or

It appends claims

def append_pairing_claim(%Credentials{} = credentials, claim) when is_binary(claim) do
append_claim(credentials, "a_pa", claim)
end

@doc """
Appends claim for AppEngine API

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appends a claim

or

It appends claims

def append_appengine_claim(%Credentials{} = credentials, claim) when is_binary(claim) do
append_claim(credentials, "a_aea", claim)
end

@doc """
Appends claim for Astarte Channels

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appends a claim

or

It appends claims

def append_channels_claim(%Credentials{} = credentials, claim) when is_binary(claim) do
append_claim(credentials, "a_ch", claim)
end

@doc """
Appends claim for Flow API

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appends a claim

or

It appends claims

@@ -144,6 +293,17 @@ defmodule Astarte.Client.Credentials do
%{credentials | claims: updated_claims}
end

@doc """
Sets expiry used to generate expiration time claim.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sets an expiry used to generate an/the expiration time claim.


@jwt_expiry 5 * 60
This function receives Astarte base API URL alongside authentication options
and returns configured `Astarte.Client.Housekeeping` struct.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and returns a configured [...]


@jwt_expiry 5 * 60
This function receives Astarte base API URL alongside authentication options

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function receives the Astarte base API URL [...]

Housekeeping is the equivalent of a superadmin API.
It allows to manage and create realms, perform cluster-wide maintenance actions.
This API is usually accessible only to system administrators, and is not meant for the average user of Astarte,
which should refer to `Astarte.Client.RealmManagement` instead.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

who should refer [...]

This function receives Astarte base API URL alongside authentication options
and returns configured `Astarte.Client.Housekeeping` struct.

## Options
Copy link

@atsetilam atsetilam Oct 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rework punctuation in this section as per above comments.


* `:datacenter_replication_factors` - uses `NetworkTopologyStrategy` replication strategy
and allows to define the number of replicas for each data center.
This option is mutually exclusive with `:replication_factor`,
Copy link

@atsetilam atsetilam Oct 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] with :replication_factor ;


* `:replication_factor` - uses `SimpleStrategy` replication strategy
and allows to define the number of replicas for a single datacenter.
This option is mutually exclusive with `:datacenter_replication_factors`,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[see above]

@enforce_keys [:http_client]
defstruct @enforce_keys

@type t :: %__MODULE__{
http_client: Tesla.Client.t()
}

alias Astarte.Client.Credentials
@doc """
Returns configured `Astarte.Client.Pairing` struct.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returns a configured [...]

@@ -110,6 +147,10 @@ defmodule Astarte.Client.Housekeeping.Realms do
end
end

@doc """
Returns a realm's configuration.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


@jwt_expiry 5 * 60
This function receives Astarte base API URL and name of the realm alongside authentication options

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

receives the Astarte [...] and the name of the Realm


@jwt_expiry 5 * 60
This function receives Astarte base API URL and name of the realm alongside authentication options
and returns configured `Astarte.Client.Pairing` struct.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and returns a configured [...]

This function receives Astarte base API URL and name of the realm alongside authentication options
and returns configured `Astarte.Client.Pairing` struct.

## Options
Copy link

@atsetilam atsetilam Oct 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rework punctuation in this section as per above comments.

@doc """
Register a device, obtaining its credentials secret.

The registration can be repeated as long as the device didn't request any credentials.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would avoid contractions.

[...] the device did not request [...]

@doc """
Unregister a device.

This makes it possible to register it again, even if it already has requested its credentials.
Copy link

@atsetilam atsetilam Oct 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows registering the device again, even if it has already requested its credentials.

alias __MODULE__
alias Astarte.Client.Credentials
@doc """
Returns configured `Astarte.Client.RealmManagement` struct.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returns a configured [...]


@jwt_expiry 5 * 60
This function receives Astarte base API URL and name of the realm alongside authentication options

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

receives the Astarte [...] and the name of the Realm


@jwt_expiry 5 * 60
This function receives Astarte base API URL and name of the realm alongside authentication options
and returns configured `Astarte.Client.RealmManagement` struct.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and returns a configured [...]

This function receives Astarte base API URL and name of the realm alongside authentication options
and returns configured `Astarte.Client.RealmManagement` struct.

## Options

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rework punctuation in this section as per above comments.

@@ -32,6 +48,15 @@ defmodule Astarte.Client.RealmManagement.Interfaces do
end
end

@doc """
Returns the list of all major versions for given interface.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[...] for a given interface.

Update an existing interface.

Replaces an existing interface with a given major version with a new one
(that must have same major version and a higher minor version).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(that must have the same major version [...]

alias Astarte.Client.{APIError, RealmManagement}

@doc """
Returns the auth configuration of the realm.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalise Realm.

@@ -32,6 +41,10 @@ defmodule Astarte.Client.RealmManagement.RealmConfig do
end
end

@doc """
Installs an auth configuration for the realm.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalise Realm.

alias Astarte.Client.{APIError, RealmManagement}

@doc """
Returns the list of all installed triggers.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all the installed triggers.

@doc """
Create a new trigger using provided configuration.

Trigger validation is performed before installation, if trigger configuration is not valid or
Copy link

@atsetilam atsetilam Oct 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trigger validation is performed before installation ; if trigger

Create a new trigger using provided configuration.

Trigger validation is performed before installation, if trigger configuration is not valid or
a trigger with the same name already exists an error is reported.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a trigger with the same name already exists , an error is reported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants