Skip to content
Open
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
6 changes: 4 additions & 2 deletions cli/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from .exec_command import ExecuteCommandStrategy
from .api_command import ApiCallStrategy
from .exec_command import ExecuteCommandStrategy
from .get_command import GetCommandStrategy
from .refresh_command import RefreshCommandStrategy
from .update_command import UpdateCommandStrategy

# Create a mapping of command names to strategy classes
COMMAND_STRATEGIES = {
"exec": ExecuteCommandStrategy,
"api": ApiCallStrategy,
"get": GetCommandStrategy,
"update": UpdateCommandStrategy
"update": UpdateCommandStrategy,
"refresh": RefreshCommandStrategy,
}
26 changes: 26 additions & 0 deletions cli/commands/refresh_command.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python3
import json

from .api_command import ApiCallStrategy
from .base import PassworkCommand


class RefreshCommandStrategy(ApiCallStrategy):
"""Refresh the access token using the configured refresh token."""

def execute(self, client, args):
args.endpoint = "v1/sessions/refresh"
args.params = json.dumps({"refreshToken": client.refresh_token})
args.method = "POST"
args.field = None
return super().execute(client, args)

@staticmethod
def add_command(subparsers):
params = PassworkCommand.base_params()

parser = subparsers.add_parser(
"refresh", help="Refresh access token using the refresh token"
)
for key, value in params.items():
parser.add_argument(key, **value)