Skip to content

Commit

Permalink
updated documentation for aliases service
Browse files Browse the repository at this point in the history
  • Loading branch information
Faakhir30 committed Sep 17, 2024
1 parent 120046f commit 266175f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
38 changes: 34 additions & 4 deletions docs/source/endpoints/aliases.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ Response:
:language: http
```

## Adding URL aliases in bulk
## Adding URL aliases in bulk via JSON

You can add multiple URL aliases for multiple pages by sending a `POST` request to the `/@aliases` endpoint on site `root`. **datetime** parameter is optional:
You can add multiple URL aliases for multiple pages by sending a `POST` request to the `/@aliases` endpoint on site `root` using JSON payload. **datetime** parameter is optional:

```{eval-rst}
.. http:example:: curl httpie python-requests
Expand All @@ -85,10 +85,25 @@ Response:
:language: http
```

## Adding URL aliases in bulk via CSV

## Listing all available aliases
You can add multiple URL aliases for multiple pages by sending a `POST` request to the `/@aliases` endpoint on site `root` using CSV file. **datetime** parameter is optional:

To list all aliases, send a `GET` request to the `/@aliases` endpoint on site `root`:
```{eval-rst}
.. http:example:: curl httpie python-requests
:request: ../../../src/plone/restapi/tests/http-examples/aliases_root_add_csv_format.req
```

Response:

```{literalinclude} ../../../src/plone/restapi/tests/http-examples/aliases_root_add_csv_format.resp
:language: http
```


## Listing all available aliases via JSON

To list all aliases in JSON format, send a `GET` request to the `/@aliases` endpoint on site `root`:

```{eval-rst}
.. http:example:: curl httpie python-requests
Expand All @@ -101,6 +116,21 @@ Response:
:language: http
```

## Listing all available aliases via CSV

To download all aliases as a csv file, send a `GET` request to the `/@aliases` endpoint on site `root`:

```{eval-rst}
.. http:example:: curl httpie python-requests
:request: ../../../src/plone/restapi/tests/http-examples/aliases_root_get_csv_format.req
```

Response:

```{literalinclude} ../../../src/plone/restapi/tests/http-examples/aliases_root_get_csv_format.resp
:language: http
```

## Filter aliases

To search for specific aliases, send a `GET` request to the `/@aliases` endpoint on site `root` with a `q` parameter:
Expand Down
4 changes: 2 additions & 2 deletions src/plone/restapi/tests/test_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2122,7 +2122,7 @@ def test_aliases_root_get_csv_format(self):
response = self.api_session.get(url + query)
save_request_and_response_for_docs("aliases_root_get_csv_format", response)

def test_aliases_root_post_csv_format(self):
def test_aliases_root_add_csv_format(self):
url = f"{self.portal.absolute_url()}/@aliases"

content = b"old path,new path,datetime,manual\n/old-page,/front-page,2022/01/01 00:00:00 GMT+0,True\n"
Expand All @@ -2148,7 +2148,7 @@ def test_aliases_root_post_csv_format(self):
}

response = self.api_session.post(url, headers=headers, data=body)
save_request_and_response_for_docs("aliases_root_post_csv_format", response)
save_request_and_response_for_docs("aliases_root_add_csv_format", response)

def test_aliases_root_filter(self):
# Get aliases
Expand Down

0 comments on commit 266175f

Please sign in to comment.