| PUT | /api/importdata |
|---|
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ImportResult:
total_rows: int = 0
total_added: int = 0
total_updated: int = 0
succesfull_rows: int = 0
error_rows: int = 0
errors: Optional[List[str]] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ImportField:
name: Optional[str] = None
value: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Row:
fields: Optional[List[ImportField]] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class FixedValue:
name: Optional[str] = None
value: Optional[str] = None
# @Api(Description="Import entity data into DigiOffice (v1)")
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ImportData:
"""
Import entity data into DigiOffice (v1)
"""
# @ApiMember(Description="Entityname in which the data will be imported", IsRequired=true)
entity_type: Optional[str] = None
"""
Entityname in which the data will be imported
"""
# @ApiMember(Description="Reports errors with a reference to this field (for example ID)")
error_field: Optional[str] = None
"""
Reports errors with a reference to this field (for example ID)
"""
# @ApiMember(Description="Should import continue on errors? (Default true)")
continue_on_error: bool = False
"""
Should import continue on errors? (Default true)
"""
# @ApiMember(Description="Rows to be imported", IsRequired=true)
rows: List[Row] = field(default_factory=list)
"""
Rows to be imported
"""
# @ApiMember(Description="Additional values to be imported on every row")
fixed_values: Optional[List[FixedValue]] = None
"""
Additional values to be imported on every row
"""
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
PUT /api/importdata HTTP/1.1
Host: test-do-services.klokgroep.nl
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
EntityType: String,
ErrorField: String,
ContinueOnError: False,
Rows:
[
{
Fields:
[
{
Name: String,
Value: String
}
]
}
],
FixedValues:
[
{
Name: String,
Value: String
}
]
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
TotalRows: 0,
TotalAdded: 0,
TotalUpdated: 0,
SuccesfullRows: 0,
ErrorRows: 0,
Errors:
[
String
]
}