From ff3ffe7fcf532a4f978ff99c3067ce2a1c44c514 Mon Sep 17 00:00:00 2001
From: Brett <brett.whynot@gmail.com>
Date: Mon, 25 Mar 2024 20:05:36 +1000
Subject: [PATCH] v0.2.1

---
 setup.py                      |  2 +-
 teslemetry_stream/__init__.py | 36 +++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index 308d189..ca88185 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@
 
 setuptools.setup(
     name="teslemetry_stream",
-    version="0.2.0",
+    version="0.2.1",
     author="Brett Adams",
     author_email="hello@teslemetry.com",
     description="Teslemetry Streaming API library for Python",
diff --git a/teslemetry_stream/__init__.py b/teslemetry_stream/__init__.py
index e76a4ef..4a6b3d7 100644
--- a/teslemetry_stream/__init__.py
+++ b/teslemetry_stream/__init__.py
@@ -96,6 +96,42 @@ async def get_config(self, vin: str | None = None) -> None:
         if not response.get("synced"):
             LOGGER.warning("Vehicle configuration not active")
 
+    async def change_hostname(self, hostname: str, vin: str | None = None) -> dict:
+        """Update Fleet Telemetry hostname"""
+        resp = await self._session.patch(
+            f"https://api.teslemetry.com/api/config/{vin or self.vin}",
+            headers=self._headers,
+            json={"hostname": hostname},
+            raise_for_status=True,
+        )
+        if resp.ok:
+            self.server = hostname
+        return await resp.json()
+
+    async def update_fields(self, fields: dict, vin: str | None = None) -> dict:
+        """Update Fleet Telemetry configuration"""
+        resp = await self._session.patch(
+            f"https://api.teslemetry.com/api/config/{vin or self.vin}",
+            headers=self._headers,
+            json={"fields": fields},
+            raise_for_status=True,
+        )
+        if resp.ok:
+            self.fields = {**self.fields, **fields}
+        return await resp.json()
+
+    async def replace_fields(self, fields: dict, vin: str | None = None) -> dict:
+        """Replace Fleet Telemetry configuration"""
+        resp = await self._session.post(
+            f"https://api.teslemetry.com/api/config/{vin or self.vin}",
+            headers=self._headers,
+            json={"fields": fields},
+            raise_for_status=True,
+        )
+        if resp.ok:
+            self.fields = fields
+        return await resp.json()
+
     @property
     def config(self) -> dict:
         """Return current configuration."""