Metadata-Version: 2.1
Name: dapla-suv-tools
Version: 0.1.34
Summary: 
Author: Anders Hagen
Author-email: nhk@ssb.no
Requires-Python: >=3.10,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: dapla-toolbelt (>=3.0.0,<4.0.0)
Requires-Dist: requests (>=2.31.0,<3.0.0)
Requires-Dist: ssb-altinn3-util (>=0.0.55,<0.0.56)
Description-Content-Type: text/markdown

# Dapla Suv Tools
A collection of tools for integrating with the SUV-platform

### Install `dapla-suv-tools` from PyPI

```python
pip install dapla-suv-tools
```

### Initialize a client using `SuvClient`

```python
from dapla_suv_tools.suv_client import SuvClient

client = SuvClient()
```

### Setup pagination using `PaginationInfo`

```python
from dapla_suv_tools.pagination import PaginationInfo

p_info = PaginationInfo(page=1, size=5)
```

### Example 1: fetch skjema by id 

```python
from dapla_suv_tools.suv_client import SuvClient

client = SuvClient()

x = client.get_skjema_by_id(skjema_id=116)

print(x)
```

### Example 2: fetch skjema's with PaginationInfo

```python
from dapla_suv_tools.suv_client import SuvClient
from dapla_suv_tools.pagination import PaginationInfo

client = SuvClient()
p_info = PaginationInfo(page=1, size=5)

y = client.get_skjema_by_ra_nummer(
    ra_nummer="RA-5566", max_results=0, latest_only=False, pagination_info=p_info
)

print(y)
```

### Function `get_skjema_by_ra_nummer`

```python
output = client.get_skjema_by_ra_nummer(ra_nummer="RA-5566", max_results=0, latest_only=False)
print(output)
```

**Parameters:**


- `ra_number` (str): Skjema's RA-number.
- `max_results` (int, optional): Maximum number of results int the result set.  A value of 0 will get ALL results. Default is 0.
- `latest_only` (bool, optional): A boolean flag to trigger a special condition. Default is 'False'.
- `pagination_info` (PaginationInfo, optional): An object holding pagination metadata. Default is 'None'.

**Returns:**  
- `dict`: A list of skjema json objects matching the RA-number





### Function `get_periode_by_id`

```python
output = client.get_periode_by_id(periode_id=123)
print(output)
```

**Parameters:**

- `periode_id` (int): The ID of the period to retrieve.
- `context` (SuvOperationContext): Operation context for logging and error handling. This is injected by the underlying pipeline.  Adding a custom context will result in an error

**Returns:**  
- `OperationResult`: An object containing the period information if found, or an error message if the retrieval fails.





### Function `get_perioder_by_skjema_id`

```python
output = client.get_perioder_by_skjema_id(skjema_id=123,periode_type="KVRT", periode_aar=2023)
print(output)
```

**Parameters:**

- `skjema_id` (int): The skjema_id of the period to retrieve.
- `periode_type` (Optional[str]): The type of the period to filter by. If None, periods of any type will be retrieved.
- `periode_nr` (Optional[int]): The number of the period to filter by. If None, periods of any number will be retrieved.
- `periode_aar` (Optional[int]): The year of the period to filter by. If None, periods of any year will be retrieved.
- `delreg_nr` (Optional[int]): The delreg_nr of the period to filter by. If None, periods of any delreg_nr will be retrieved.
- `enhet_type` (Optional[int]): The enhet_type of the period to filter by. If None, periods of any enhet_type will be retrieved.
- `max_results` (int): Maximum number of results in the result set. A value of 0 will get ALL results. Defaults to 0
- `latest_only` (bool): A boolean flag to trigger a special condition. A True value will retrieve the latest periode added. Defaults to False.
- `pagination_info` (Optional[int]): An object holding pagination metadata. Defaults to None. 
- `context` (SuvOperationContext): Operation context for logging and error handling. This is injected by the underlying pipeline.  Adding a custom context will result in an error

**Returns:**  
- `OperationResult`: An object containing the period information if found, or an error message if the retrieval fails.




### Function `update_periode_by_id`

```python
output = client.update_periode_by_id(
        periode_id=456, vis_oppgavebyrde=True
    )
print(output)
```

**Parameters:**

- `periode_id` (int): The ID of the period to update.
- `periode_dato` (Optional[date]): Date for the period. If None, the existing date will be used.
- `delreg_nr` (Optional[int]): delreg_nr. If None, the existing number will be used.
- `enhet_type` (Optional[str]): enhet_type. If None, the existing type will be used.
- `vis_oppgavebyrde` (Optional[bool]): A boolean flag to indicate visibility of "oppgavebyrde". Defaults to None.
- `vis_brukeropplevelse` (Optional[bool]): A boolean flag to indicate visibility of "brukeropplevelse". Defaults to None.
- `har_skjemadata` (Optional[bool]): A boolean flag to indicate the presence of schema data. Defaults to None.
- `journalnummer` (Optional[str]): Journal number. If None, the existing number will be used.
- `context` (SuvOperationContext): Operation context for logging and error handling. This is injected by the underlying pipeline.  Adding a custom context will result in an error

**Returns:**  
- `OperationResult`: An object containing the updated period information, or an error message if the update fails.



### Function `update_periode_by_skjema_id`

```python
output = client.update_periode_by_skjema_id(skjema_id=456, periode_type="KVRT", periode_aar=2023, periode_nr=1, delreg_nr=3)
print(output)
```

**Parameters:**

- `skjema_id` (int): The skjema_id of the period to update.
- `periode_type` (str): Periode type of the period to update.
- `periode_aar` (int): Year of the period to update.
- `periode_nr` (int): Periode number of the period to update.
- `periode_dato` (Optional[date]): Date for the period. If None, the existing date will be used.
- `delreg_nr` (Optional[int]): The delreg_nr of the period to filter by. If None, periods of any delreg_nr will be retrieved.
- `enhet_type` (Optional[int]): The enhet_type of the period to filter by. If None, periods of any enhet_type will be retrieved.
- `vis_oppgavebyrde` (Optional[bool]): A boolean flag to indicate visibility of "oppgavebyrde". Defaults to None.
- `vis_brukeropplevelse` (Optional[bool]): A boolean flag to indicate visibility of "brukeropplevelse". Defaults to None.
- `har_skjemadata` (Optional[bool]): A boolean flag to indicate the presence of schema data. Defaults to None.
- `journalnummer` (Optional[str]): Journal number. If None, the existing number will be used.
- `context` (SuvOperationContext): Operation context for logging and error handling. This is injected by the underlying pipeline.  Adding a custom context will result in an error

**Returns:**  
- `OperationResult`: An object containing the updated period information, or an error message if the update fails.



### Function `create_periode`

```python
output = client.create_periode(
        skjema_id=456, periode_type="KVRT", periode_aar=2023, periode_nr=1
    )
print(output)
```

**Parameters:**

- `skjema_id` (int): The skjema_id associated with the new period.
- `periode_type` (Optional[str]): Periode type of the new periode.
- `periode_aar` (Optional[int]): Year of the new periode.
- `periode_nr` (Optional[int]): Periode number of the new periode.
- `periode_dato` (Optional[date]): Date for the period.
- `delreg_nr` (Optional[int]): delreg_nr
- `enhet_type` (Optional[int]): enhet_type
- `vis_oppgavebyrde` (Optional[bool]): A boolean flag to indicate visibility of "oppgavebyrde". Defaults to None.
- `vis_brukeropplevelse` (Optional[bool]): A boolean flag to indicate visibility of "brukeropplevelse". Defaults to None.
- `har_skjemadata` (Optional[bool]): A boolean flag to indicate the presence of schema data. Defaults to None.
- `journalnummer` (Optional[str]): Journal number. If None, the existing number will be used.
- `context` (SuvOperationContext): Operation context for logging and error handling. This is injected by the underlying pipeline.  Adding a custom context will result in an error

**Returns:**  
- `OperationResult`:         An object containing the ID of the created period, or an error message if the creation fails.





### Function `delete_periode`

```python
output = client.delete_periode(periode_id=123)
print(output)
```

**Parameters:**

- `periode_id` (int): The ID of the period to delete.
- `context` (SuvOperationContext): Operation context for logging and error handling. This is injected by the underlying pipeline.  Adding a custom context will result in an error

**Returns:**  
- `OperationResult`: An object containing the result of the deletion operation, or an error message if the deletion fails.

=======
- `ra_number` (str, required): Skjema's RA-number.
- `max_results` (int, optional): Maximum number of results in the result set.  A value of `0` will get ALL results. Defaults to `0`.
- `latest_only` (bool, optional): A boolean flag to trigger a special condition. Defaults to `False`.
- `pagination_info` (PaginationInfo, optional): An object holding pagination metadata. Defaults to `None`.

**Returns:**  
- `dict`: A list of skjema json objects matching the RA-number


