1 package translatortext 2 3 // Copyright (c) Microsoft Corporation. All rights reserved. 4 // Licensed under the MIT License. See License.txt in the project root for license information. 5 // 6 // Code generated by Microsoft (R) AutoRest Code Generator. 7 // Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9 import ( 10 "encoding/json" 11 "github.com/Azure/go-autorest/autorest" 12 "github.com/Azure/go-autorest/autorest/date" 13 "github.com/gofrs/uuid" 14 ) 15 16 // The package's fully qualified name. 17 const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/cognitiveservices/v1.0_preview.1/translatortext" 18 19 // BatchRequest definition for the input batch translation request 20 type BatchRequest struct { 21 Source *SourceInput `json:"source,omitempty"` 22 // Targets - Location of the destination for the output 23 Targets *[]TargetInput `json:"targets,omitempty"` 24 // StorageType - Possible values include: 'Folder', 'File' 25 StorageType StorageType `json:"storageType,omitempty"` 26 } 27 28 // BatchStatusDetail job status response 29 type BatchStatusDetail struct { 30 autorest.Response `json:"-"` 31 // ID - Id of the operation. 32 ID *uuid.UUID `json:"id,omitempty"` 33 // CreatedDateTimeUtc - Operation created date time 34 CreatedDateTimeUtc *date.Time `json:"createdDateTimeUtc,omitempty"` 35 // LastActionDateTimeUtc - Date time in which the operation's status has been updated 36 LastActionDateTimeUtc *date.Time `json:"lastActionDateTimeUtc,omitempty"` 37 // Status - Possible values include: 'NotStarted', 'Running', 'Succeeded', 'Failed', 'Cancelled', 'Cancelling' 38 Status Status `json:"status,omitempty"` 39 Summary *StatusSummary `json:"summary,omitempty"` 40 } 41 42 // BatchStatusResponse document Status Response 43 type BatchStatusResponse struct { 44 autorest.Response `json:"-"` 45 // Value - The summary status of individual operation 46 Value *[]BatchStatusDetail `json:"value,omitempty"` 47 // NextLink - Url for the next page. Null if no more pages available 48 NextLink *string `json:"@nextLink,omitempty"` 49 } 50 51 // BatchSubmissionRequest job submission batch request 52 type BatchSubmissionRequest struct { 53 // Inputs - The input list of documents or folders containing documents 54 Inputs *[]BatchRequest `json:"inputs,omitempty"` 55 } 56 57 // DocumentFilter ... 58 type DocumentFilter struct { 59 // Prefix - A case-sensitive prefix string to filter documents in the source path for translation. 60 // For example, when using a Azure storage blob Uri, use the prefix to restrict sub folders for translation. 61 Prefix *string `json:"prefix,omitempty"` 62 // Suffix - A case-sensitive suffix string to filter documents in the source path for translation. 63 // This is most often use for file extensions 64 Suffix *string `json:"suffix,omitempty"` 65 } 66 67 // DocumentStatusDetail ... 68 type DocumentStatusDetail struct { 69 autorest.Response `json:"-"` 70 // Path - Location of the document or folder 71 Path *string `json:"path,omitempty"` 72 // CreatedDateTimeUtc - Operation created date time 73 CreatedDateTimeUtc *date.Time `json:"createdDateTimeUtc,omitempty"` 74 // LastActionDateTimeUtc - Date time in which the operation's status has been updated 75 LastActionDateTimeUtc *date.Time `json:"lastActionDateTimeUtc,omitempty"` 76 // Status - Possible values include: 'Status1NotStarted', 'Status1Running', 'Status1Succeeded', 'Status1Failed', 'Status1Cancelled', 'Status1Cancelling' 77 Status Status1 `json:"status,omitempty"` 78 // DetectedLanguage - Detected language of the original document (to be implemented) 79 DetectedLanguage *string `json:"detectedLanguage,omitempty"` 80 // To - To language 81 To *string `json:"to,omitempty"` 82 Error *ErrorV2 `json:"error,omitempty"` 83 // Progress - Progress of the translation if available 84 Progress *float64 `json:"progress,omitempty"` 85 // ID - Document Id 86 ID *uuid.UUID `json:"id,omitempty"` 87 } 88 89 // DocumentStatusResponse document Status Response 90 type DocumentStatusResponse struct { 91 autorest.Response `json:"-"` 92 // Value - The detail status of individual documents 93 Value *[]DocumentStatusDetail `json:"value,omitempty"` 94 // NextLink - Url for the next page. Null if no more pages available 95 NextLink *string `json:"@nextLink,omitempty"` 96 } 97 98 // ErrorResponseV2 contains unified error information used for HTTP responses across any Cognitive Service. 99 // Instances 100 // can be created either through Microsoft.CloudAI.Containers.HttpStatusExceptionV2 or by returning it 101 // directly from 102 // a controller. 103 type ErrorResponseV2 struct { 104 Error *ErrorV2 `json:"error,omitempty"` 105 } 106 107 // ErrorV2 this contains an outer error with error code, message, details, target and an inner error with 108 // more descriptive details. 109 type ErrorV2 struct { 110 // Code - Possible values include: 'InvalidRequest', 'InvalidArgument', 'InternalServerError', 'ServiceUnavailable', 'ResourceNotFound', 'Unauthorized', 'RequestRateTooHigh' 111 Code Code `json:"code,omitempty"` 112 // Message - READ-ONLY; Gets high level error message. 113 Message *string `json:"message,omitempty"` 114 // Target - READ-ONLY; Gets the source of the error. 115 // For example it would be "documents" or "document id" in case of invalid document. 116 Target *string `json:"target,omitempty"` 117 InnerError *InnerErrorV2 `json:"innerError,omitempty"` 118 } 119 120 // MarshalJSON is the custom marshaler for ErrorV2. 121 func (ev ErrorV2) MarshalJSON() ([]byte, error) { 122 objectMap := make(map[string]interface{}) 123 if ev.Code != "" { 124 objectMap["code"] = ev.Code 125 } 126 if ev.InnerError != nil { 127 objectMap["innerError"] = ev.InnerError 128 } 129 return json.Marshal(objectMap) 130 } 131 132 // FileFormat ... 133 type FileFormat struct { 134 // Format - Name of the format 135 Format *string `json:"format,omitempty"` 136 // FileExtensions - Supported file extension for this format 137 FileExtensions *[]string `json:"fileExtensions,omitempty"` 138 // ContentTypes - Supported Content-Types for this format 139 ContentTypes *[]string `json:"contentTypes,omitempty"` 140 // Versions - Supported Version 141 Versions *[]string `json:"versions,omitempty"` 142 } 143 144 // FileFormatListResult base type for List return in our api 145 type FileFormatListResult struct { 146 autorest.Response `json:"-"` 147 // Value - list of objects 148 Value *[]FileFormat `json:"value,omitempty"` 149 } 150 151 // Glossary glossary / translation memory for the request 152 type Glossary struct { 153 // GlossaryURL - Location of the glossary. 154 // We will use the file extension to extract the formating if the format parameter is not supplied. 155 // 156 // If the translation language pair is not present in the glossary, it will not be applied 157 GlossaryURL *string `json:"glossaryUrl,omitempty"` 158 // Format - Format 159 Format *string `json:"format,omitempty"` 160 // Version - Version 161 Version *string `json:"version,omitempty"` 162 } 163 164 // InnerErrorV2 new Inner Error format which conforms to Cognitive Services API Guidelines which is 165 // available at 166 // https://microsoft.sharepoint.com/%3Aw%3A/t/CognitiveServicesPMO/EUoytcrjuJdKpeOKIK_QRC8BPtUYQpKBi8JsWyeDMRsWlQ?e=CPq8ow. 167 // This contains required properties ErrorCode, message and optional properties target, details(key value 168 // pair), inner error(this can be nested). 169 type InnerErrorV2 struct { 170 // Code - READ-ONLY; Gets detailed error code. 171 Code *int32 `json:"code,omitempty"` 172 // Error - READ-ONLY; Gets detailed error string. 173 Error *string `json:"error,omitempty"` 174 // Message - READ-ONLY; Gets high level error message. 175 Message *string `json:"message,omitempty"` 176 // Target - READ-ONLY; Gets the source of the error. 177 // For example it would be "documents" or "document id" in case of invalid document. 178 Target *string `json:"target,omitempty"` 179 InnerError *InnerErrorV2 `json:"innerError,omitempty"` 180 } 181 182 // MarshalJSON is the custom marshaler for InnerErrorV2. 183 func (iev InnerErrorV2) MarshalJSON() ([]byte, error) { 184 objectMap := make(map[string]interface{}) 185 if iev.InnerError != nil { 186 objectMap["innerError"] = iev.InnerError 187 } 188 return json.Marshal(objectMap) 189 } 190 191 // SourceInput source of the input documents 192 type SourceInput struct { 193 // SourceURL - Location of the folder / container or single file with your documents 194 SourceURL *string `json:"sourceUrl,omitempty"` 195 Filter *DocumentFilter `json:"filter,omitempty"` 196 // Language - Language code 197 // If none is specified, we will perform auto detect on the document 198 Language *string `json:"language,omitempty"` 199 // StorageSource - Possible values include: 'AzureBlob' 200 StorageSource StorageSource `json:"storageSource,omitempty"` 201 } 202 203 // StatusSummary ... 204 type StatusSummary struct { 205 // Total - Total count 206 Total *int32 `json:"total,omitempty"` 207 // Failed - Failed count 208 Failed *int32 `json:"failed,omitempty"` 209 // Success - Number of Success 210 Success *int32 `json:"success,omitempty"` 211 // InProgress - Number of in progress 212 InProgress *int32 `json:"inProgress,omitempty"` 213 // NotYetStarted - Count of not yet started 214 NotYetStarted *int32 `json:"notYetStarted,omitempty"` 215 // Cancelled - Number of cancelled 216 Cancelled *int32 `json:"cancelled,omitempty"` 217 } 218 219 // StorageSourceListResult base type for List return in our api 220 type StorageSourceListResult struct { 221 autorest.Response `json:"-"` 222 // Value - list of objects 223 Value *[]string `json:"value,omitempty"` 224 } 225 226 // TargetInput destination for the finished translated documents 227 type TargetInput struct { 228 // TargetURL - Location of the folder / container with your documents 229 TargetURL *string `json:"targetUrl,omitempty"` 230 // Category - Category / custom system for translation request 231 Category *string `json:"category,omitempty"` 232 // Language - Target Language 233 Language *string `json:"language,omitempty"` 234 // Glossaries - List of Glossary 235 Glossaries *[]Glossary `json:"glossaries,omitempty"` 236 // StorageSource - Possible values include: 'StorageSource1AzureBlob' 237 StorageSource StorageSource1 `json:"storageSource,omitempty"` 238 } 239