Skip to content
Draft
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
36 changes: 36 additions & 0 deletions lkr/auth/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import typer
from looker_sdk.rtl.auth_token import AccessToken, AuthToken
from pydantic import BaseModel

from lkr.auth.oauth import OAuth2PKCE
from lkr.auth_service import get_auth
Expand Down Expand Up @@ -228,5 +229,40 @@ def list(ctx: typer.Context):
print(table)


class Test(BaseModel):
name: str
age: int


@group.command()
def get(
name: Annotated[str, typer.Option("--name")] = "John",
age: Annotated[int, typer.Option("--age")] = 30,
):
"""
get authentication
"""
test = Test(name=name, age=age)
print(test.model_dump_json())


@group.command()
def set(ctx: typer.Context):
"""
put authentication
"""
import sys

if sys.stdin.isatty():
logger.error(
"This command is intended to be used with a pipe. For example: `lkr auth get | lkr auth set`"
)
raise typer.Exit(1)

read = sys.stdin.read()
test = Test.model_validate_json(read)
print(test.model_dump_json())


if __name__ == "__main__":
group()