MCPcopy Create free account
hub / github.com/Clarifai/clarifai-python / create_pat

Function create_pat

scripts/key_for_tests.py:70–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68
69
70def create_pat():
71 session_token, user_id = login()
72 os.environ["CLARIFAI_USER_ID"] = user_id
73
74 url = "/users/%s/keys" % user_id
75 payload = {
76 "keys": [
77 {
78 "description": "Auto-created in a CI test run",
79 "scopes": ["All"],
80 "type": "personal_access_token",
81 "apps": [],
82 }
83 ]
84 }
85 data = _request(method="POST", url=url, payload=payload, headers=_auth_headers(session_token))
86 _assert_response_success(data)
87
88 assert "keys" in data, f"Invalid response {data}"
89 assert len(data["keys"]) == 1, f"Invalid response {data}"
90 assert "id" in data["keys"][0], f"Invalid response {data}"
91 pat_id = data["keys"][0]["id"]
92 assert pat_id, f"Invalid response {data}"
93
94 # This print needs to be present so we can read the value in CI.
95 print(pat_id)
96
97
98def run(arguments):

Callers 1

runFunction · 0.85

Calls 4

_requestFunction · 0.85
_auth_headersFunction · 0.85
_assert_response_successFunction · 0.85
loginFunction · 0.70

Tested by

no test coverage detected