Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
# pylint: skip-file
# flake8: noqa

from ._clients import *
46 changes: 46 additions & 0 deletions src/healthcareapis/azext_healthcareapis/aaz/latest/_clients.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_client("AAZHealthdataaiservicesDeidservicesDataPlaneClient_healthcareapis")
class AAZHealthdataaiservicesDeidservicesDataPlaneClient(AAZBaseClient):
_CLOUD_HOST_TEMPLATES = {
CloudNameEnum.AzureCloud: "https://{endpoint}",
}

_AAD_CREDENTIAL_SCOPES = [
"https://deid.azure.com/.default",
]

@classmethod
def _build_base_url(cls, ctx, **kwargs):
endpoint = None
if not endpoint:
endpoint = cls._CLOUD_HOST_TEMPLATES.get(ctx.cli_ctx.cloud.name, None)
return endpoint

@classmethod
def _build_configuration(cls, ctx, credential, **kwargs):
return AAZClientConfiguration(
credential=credential,
credential_scopes=cls._AAD_CREDENTIAL_SCOPES,
**kwargs
)


class _AAZHealthdataaiservicesDeidservicesDataPlaneClientHelper:
"""Helper class for AAZHealthdataaiservicesDeidservicesDataPlaneClient"""


__all__ = [
"AAZHealthdataaiservicesDeidservicesDataPlaneClient",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command_group(
"health-data-ai-services",
)
class __CMDGroup(AAZCommandGroup):
"""Manage Health Data Ai Services
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from .__cmd_group import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command_group(
"health-data-ai-services deid-services",
)
class __CMDGroup(AAZCommandGroup):
"""Manage Deid Services
"""
pass


__all__ = ["__CMDGroup"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from .__cmd_group import *
from ._deid import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
#
# Code generated by aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *


@register_command(
"health-data-ai-services deid-services deid",
)
class Deid(AAZCommand):
"""A remote procedure call (RPC) operation.
"""

_aaz_info = {
"version": "2024-11-15",
"resources": [
["data-plane:healthdataaiservices.deidservices", "/deid", "2024-11-15"],
]
}

def _handler(self, command_args):
super()._handler(command_args)
self._execute_operations()
return self._output()

_args_schema = None

@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
if cls._args_schema is not None:
return cls._args_schema
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)

# define Arg Group "Client"

_args_schema = cls._args_schema
_args_schema.endpoint = AAZStrArg(
options=["--endpoint"],
arg_group="Client",
help="Url of your De-identification Service.",
required=True,
)

# define Arg Group "Body"

_args_schema = cls._args_schema
_args_schema.customizations = AAZObjectArg(
options=["--customizations"],
arg_group="Body",
help="Customization parameters to override default service behaviors.",
)
_args_schema.input_text = AAZStrArg(
options=["--input-text"],
arg_group="Body",
help="Input text to de-identify.",
required=True,
fmt=AAZStrArgFormat(
max_length=48000,
),
)
_args_schema.operation = AAZStrArg(
options=["--operation"],
arg_group="Body",
help="Operation to perform on the input documents.",
default="Surrogate",
enum={"Redact": "Redact", "Surrogate": "Surrogate", "Tag": "Tag"},
)

customizations = cls._args_schema.customizations
customizations.redaction_format = AAZStrArg(
options=["redaction-format"],
help="Format of the redacted output. Only valid when Operation is Redact. Please refer to https://learn.microsoft.com/azure/healthcare-apis/deidentification/redaction-format for more details.",
fmt=AAZStrArgFormat(
max_length=16,
min_length=1,
),
)
customizations.surrogate_locale = AAZStrArg(
options=["surrogate-locale"],
help="Locale in which the output surrogates are written.",
default="en-US",
)
return cls._args_schema

def _execute_operations(self):
self.pre_operations()
self.DeidentifyText(ctx=self.ctx)()
self.post_operations()

@register_callback
def pre_operations(self):
pass

@register_callback
def post_operations(self):
pass

def _output(self, *args, **kwargs):
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
return result

class DeidentifyText(AAZHttpOperation):
CLIENT_TYPE = "AAZHealthdataaiservicesDeidservicesDataPlaneClient_healthcareapis"

def __call__(self, *args, **kwargs):
request = self.make_request()
session = self.client.send_request(request=request, stream=False, **kwargs)
if session.http_response.status_code in [200]:
return self.on_200(session)

return self.on_error(session.http_response)

@property
def url(self):
return self.client.format_url(
"/deid",
**self.url_parameters
)

@property
def method(self):
return "POST"

@property
def error_format(self):
return "ODataV4Format"

@property
def url_parameters(self):
parameters = {
**self.serialize_url_param(
"endpoint", self.ctx.args.endpoint,
skip_quote=True,
required=True,
),
}
return parameters

@property
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2024-11-15",
required=True,
),
}
return parameters

@property
def header_parameters(self):
parameters = {
**self.serialize_header_param(
"Content-Type", "application/json",
),
**self.serialize_header_param(
"Accept", "application/json",
),
}
return parameters

@property
def content(self):
_content_value, _builder = self.new_content_builder(
self.ctx.args,
typ=AAZObjectType,
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
)
_builder.set_prop("customizations", AAZObjectType, ".customizations")
_builder.set_prop("inputText", AAZStrType, ".input_text", typ_kwargs={"flags": {"required": True}})
_builder.set_prop("operation", AAZStrType, ".operation")

customizations = _builder.get(".customizations")
if customizations is not None:
customizations.set_prop("redactionFormat", AAZStrType, ".redaction_format")
customizations.set_prop("surrogateLocale", AAZStrType, ".surrogate_locale")

return self.serialize_content(_content_value)

def on_200(self, session):
data = self.deserialize_http_content(session)
self.ctx.set_var(
"instance",
data,
schema_builder=self._build_schema_on_200
)

_schema_on_200 = None

@classmethod
def _build_schema_on_200(cls):
if cls._schema_on_200 is not None:
return cls._schema_on_200

cls._schema_on_200 = AAZObjectType()

_schema_on_200 = cls._schema_on_200
_schema_on_200.output_text = AAZStrType(
serialized_name="outputText",
)
_schema_on_200.tagger_result = AAZObjectType(
serialized_name="taggerResult",
)

tagger_result = cls._schema_on_200.tagger_result
tagger_result.entities = AAZListType(
flags={"required": True},
)

entities = cls._schema_on_200.tagger_result.entities
entities.Element = AAZObjectType()

_element = cls._schema_on_200.tagger_result.entities.Element
_element.category = AAZStrType(
flags={"required": True},
)
_element.confidence_score = AAZFloatType(
serialized_name="confidenceScore",
)
_element.length = AAZObjectType(
flags={"required": True},
)
_DeidHelper._build_schema_stringindex_read(_element.length)
_element.offset = AAZObjectType(
flags={"required": True},
)
_DeidHelper._build_schema_stringindex_read(_element.offset)
_element.text = AAZStrType()

return cls._schema_on_200


class _DeidHelper:
"""Helper class for Deid"""

_schema_stringindex_read = None

@classmethod
def _build_schema_stringindex_read(cls, _schema):
if cls._schema_stringindex_read is not None:
_schema.code_point = cls._schema_stringindex_read.code_point
_schema.utf16 = cls._schema_stringindex_read.utf16
_schema.utf8 = cls._schema_stringindex_read.utf8
return

cls._schema_stringindex_read = _schema_stringindex_read = AAZObjectType()

stringindex_read = _schema_stringindex_read
stringindex_read.code_point = AAZIntType(
serialized_name="codePoint",
flags={"required": True},
)
stringindex_read.utf16 = AAZIntType(
flags={"required": True},
)
stringindex_read.utf8 = AAZIntType(
flags={"required": True},
)

_schema.code_point = cls._schema_stringindex_read.code_point
_schema.utf16 = cls._schema_stringindex_read.utf16
_schema.utf8 = cls._schema_stringindex_read.utf8


__all__ = ["Deid"]
Loading
Loading