# {py:mod}`abr_sdk.keygen`

```{py:module} abr_sdk.keygen
```

```{autodoc2-docstring} abr_sdk.keygen
:allowtitles:
```

## Module Contents

### Classes

````{list-table}
:class: autosummary longtable
:align: left

* - {py:obj}`Failure <abr_sdk.keygen.Failure>`
  - ```{autodoc2-docstring} abr_sdk.keygen.Failure
    :summary:
    ```
* - {py:obj}`_Response <abr_sdk.keygen._Response>`
  - ```{autodoc2-docstring} abr_sdk.keygen._Response
    :summary:
    ```
* - {py:obj}`KeygenClient <abr_sdk.keygen.KeygenClient>`
  - ```{autodoc2-docstring} abr_sdk.keygen.KeygenClient
    :summary:
    ```
````

### Functions

````{list-table}
:class: autosummary longtable
:align: left

* - {py:obj}`unwrap_machine_file_pem <abr_sdk.keygen.unwrap_machine_file_pem>`
  - ```{autodoc2-docstring} abr_sdk.keygen.unwrap_machine_file_pem
    :summary:
    ```
* - {py:obj}`_parse_json_object <abr_sdk.keygen._parse_json_object>`
  - ```{autodoc2-docstring} abr_sdk.keygen._parse_json_object
    :summary:
    ```
* - {py:obj}`_first_error_detail <abr_sdk.keygen._first_error_detail>`
  - ```{autodoc2-docstring} abr_sdk.keygen._first_error_detail
    :summary:
    ```
* - {py:obj}`_resource_id <abr_sdk.keygen._resource_id>`
  - ```{autodoc2-docstring} abr_sdk.keygen._resource_id
    :summary:
    ```
* - {py:obj}`_match_machine_id <abr_sdk.keygen._match_machine_id>`
  - ```{autodoc2-docstring} abr_sdk.keygen._match_machine_id
    :summary:
    ```
````

### Data

````{list-table}
:class: autosummary longtable
:align: left

* - {py:obj}`DEFAULT_API_BASE <abr_sdk.keygen.DEFAULT_API_BASE>`
  - ```{autodoc2-docstring} abr_sdk.keygen.DEFAULT_API_BASE
    :summary:
    ```
* - {py:obj}`_KEYGEN_ACCOUNT_ID <abr_sdk.keygen._KEYGEN_ACCOUNT_ID>`
  - ```{autodoc2-docstring} abr_sdk.keygen._KEYGEN_ACCOUNT_ID
    :summary:
    ```
* - {py:obj}`_CHECKOUT_ALGORITHM <abr_sdk.keygen._CHECKOUT_ALGORITHM>`
  - ```{autodoc2-docstring} abr_sdk.keygen._CHECKOUT_ALGORITHM
    :summary:
    ```
* - {py:obj}`_TIMEOUT_S <abr_sdk.keygen._TIMEOUT_S>`
  - ```{autodoc2-docstring} abr_sdk.keygen._TIMEOUT_S
    :summary:
    ```
* - {py:obj}`_RESUMABLE_VALIDATION_CODES <abr_sdk.keygen._RESUMABLE_VALIDATION_CODES>`
  - ```{autodoc2-docstring} abr_sdk.keygen._RESUMABLE_VALIDATION_CODES
    :summary:
    ```
````

### API

````{py:data} DEFAULT_API_BASE
:canonical: abr_sdk.keygen.DEFAULT_API_BASE
:type: typing.Final[str]
:value: >
   'https://api.keygen.sh/v1'

```{autodoc2-docstring} abr_sdk.keygen.DEFAULT_API_BASE
```

````

````{py:data} _KEYGEN_ACCOUNT_ID
:canonical: abr_sdk.keygen._KEYGEN_ACCOUNT_ID
:type: typing.Final[str]
:value: >
   '721630ba-ba6b-466b-a558-5b74f7f27b17'

```{autodoc2-docstring} abr_sdk.keygen._KEYGEN_ACCOUNT_ID
```

````

````{py:data} _CHECKOUT_ALGORITHM
:canonical: abr_sdk.keygen._CHECKOUT_ALGORITHM
:type: typing.Final[str]
:value: >
   'base64+ed25519'

```{autodoc2-docstring} abr_sdk.keygen._CHECKOUT_ALGORITHM
```

````

````{py:data} _TIMEOUT_S
:canonical: abr_sdk.keygen._TIMEOUT_S
:type: typing.Final[int]
:value: >
   30

```{autodoc2-docstring} abr_sdk.keygen._TIMEOUT_S
```

````

````{py:data} _RESUMABLE_VALIDATION_CODES
:canonical: abr_sdk.keygen._RESUMABLE_VALIDATION_CODES
:type: typing.Final[frozenset[str]]
:value: >
   'frozenset(...)'

```{autodoc2-docstring} abr_sdk.keygen._RESUMABLE_VALIDATION_CODES
```

````

`````{py:class} Failure(*args, **kwds)
:canonical: abr_sdk.keygen.Failure

Bases: {py:obj}`enum.Enum`

```{autodoc2-docstring} abr_sdk.keygen.Failure
```

```{rubric} Initialization
```

```{autodoc2-docstring} abr_sdk.keygen.Failure.__init__
```

````{py:attribute} NETWORK
:canonical: abr_sdk.keygen.Failure.NETWORK
:value: >
   'network'

```{autodoc2-docstring} abr_sdk.keygen.Failure.NETWORK
```

````

````{py:attribute} LICENSE
:canonical: abr_sdk.keygen.Failure.LICENSE
:value: >
   'license'

```{autodoc2-docstring} abr_sdk.keygen.Failure.LICENSE
```

````

````{py:attribute} PROTOCOL
:canonical: abr_sdk.keygen.Failure.PROTOCOL
:value: >
   'protocol'

```{autodoc2-docstring} abr_sdk.keygen.Failure.PROTOCOL
```

````

`````

````{py:exception} ActivationError(kind: abr_sdk.keygen.Failure, message: str)
:canonical: abr_sdk.keygen.ActivationError

Bases: {py:obj}`abr_sdk.exceptions.AbrSdkError`

```{autodoc2-docstring} abr_sdk.keygen.ActivationError
```

```{rubric} Initialization
```

```{autodoc2-docstring} abr_sdk.keygen.ActivationError.__init__
```

````

````{py:function} unwrap_machine_file_pem(pem_text: str) -> bytes
:canonical: abr_sdk.keygen.unwrap_machine_file_pem

```{autodoc2-docstring} abr_sdk.keygen.unwrap_machine_file_pem
```
````

`````{py:class} _Response
:canonical: abr_sdk.keygen._Response

```{autodoc2-docstring} abr_sdk.keygen._Response
```

````{py:attribute} status
:canonical: abr_sdk.keygen._Response.status
:type: int
:value: >
   None

```{autodoc2-docstring} abr_sdk.keygen._Response.status
```

````

````{py:attribute} body
:canonical: abr_sdk.keygen._Response.body
:type: dict[str, typing.Any] | None
:value: >
   None

```{autodoc2-docstring} abr_sdk.keygen._Response.body
```

````

`````

````{py:function} _parse_json_object(raw: bytes) -> dict[str, typing.Any] | None
:canonical: abr_sdk.keygen._parse_json_object

```{autodoc2-docstring} abr_sdk.keygen._parse_json_object
```
````

````{py:function} _first_error_detail(body: collections.abc.Mapping[str, typing.Any] | None) -> str
:canonical: abr_sdk.keygen._first_error_detail

```{autodoc2-docstring} abr_sdk.keygen._first_error_detail
```
````

````{py:function} _resource_id(body: collections.abc.Mapping[str, typing.Any] | None) -> str | None
:canonical: abr_sdk.keygen._resource_id

```{autodoc2-docstring} abr_sdk.keygen._resource_id
```
````

````{py:function} _match_machine_id(rows: object, fingerprint: str) -> str | None
:canonical: abr_sdk.keygen._match_machine_id

```{autodoc2-docstring} abr_sdk.keygen._match_machine_id
```
````

`````{py:class} KeygenClient(key: str, *, env: str = 'production', api_base: str = DEFAULT_API_BASE, timeout_s: int = _TIMEOUT_S)
:canonical: abr_sdk.keygen.KeygenClient

```{autodoc2-docstring} abr_sdk.keygen.KeygenClient
```

```{rubric} Initialization
```

```{autodoc2-docstring} abr_sdk.keygen.KeygenClient.__init__
```

````{py:method} activate(fingerprint: str) -> str
:canonical: abr_sdk.keygen.KeygenClient.activate

```{autodoc2-docstring} abr_sdk.keygen.KeygenClient.activate
```

````

````{py:method} validate_license_key(fingerprint: str = '') -> str
:canonical: abr_sdk.keygen.KeygenClient.validate_license_key

```{autodoc2-docstring} abr_sdk.keygen.KeygenClient.validate_license_key
```

````

````{py:method} get_or_create_machine(license_id: str, fingerprint: str) -> str
:canonical: abr_sdk.keygen.KeygenClient.get_or_create_machine

```{autodoc2-docstring} abr_sdk.keygen.KeygenClient.get_or_create_machine
```

````

````{py:method} checkout_machine_file(machine_id: str) -> str
:canonical: abr_sdk.keygen.KeygenClient.checkout_machine_file

```{autodoc2-docstring} abr_sdk.keygen.KeygenClient.checkout_machine_file
```

````

````{py:method} _create_machine(license_id: str, fingerprint: str) -> str
:canonical: abr_sdk.keygen.KeygenClient._create_machine

```{autodoc2-docstring} abr_sdk.keygen.KeygenClient._create_machine
```

````

````{py:method} _url(path: str, query: collections.abc.Mapping[str, str] | None = None) -> str
:canonical: abr_sdk.keygen.KeygenClient._url

```{autodoc2-docstring} abr_sdk.keygen.KeygenClient._url
```

````

````{py:method} _headers() -> dict[str, str]
:canonical: abr_sdk.keygen.KeygenClient._headers

```{autodoc2-docstring} abr_sdk.keygen.KeygenClient._headers
```

````

````{py:method} _request(method: str, path: str, *, query: collections.abc.Mapping[str, str] | None = None, payload: collections.abc.Mapping[str, typing.Any] | None = None) -> abr_sdk.keygen._Response
:canonical: abr_sdk.keygen.KeygenClient._request

```{autodoc2-docstring} abr_sdk.keygen.KeygenClient._request
```

````

````{py:method} _require_object(resp: abr_sdk.keygen._Response, step: str) -> dict[str, typing.Any]
:canonical: abr_sdk.keygen.KeygenClient._require_object

```{autodoc2-docstring} abr_sdk.keygen.KeygenClient._require_object
```

````

````{py:method} _http_error(resp: abr_sdk.keygen._Response, step: str) -> abr_sdk.keygen.ActivationError
:canonical: abr_sdk.keygen.KeygenClient._http_error

```{autodoc2-docstring} abr_sdk.keygen.KeygenClient._http_error
```

````

`````
