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