Skip to content

Commit 86549d3

Browse files
authored
RSDK-12349 - remove location secret connection code (#1020)
1 parent a09e916 commit 86549d3

File tree

6 files changed

+95
-102
lines changed

6 files changed

+95
-102
lines changed

.github/workflows/license_finder.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ jobs:
1414
timeout-minutes: 30
1515

1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v5
1818

1919
- name: Install uv
20-
uses: astral-sh/setup-uv@v3
20+
uses: astral-sh/setup-uv@v7
21+
with:
22+
python-version: "3.13"
2123

2224
- name: Setup Python
2325
run: |

src/viam/app/app_client.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -540,22 +540,19 @@ async def main():
540540
For more information, see `Fleet Management API <https://docs.viam.com/dev/reference/apis/fleet/>`_.
541541
"""
542542

543-
def __init__(self, channel: Channel, metadata: Mapping[str, str], location_id: Optional[str] = None):
543+
def __init__(self, channel: Channel, metadata: Mapping[str, str]):
544544
"""Create an `AppClient` that maintains a connection to app.
545545
546546
Args:
547547
channel (grpclib.client.Channel): connection to app.
548548
metadata (Mapping[str, str]): Required authorization token to send requests to app.
549-
location_id (Optional[str]): Default location ID.
550549
"""
551550
self._metadata = metadata
552551
self._app_client = AppServiceStub(channel)
553-
self._location_id = location_id
554552
self._channel = channel
555553

556554
_app_client: AppServiceStub
557555
_metadata: Mapping[str, str]
558-
_location_id: Optional[str]
559556
_channel: Channel
560557
_organization_id: Optional[str] = None
561558

@@ -1016,7 +1013,7 @@ async def get_location(self, location_id: Optional[str] = None) -> Location:
10161013
10171014
For more information, see `Fleet Management API <https://docs.viam.com/dev/reference/apis/fleet/#getlocation>`_.
10181015
"""
1019-
request = GetLocationRequest(location_id=location_id if location_id else self._location_id if self._location_id else "")
1016+
request = GetLocationRequest(location_id=location_id if location_id else "")
10201017
response: GetLocationResponse = await self._app_client.GetLocation(request, metadata=self._metadata)
10211018
return response.location
10221019

@@ -1155,7 +1152,7 @@ async def location_auth(self, location_id: Optional[str] = None) -> LocationAuth
11551152
11561153
For more information, see `Fleet Management API <https://docs.viam.com/dev/reference/apis/fleet/#locationauth>`_.
11571154
"""
1158-
request = LocationAuthRequest(location_id=location_id if location_id else self._location_id if self._location_id else "")
1155+
request = LocationAuthRequest(location_id=location_id if location_id else "")
11591156
response: LocationAuthResponse = await self._app_client.LocationAuth(request, metadata=self._metadata)
11601157
return response.auth
11611158

@@ -1179,7 +1176,7 @@ async def create_location_secret(self, location_id: Optional[str] = None) -> Loc
11791176
11801177
For more information, see `Fleet Management API <https://docs.viam.com/dev/reference/apis/fleet/#createlocationsecret>`_.
11811178
"""
1182-
request = CreateLocationSecretRequest(location_id=location_id if location_id else self._location_id if self._location_id else "")
1179+
request = CreateLocationSecretRequest(location_id=location_id if location_id else "")
11831180
response: CreateLocationSecretResponse = await self._app_client.CreateLocationSecret(request, metadata=self._metadata)
11841181
return response.auth
11851182

@@ -1204,7 +1201,7 @@ async def delete_location_secret(self, secret_id: str, location_id: Optional[str
12041201
For more information, see `Fleet Management API <https://docs.viam.com/dev/reference/apis/fleet/#deletelocationsecret>`_.
12051202
"""
12061203
request = DeleteLocationSecretRequest(
1207-
location_id=location_id if location_id else self._location_id if self._location_id else "", secret_id=secret_id
1204+
location_id=location_id if location_id else "", secret_id=secret_id
12081205
)
12091206
await self._app_client.DeleteLocationSecret(request, metadata=self._metadata)
12101207

@@ -1653,7 +1650,7 @@ async def list_robots(self, location_id: Optional[str] = None) -> List[Robot]:
16531650
16541651
For more information, see `Fleet Management API <https://docs.viam.com/dev/reference/apis/fleet/#listrobots>`_.
16551652
"""
1656-
request = ListRobotsRequest(location_id=location_id if location_id else self._location_id if self._location_id else "")
1653+
request = ListRobotsRequest(location_id=location_id if location_id else "")
16571654
response: ListRobotsResponse = await self._app_client.ListRobots(request, metadata=self._metadata)
16581655
return list(response.robots)
16591656

@@ -1677,7 +1674,7 @@ async def new_robot(self, name: str, location_id: Optional[str] = None) -> str:
16771674
16781675
For more information, see `Fleet Management API <https://docs.viam.com/dev/reference/apis/fleet/#newrobot>`_.
16791676
"""
1680-
request = NewRobotRequest(location=location_id if location_id else self._location_id if self._location_id else "", name=name)
1677+
request = NewRobotRequest(location=location_id if location_id else "", name=name)
16811678
response: NewRobotResponse = await self._app_client.NewRobot(request, metadata=self._metadata)
16821679
return response.id
16831680

@@ -1708,7 +1705,7 @@ async def update_robot(self, robot_id: str, name: str, location_id: Optional[str
17081705
For more information, see `Fleet Management API <https://docs.viam.com/dev/reference/apis/fleet/#updaterobot>`_.
17091706
"""
17101707
request = UpdateRobotRequest(
1711-
id=robot_id, name=name, location=location_id if location_id else self._location_id if self._location_id else ""
1708+
id=robot_id, name=name, location=location_id if location_id else ""
17121709
)
17131710
response: UpdateRobotResponse = await self._app_client.UpdateRobot(request, metadata=self._metadata)
17141711
return response.robot

src/viam/app/viam_client.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ async def create_from_dial_options(cls, dial_options: DialOptions, app_url: Opti
8585

8686
self = cls()
8787
self._dial_options = dial_options
88-
self._location_id = None
89-
if dial_options.credentials.type == "robot-location-secret":
90-
self._location_id = dial_options.auth_entity.split(".")[1]
9188
if app_url is None:
9289
app_url = "app.viam.com"
9390
self._channel = await _dial_app(app_url)
@@ -98,7 +95,6 @@ async def create_from_dial_options(cls, dial_options: DialOptions, app_url: Opti
9895
_channel: Channel
9996
_metadata: Mapping[str, str]
10097
_closed: bool = False
101-
_location_id: Optional[str]
10298
_dial_options: DialOptions
10399

104100
@property
@@ -140,7 +136,7 @@ async def main():
140136
# Instantiate an AppClient called "fleet" to run fleet management API methods on
141137
fleet = viam_client.app_client
142138
"""
143-
return AppClient(self._channel, self._metadata, self._location_id)
139+
return AppClient(self._channel, self._metadata)
144140

145141
@property
146142
def ml_training_client(self) -> MLTrainingClient:

src/viam/rpc/dial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
class Credentials:
3232
"""Credentials to connect to the machine and app.viam.com."""
3333

34-
type: Union[Literal["robot-location-secret"], Literal["robot-secret"], Literal["api-key"]]
34+
type: Union[Literal["robot-secret"], Literal["api-key"]]
3535
"""The type of credential
3636
"""
3737

0 commit comments

Comments
 (0)