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

chore(sdk): update documentation examples #196

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

Notable changes to this project will be documented in this file.

## 2.0.0 (23 December 2023)

### Added

* Added support for OAuth authentication method

### Modified

* Dropped support for legacy API Key and Service account authentication methods

## 1.1.2 (4 September 2020)

### Added
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,23 @@ Python >= 3.8
from lumapps.api import BaseClient

token = "MY TOKEN"
client = BaseClient(token=token)
base_client = BaseClient(
api_info={"base_url": "https://your-cell.api.lumapps.com"}, # e.g. "https://go-cell-001.api.lumapps.com"
auth_info={
"client_id": "your-client-id",
"client_secret": "your-client-secret"
}
)

api = base_client.get_new_client_as("[email protected]", customer_id="your-organization-id")
```

3. Make your first API call

Let's display the full name of a registered user in lumapps

```python
user_email = "YOUR EMAIL"
usr = api.get_call("user/get", email=user_email)
usr = api.get_call("user/get", email="[email protected]")
print("Hello {}".format(usr["fullName"]))
```

Expand All @@ -71,7 +78,7 @@ The SDK documentation is available [here](https://lumapps.github.io/lumapps-sdk/

## Code convention

Docstring in PEP 484 type annotations format adapted to python 2.7 using comments.
Docstring in PEP 484 type annotations format adapted to python 3.x using comments.

## How to get help, contribute, or provide feedback

Expand Down
11 changes: 9 additions & 2 deletions docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@ Be sure to target the right lumapps environment. Refer to the [environment docum

## Using a regular token

To authenticate with a regular, short lived token, instanciate the sdk like so:
To authenticate with a regular, short lived accesss token, instantiate the sdk like so:

```python
from lumapps.api.base_client import BaseClient

client = BaseClient(api_info, token="<your_token>")
client = base_client = BaseClient(
api_info={"base_url": "https://your-cell.api.lumapps.com"},
auth_info={
"client_id": "your-client-id",
"client_secret": "your-client-secret"
}
)
```

## Using an application
Expand All @@ -33,6 +39,7 @@ my_application = {
}
customer_id = "<your_customer_id>"
user_to_authenticate_on_behalf_of = "<user_email>"
api_info={"base_url": "https://your-cell.api.lumapps.com"} # e.g. https://go-cell-001.api.lumapps.com

client = BaseClient(
api_info, auth_info=my_application
Expand Down
1 change: 0 additions & 1 deletion docs/base_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
- "iter_call"
- "get_call"
- "get_new_client_as"
- "get_new_client_as_using_dwd"
8 changes: 7 additions & 1 deletion docs/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,11 @@ It should be under the following format: `https://XX-cell-YYY.api.lumapps.com`.
```python
from lumapps.api.client import BaseClient

client = BaseClient({"base_url": <my_base_url>})
client = BaseClient(
api_info={"base_url": "https://go-cell-001.api.lumapps.com"},
auth_info={
"client_id": "your-client-id",
"client_secret": "your-client-secret"
}
)
```
23 changes: 19 additions & 4 deletions docs/guides/base_client_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ For instance if you want to get a particular user identified by his email you'll

```python
from lumapps.api.base_client import BaseClient
client = BaseClient(token="<your_token>")

email = "<the_user_email>"
user = client.get_call("user/get", email=email)
base_client = BaseClient(
api_info={"base_url": "https://go-cell-001.api.lumapps.com"},
auth_info={
"client_id": "your-client-id",
"client_secret": "your-client-secret"
}
)
api = base_client.get_new_client_as("[email protected]", customer_id="your-organization-id")

user = client.get_call("user/get", email="[email protected]")
```
## Adding request body parameters

Expand All @@ -36,7 +43,15 @@ For instance if you want to create a particular user:

```python
from lumapps.api.base_client import BaseClient
client = BaseClient(token="<your_token>")

base_client = BaseClient(
api_info={"base_url": "https://go-cell-001.api.lumapps.com"},
auth_info={
"client_id": "your-client-id",
"client_secret": "your-client-secret"
}
)
api = base_client.get_new_client_as("[email protected]", customer_id="your-organization-id")

body = {
"email": "[email protected]",
Expand Down
7 changes: 1 addition & 6 deletions docs/guides/comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ For more details see [api.lumapps.com](https://apiv1.lumapps.com/#operation/Comm
## Comment get

```python
from lumapps.api.base_client import BaseClient
client = BaseClient(token="<your_token>")

comment = client.get_call(
"comment/get", uid="YOUR_COMMENT_ID"
)
Expand Down Expand Up @@ -50,9 +47,6 @@ comment = {
or update properties from one you just got using the api.

```python
from lumapps.api.base_client import BaseClient
client = BaseClient(token="<your_token>")

comment = client.get_call(
"comment/get", uid="YOUR_COMMENT_ID"
)
Expand All @@ -62,5 +56,6 @@ comment["title"] = {"fr": "New title"}
comment = client.get_call(
"comment/save", body=comment
)
```

For more details see [the api documentation](https://apiv1.lumapps.com)
6 changes: 0 additions & 6 deletions docs/guides/community.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
## Community list

```python
from lumapps.api.base_client import BaseClient
client = BaseClient(token="<your_token>")

body = {
"instanceId": "YOUR_INSTANCE_ID",
"lang": "fr",
Expand All @@ -22,9 +19,6 @@ For more details see [the api documentation](https://apiv1.lumapps.com/#operatio
## Community get

```python
from lumapps.api.base_client import BaseClient
client = BaseClient(token="<your_token>")

community = client.get_call(
"community/get", uid="YOUR_COMMUNITY_ID"
)
Expand Down
9 changes: 0 additions & 9 deletions docs/guides/community_posts.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
## Post list

```python
from lumapps.api.base_client import BaseClient
client = BaseClient(token="<your_token>")

body = {
"contentId": community_id,
"lang": "",
Expand All @@ -23,9 +20,6 @@ For more details see [the api documentation](https://apiv1.lumapps.com/#operatio
## Post get

```python
from lumapps.api.base_client import BaseClient
client = BaseClient(token="<your_token>")

post = client.get_call(
"community/post/get", uid="YOUR_POST_ID"
)
Expand Down Expand Up @@ -56,9 +50,6 @@ post = {
or update properties from one you just got using the api.

```python
from lumapps.api.base_client import BaseClient
client = BaseClient(token="<your_token>")

post = client.get_call(
"community/post/get", uid="YOUR_POST_ID"
)
Expand Down
6 changes: 1 addition & 5 deletions docs/guides/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ The `lang` parameter is mandatory for this call.
You can add more filters, see [apidoc](https://api.lumapps.com/docs/output/_schemas/servercontentcontentmessagescontentlistrequest)

```python
from lumapps.api.base_client import BaseClient
client = BaseClient(token="<your_token>")

contents = client.get_call("content/list", body={"lang":"en"})
```

Expand Down Expand Up @@ -178,9 +175,8 @@ The `properties>id` (or class) could be used to simplify widget access from code
To help you work on widget some helpers are available in the lumapps sdk

```python
from lumapps.api.base_client import BaseClientfrom lumapps.api.helpers import widgets as widgets_helper
from lumapps.api.helpers import widgets as widgets_helper

client = BaseClient(token="<your_token>")
content = client.get_call("content/get") # get the lumapps content

# return the first found widget with the property widgetType equal to video
Expand Down
3 changes: 0 additions & 3 deletions docs/guides/content_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ This example as 2 rows with each one containing 2 columns.

```python
import copy
from lumapps.api.base_client import BaseClient
client = BaseClient(token="{your_token}")

template_id = "{your_template_id}"
template = client.get_call("template/get", uid=template_id)

Expand Down
6 changes: 0 additions & 6 deletions docs/guides/groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ client.get_call("feedtype/list", instance="12345") # one one instance
## Create a group

```python
from lumapps.api.base_client import BaseClient
client = BaseClient(token="<your_token>")

group = {
"customer": "123456789",
"name": "Display name",
Expand Down Expand Up @@ -109,9 +106,6 @@ feed_members = api.get_call("user/list", feeds=['1345'])
## update members of a group

```python
from lumapps.api.base_client import BaseClient
client = BaseClient(token="<your_token>")

body = {
"feed": "1234",
"addedUsers":
Expand Down
3 changes: 0 additions & 3 deletions docs/guides/media.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
We provide a helper method to ease the process of uploading a media

```python
from lumapps.api.base_client import BaseClient
client = BaseClient(token=<you_token>)

uploaded_media = client.upload_call("path_to_my_file")
```

Expand Down
9 changes: 0 additions & 9 deletions docs/guides/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
## Metadata kind

```python
from lumapps.api.base_client import BaseClient
client = BaseClient(token="<your_token>")

metadata_kind = client.get_call("metadata/list", body={
"emptyParent": "true",
"lang": "fr",
Expand Down Expand Up @@ -35,9 +32,6 @@ print(metadata_kind)
## Metadata values

```python
from lumapps.api.base_client import BaseClient
client = BaseClient(token="<your_token>")

metadata_values = client.get_call('metadata', 'list', body={
"familyId": "6298100337213440", # <- /!\
"parent": "6298100337213440", # <- /!\
Expand Down Expand Up @@ -129,9 +123,6 @@ Code sample
```python
import time

from lumapps.api.base_client import BaseClient
client = BaseClient(token="<your_token>")

# Get metadata list
metadata_list = client.get_call(
"metadata/list",
Expand Down
9 changes: 0 additions & 9 deletions docs/guides/roles.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ You can easly create, modify, delete or list roles on your instance with the sdk
## __List roles__

```python
from lumapps.api.base_client import BaseClient
client = BaseClient(token="<your_token>")

roles = client.get_call("role/list", instance=site_id)
```

Expand All @@ -16,9 +13,6 @@ roles = client.get_call("role/list", instance=site_id)
To create a role you need to create an object like the following one

```python
from lumapps.api.base_client import BaseClient
client = BaseClient(token="<your_token>")

my_role = {
"authorizations": authorizations,
"description": {"fr": "Ma description en francais"},
Expand Down Expand Up @@ -88,9 +82,6 @@ To update a role the recommanded way is the following:
3. re-save it.

```python
from lumapps.api.base_client import BaseClient
client = BaseClient(token="<your_token>")

# Get the role
role = client.get_call("role/get", uid=role_uid)

Expand Down
Loading
Loading