Hey Michael,
I think the best way to get this same functionality is to use the SymXchange File API. Upload your file then call your poweron with the letter file name you uploaded.
While this query is not in the SDK yet it something we should get added. Below is something you could use to get you started.
```python
import base64
import logging
import uuid
from typing import Type
from lxml.builder import E, ElementMaker
from q2_cores.SymXchange.models import namespaces
from q2_cores.SymXchange.models import Credentials, DeviceInformation
from q2_cores.SymXchange.queries.base_query import SymXchangeBaseQuery
class FileManagementQuery(SymXchangeBaseQuery):
def __init__(
self,
logger: logging.Logger,
file_name: str,
file_contents: str,
credentials: Type[Credentials],
device_info: DeviceInformation,
mock_failure: bool = False,
):
self.file_name = file_name
self.file_contents = file_contents
super().__init__(logger, credentials, device_info, mock_failure)
@property
def service(self) -> str:
return "filemanagement"
def build(self) -> str:
file = ElementMaker(
namespace=namespaces.SYMXCHANGE_FILEMANAGEMENT,
nsmap={"file": namespaces.SYMXCHANGE_FILEMANAGEMENT, "dto": namespaces.SYMXCHANGE_FILEMANAGEMENT_DTO}
)
file_dto = ElementMaker(
namespace=namespaces.SYMXCHANGE_FILEMANAGEMENT_DTO
)
file_upload = file.uploadLetterFile(
E.Request(
{f'{{{namespaces.SYMXCHANGE_COMMON}}}MessageId' : str(uuid.uuid4())},
self.create_credentials(),
self.create_device_info(),
file_dto.FileName(self.file_name),
E.Data(base64.b64encode(self.file_contents.encode()).decode()),
E.noNewline(str(False).lower())
)
)
envelope = self.create_envelope(file_upload)
return super().serialize(envelope)
```
Hey Michael,
I think the best way to get this same functionality is to use the SymXchange File API.
While this query is not in the SDK yet it something we should get added. Below is something you could use to get you started.
```python
import base64
import logging
import uuid
from typing import Type
from lxml.builder import E, ElementMaker
from q2_cores.SymXchange.models import namespaces
from q2_cores.SymXchange.models import Credentials, DeviceInformation
from q2_cores.SymXchange.queries.base_query import SymXchangeBaseQuery
class FileManagementQuery(SymXchangeBaseQuery):
def __init__(
self,
logger: logging.Logger,
file_name: str,
file_contents: str,
credentials: Type[Credentials],
device_info: DeviceInformation,
mock_failure: bool = False,
):
self.file_name = file_name
self.file_contents = file_contents
super().__init__(logger, credentials, device_info, mock_failure)
@property
def service(self) -> str:
return "filemanagement"
def build(self) -> str:
file = ElementMaker(
namespace=namespaces.SYMXCHANGE_FILEMANAGEMENT,
nsmap={"file": namespaces.SYMXCHANGE_FILEMANAGEMENT, "dto": namespaces.SYMXCHANGE_FILEMANAGEMENT_DTO}
)
file_dto = ElementMaker(
namespace=namespaces.SYMXCHANGE_FILEMANAGEMENT_DTO
)
file_upload = file.uploadLetterFile(
E.Request(
{f'{{{namespaces.SYMXCHANGE_COMMON}}}MessageId' : str(uuid.uuid4())},
self.create_credentials(),
self.create_device_info(),
file_dto.FileName(self.file_name),
E.Data(base64.b64encode(self.file_contents.encode()).decode()),
E.noNewline(str(False).lower())
)
)
envelope = self.create_envelope(file_upload)
return super().serialize(envelope)
```
SymXchange core query no data file
Hey Michael,
I think the best way to get this same functionality is to use the SymXchange File API.
While this query is not in the SDK yet it something we should get added. Below is something you could use to get you started.
```python
import base64
import logging
import uuid
from typing import Type
from lxml.builder import E, ElementMaker
from q2_cores.SymXchange.models import namespaces
from q2_cores.SymXchange.models import Credentials, DeviceInformation
from q2_cores.SymXchange.queries.base_query import SymXchangeBaseQuery
class FileManagementQuery(SymXchangeBaseQuery):
def __init__(
self,
logger: logging.Logger,
file_name: str,
file_contents: str,
credentials: Type[Credentials],
device_info: DeviceInformation,
mock_failure: bool = False,
):
self.file_name = file_name
self.file_contents = file_contents
super().__init__(logger, credentials, device_info, mock_failure)
@property
def service(self) -> str:
return "filemanagement"
def build(self) -> str:
file = ElementMaker(
namespace=namespaces.SYMXCHANGE_FILEMANAGEMENT,
nsmap={"file": namespaces.SYMXCHANGE_FILEMANAGEMENT, "dto": namespaces.SYMXCHANGE_FILEMANAGEMENT_DTO}
)
file_dto = ElementMaker(
namespace=namespaces.SYMXCHANGE_FILEMANAGEMENT_DTO
)
file_upload = file.uploadLetterFile(
E.Request(
{f'{{{namespaces.SYMXCHANGE_COMMON}}}MessageId' : str(uuid.uuid4())},
self.create_credentials(),
self.create_device_info(),
file_dto.FileName(self.file_name),
E.Data(base64.b64encode(self.file_contents.encode()).decode()),
E.noNewline(str(False).lower())
)
)
envelope = self.create_envelope(file_upload)
return super().serialize(envelope)
```