{"id":28376226,"url":"https://github.com/phasehq/python-sdk","last_synced_at":"2025-06-26T10:31:06.519Z","repository":{"id":170918029,"uuid":"633793224","full_name":"phasehq/python-sdk","owner":"phasehq","description":"Python SDK for Phase","archived":false,"fork":false,"pushed_at":"2025-04-06T10:46:42.000Z","size":125,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-30T00:05:59.470Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phasehq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-28T09:39:12.000Z","updated_at":"2025-04-06T10:43:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"632b64c9-d222-407d-a0ef-078dc76ecd3a","html_url":"https://github.com/phasehq/python-sdk","commit_stats":null,"previous_names":["phasehq/python-sdk"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/phasehq/python-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phasehq%2Fpython-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phasehq%2Fpython-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phasehq%2Fpython-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phasehq%2Fpython-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phasehq","download_url":"https://codeload.github.com/phasehq/python-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phasehq%2Fpython-sdk/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262047827,"owners_count":23250424,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-30T00:05:59.528Z","updated_at":"2025-06-26T10:31:06.509Z","avatar_url":"https://github.com/phasehq.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python SDK for Phase\n\nSDK to integrate Phase in server-side applications running Python. This SDK allows you to manage secrets securely using the Phase platform.\n\n## Install\n\n```\npip install phase-dev\n```\n\n## Import\n\n```python\nfrom phase import Phase, CreateSecretsOptions, GetAllSecretsOptions, GetSecretOptions, UpdateSecretOptions, DeleteSecretOptions\n```\n\n## Initialize\n\nInitialize the SDK with your host and token:\n\n```python\nphase = Phase(\n    init=False,\n    host='https://your-phase-host.com',\n    pss=PHASE_SERVICE_TOKEN\n\n)\n```\n\n## Usage\n\n### Create Secrets\n\nCreate one or more secrets in a specified application and environment:\n\n```python\ncreate_options = CreateSecretsOptions(\n    env_name=\"Development\",\n    app_name=\"Your App Name\",\n    key_value_pairs=[\n        {\"API_KEY\": \"your-api-key\"},\n        {\"DB_PASSWORD\": \"your-db-password\"}\n    ],\n    secret_path=\"/api\"\n)\nresult = phase.create_secrets(create_options)\nprint(f\"Create secrets result: {result}\")\n```\n\n### Get Secrets\n\nFetch one or more secrets from a specified application and environment:\n\n```python\nget_options = GetAllSecretsOptions(\n    env_name=\"Development\",\n    app_name=\"Your App Name\",\n    tag=\"api\",  # Optional: filter by tag\n    secret_path=\"/api\"  # Optional: specify path\n)\nsecrets = phase.get_all_secrets(get_options)\nfor secret in secrets:\n    print(f\"Key: {secret.key}, Value: {secret.value}\")\n```\n\nTo get a specific secret:\n\n```python\nget_options = GetSecretOptions(\n    env_name=\"Development\",\n    app_name=\"Your App Name\",\n    key_to_find=\"API_KEY\",\n    secret_path=\"/api\"\n)\nsecret = phase.get_secret(get_options)\nif secret:\n    print(f\"Key: {secret.key}, Value: {secret.value}\")\n```\n\n### Update Secrets\n\nUpdate an existing secret in a specified application and environment:\n\n```python\nupdate_options = UpdateSecretOptions(\n    env_name=\"Development\",\n    app_name=\"Your App Name\",\n    key=\"API_KEY\",\n    value=\"new-api-key-value\",\n    secret_path=\"/api\",\n    destination_path=\"/new-api\",  # Optional: move secret to a new path\n    override=False,  # Optional: create a personal override\n    toggle_override=False  # Optional: toggle personal override\n)\nresult = phase.update_secret(update_options)\nprint(f\"Update result: {result}\")\n```\n\n### Delete Secrets\n\nDelete a secret from a specified application and environment:\n\n```python\ndelete_options = DeleteSecretOptions(\n    env_name=\"Development\",\n    app_name=\"Your App Name\",\n    key_to_delete=\"API_KEY\",\n    secret_path=\"/api\"\n)\nresult = phase.delete_secret(delete_options)\nprint(f\"Delete result: {result}\")\n```\n\n## Error Handling\n\nThe SDK methods may raise exceptions for various error conditions. It's recommended to wrap SDK calls in try-except blocks to handle potential errors:\n\n```python\ntry:\n    get_options = GetAllSecretsOptions(env_name=\"Development\", app_name=\"Your App Name\")\n    secrets = phase.get_all_secrets(get_options)\nexcept ValueError as e:\n    print(f\"An error occurred: {e}\")\n```\n\n## Note on Security\n\nNever hard-code sensitive information like tokens or secrets directly in your code. Always use environment variables or secure configuration management to provide these values to your application.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphasehq%2Fpython-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphasehq%2Fpython-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphasehq%2Fpython-sdk/lists"}