File size: 5,716 Bytes
54fa0c8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
'''
MIT license https://opensource.org/licenses/MIT Copyright 2024 Infosys Ltd

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
'''

"""
fileName: mappers.py
description: A Pydantic model object for usecase entity model
             which maps the data model to the usecase entity schema
"""

from pydantic import BaseModel, Field
from datetime import datetime
from typing import Optional,Union, List

"""
description: piiEntity
params:
"""


class PIIEntity(BaseModel):
    type: Optional[str] = Field(example="US_SSN")
    beginOffset: Optional[int] = Field(example=19)
    endOffset: Optional[int] = Field(example=28)
    score:Optional[float]=Field(example=1.1)  
    responseText:Optional[str]=Field(example="012884567")

    class Config:
        orm_mode = True

class PIIItems(BaseModel):
    start: Optional[int] = Field(example=19)
    end: Optional[int] = Field(example=28)
    entity_type: Optional[str] = Field(example="US_SSN") 
    text:Optional[str]=Field(example="John Smith's SSN is 012884567")
    operator:Optional[str]= Field(example="encrypt") 

    class Config:
        orm_mode = True

class PIIImageEntity(BaseModel):
    type: str = Field(example="US_SSN")

    class Config:
        orm_mode = True

class PIIAnalyzeRequest(BaseModel):
    inputText: str = Field(example="John Smith's SSN is 012884567")
    # entity_type: Optional[str] = Field(example="COMPANY_NAME")
    portfolio:Optional[str] = Field(example="string")
    account:Optional[str] = Field(example="string")
    exclusionList:Optional[str] = Field(example="Karan,Infosys")
    user: Optional[str] = Field(None)
    lotNumber:Optional[str] = Field(None)
    
class PIIEncryptResponse(BaseModel):
    text: str = Field(example="John Smith's SSN is 012884567")
    items: List[PIIItems]

    class Config:
        orm_mode = True

class PIIDecryptRequest(BaseModel):
    text: str = Field(example="John Smith's SSN is 012884567")
    items: List[PIIItems]

class PIIAnalyzeResponse(BaseModel):
    PIIEntities: List[PIIEntity]

    class Config:
        orm_mode = True


class PIIAnonymizeRequest(BaseModel):
    inputText: str = Field(example="John Smith's SSN is 012884567")
    portfolio:Optional[str] = Field(example="string")
    account:Optional[str] = Field(example="string")
    exclusionList:Optional[str] = Field(example="Karan,Infosys")
    piiEntitiesToBeRedacted: Optional[list] = Field(example=["US_SSN"])
    redactionType: Optional[str] = Field(example='replace')
    user: Optional[str] = Field(example = None)
    lotNumber:Optional[str] = Field(example = None)
    fakeData: Optional[bool] = Field(example = False)



class PIIAnonymizeResponse(BaseModel):
    anonymizedText: str = Field(example="John Smith's SSN is <US_SSN>")

    class Config:
        orm_mode = True
        
class PIIDecryptResponse(BaseModel):
    decryptedText: str = Field(example="John Smith's SSN is <US_SSN>")

    class Config:
        orm_mode = True   
    
#class Image
class PIIImageAnalyzeRequest(BaseModel):
    class Config:
        orm_mode = True

class PIIImageAnonymizeResponse(BaseModel):
    base64text: str=Field(example="kshdbfbfwbedhbaskjbakbsakjnalhbsfsfvslkjdnlkjdsnkdsbflkjsbdsklakbkdb")

    class Config:
        orm_mode = True

class PIIImageEntity(BaseModel):
    type: str = Field(example="US_SSN")

    class Config:
        orm_mode = True

class PIIImageAnalyzeResponse(BaseModel):
    PIIEntities: List[PIIImageEntity]

    class Config:
        orm_mode = True

class PIIMultipleImageAnalyzeResponse(BaseModel):
    PIIEntities: List[List[PIIImageEntity]]

    class Config:
        orm_mode = True



class PIIPrivacyShieldRequest(BaseModel):
    inputText: str = Field(example="John Smith's SSN is 012884567")
    # entity_type: Optional[str] = Field(example="COMPANY_NAME")
    portfolio:Optional[str] = Field(example="string")
    account:Optional[str] = Field(example="string")

    



class PrivacyShield(BaseModel):
    entitiesRecognised:list = Field(example=["US_SSN"])
    entitiesConfigured :list = Field(example=["US_SSN"])
    result:str =""

class PIIPrivacyShieldResponse(BaseModel):
    privacyCheck: List[PrivacyShield]

    class Config:
        orm_mode = True



class LogoHidingResponse(BaseModel):
    base64text: str=Field(example="kshdbfbfwbedhbaskjbakbsakjnalhbsfsfvslkjdnlkjdsnkdsbflkjsbdsklakbkdb")

    class Config:
        orm_mode = True

class Telemetry(BaseModel):
    Module:str= Field(example = "Privacy")
    TelemetryFlagValue : bool = Field(example=True) 
  

class TelemetryResponse(BaseModel):
    result : List[Telemetry]

    class Config:
        orm_mode = True
    
class PIICodeDetectRequest(BaseModel):
    inputText: str = Field(example="John Smith's SSN is 012884567")