## Resource


A managed resource with properties and class/static methods.


Usage


``` python
Resource(
    name,
    capacity=100,
)
```


## Parameters


`name: str`  
Resource name.

`capacity: int = ``100`  
Maximum capacity.


## Attributes

| Name | Description |
|----|----|
| [available](#available) | Available capacity. |
| [name](#name) | The resource name. |

------------------------------------------------------------------------


#### available


Available capacity.


`available: int`


------------------------------------------------------------------------


#### name


The resource name.


`name: str`


## Methods

| Name | Description |
|----|----|
| [allocate()](#allocate) | Allocate some capacity. |
| [from_dict()](#from_dict) | Create a Resource from a dictionary. |
| [validate_name()](#validate_name) | Check whether a resource name is valid. |

------------------------------------------------------------------------


#### allocate()


Allocate some capacity.


Usage


``` python
allocate(amount)
```


##### Parameters


`amount: int`  
Amount to allocate.


##### Returns


`bool`  
True if allocation succeeded.


------------------------------------------------------------------------


#### from_dict()


Create a Resource from a dictionary.


Usage


``` python
from_dict(data)
```


##### Parameters


`data: dict`  
Dictionary with 'name' and optional 'capacity' keys.


##### Returns


`Resource`  
A new resource instance.


------------------------------------------------------------------------


#### validate_name()


Check whether a resource name is valid.


Usage


``` python
validate_name(name)
```


##### Parameters


`name: str`  
The name to validate.


##### Returns


`bool`  
True if valid.
