Skip to content

Commit

Permalink
Merge pull request #45 from neicnordic/feature/WAL-6489
Browse files Browse the repository at this point in the history
[WAL-6489] Update component usage reporting docs
  • Loading branch information
livenson authored Mar 14, 2024
2 parents 0c8ad08 + 196c22d commit 126a719
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions docs/SDK guide/allocation-management-sp.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,34 +243,29 @@ result = client.marketplace_resource_get_team(
A usage of a resource allocation can be submitted by a corresponding service provider.
For this, the following methods are used:

- `get_marketplace_offering` - getting offering with components info.
Arguments:
- `get_marketplace_offering` - getting offering with components info. Arguments:

- **`offering_uuid`** - UUID of an offering

- `marketplace_resource_get_plan_periods` - getting current plan periods for resource allocation. Arguments:

- **`resource_uuid`** - UUID of a resource

- `create_component_usages` - creating or updating components usage for the current plan

- **`plan_period_uuid`** - UUID of a plan period
- `create_component_usages` - creating or updating components usage for the current plan. Arguments:
- **`usages`** - list of `ComponentUsage` instances
- **`resource`** - UUID of a resource

```python
from waldur_client import WaldurClient, ComponentUsage
from waldur_client import ComponentUsage

offering = client.get_marketplace_offering(offering_uuid='<offering-uuid>')
component_types = [component['type'] for component in offering['components']]
plan_periods = client.marketplace_resource_get_plan_periods(resource_uuid='<resource-uuid>')

if len(plan_periods) > 0:
plan_period = plan_periods[0]
component_usages = [ComponentUsage(type=comp_type, amount=10, description='Usage') for comp_type in component_types]

client.create_component_usages(
plan_period_uuid=plan_period['uuid'],
usages=[ComponentUsage(type=comp_type, amount=10, description='Usage') for comp_type in component_types]
)
client.create_component_usages(
usages=component_usages,
resource='<resource-uuid>',
)

result = client.marketplace_resource_get_plan_periods('<resource-uuid>')

Expand Down

0 comments on commit 126a719

Please sign in to comment.