|
17 | 17 | from arango.cluster import Cluster |
18 | 18 | from arango.collection import StandardCollection |
19 | 19 | from arango.connection import Connection |
| 20 | +from arango.errno import HTTP_NOT_FOUND |
20 | 21 | from arango.exceptions import ( |
21 | 22 | AnalyzerCreateError, |
22 | 23 | AnalyzerDeleteError, |
@@ -1644,12 +1645,14 @@ def has_graph(self, name: str) -> Result[bool]: |
1644 | 1645 | :return: True if graph exists, False otherwise. |
1645 | 1646 | :rtype: bool |
1646 | 1647 | """ |
1647 | | - request = Request(method="get", endpoint="/_api/gharial") |
| 1648 | + request = Request(method="get", endpoint=f"/_api/gharial/{name}") |
1648 | 1649 |
|
1649 | 1650 | def response_handler(resp: Response) -> bool: |
1650 | | - if not resp.is_success: |
1651 | | - raise GraphListError(resp, request) |
1652 | | - return any(name == graph["_key"] for graph in resp.body["graphs"]) |
| 1651 | + if resp.is_success: |
| 1652 | + return True |
| 1653 | + if resp.status_code == HTTP_NOT_FOUND: |
| 1654 | + return False |
| 1655 | + raise GraphListError(resp, request) |
1653 | 1656 |
|
1654 | 1657 | return self._execute(request, response_handler) |
1655 | 1658 |
|
@@ -1699,6 +1702,7 @@ def create_graph( |
1699 | 1702 | replication_factor: Optional[int] = None, |
1700 | 1703 | write_concern: Optional[int] = None, |
1701 | 1704 | satellite_collections: Optional[Sequence[str]] = None, |
| 1705 | + sync: Optional[bool] = None, |
1702 | 1706 | ) -> Result[Graph]: |
1703 | 1707 | """Create a new graph. |
1704 | 1708 |
|
@@ -1753,6 +1757,8 @@ def create_graph( |
1753 | 1757 | element must be a string and a valid collection name. The |
1754 | 1758 | collection type cannot be modified later. |
1755 | 1759 | :type satellite_collections: [str] | None |
| 1760 | + :param sync: Wait until everything is synced to disk. |
| 1761 | + :type sync: bool | None |
1756 | 1762 | :return: Graph API wrapper. |
1757 | 1763 | :rtype: arango.graph.Graph |
1758 | 1764 | :raise arango.exceptions.GraphCreateError: If create fails. |
@@ -1796,7 +1802,16 @@ def create_graph( |
1796 | 1802 | if satellite_collections is not None: # pragma: no cover |
1797 | 1803 | data["options"]["satellites"] = satellite_collections |
1798 | 1804 |
|
1799 | | - request = Request(method="post", endpoint="/_api/gharial", data=data) |
| 1805 | + params: Params = {} |
| 1806 | + if sync is not None: |
| 1807 | + params["waitForSync"] = sync |
| 1808 | + |
| 1809 | + request = Request( |
| 1810 | + method="post", |
| 1811 | + endpoint="/_api/gharial", |
| 1812 | + data=data, |
| 1813 | + params=params, |
| 1814 | + ) |
1800 | 1815 |
|
1801 | 1816 | def response_handler(resp: Response) -> Graph: |
1802 | 1817 | if resp.is_success: |
|
0 commit comments