import * as coreClient from "@azure/core-client" ; import * as coreRestPipeline from "@azure/core-rest-pipeline" ; import * as coreTracing from "@azure/core-tracing" ; import { createSpan } from "./tracing" ; import * as Parameters from "./models/parameters" ; import * as Mappers from "./models/mappers" ; import { MediaTypesWithTracingClientOptionalParams , ContentType , AnalyzeBody$binaryOptionalParams , AnalyzeBody$jsonOptionalParams , AnalyzeBodyResponse , AnalyzeBodyNoAcceptHeader$binaryOptionalParams , AnalyzeBodyNoAcceptHeader$jsonOptionalParams , ContentTypeWithEncodingOptionalParams , ContentTypeWithEncodingResponse , BinaryBodyWithTwoContentTypesOptionalParams , BinaryBodyWithTwoContentTypesResponse , ContentType1 , BinaryBodyWithThreeContentTypes$binaryOptionalParams , BinaryBodyWithThreeContentTypes$textOptionalParams , BinaryBodyWithThreeContentTypesResponse , PutTextAndJsonBody$textOptionalParams , PutTextAndJsonBody$jsonOptionalParams , PutTextAndJsonBodyResponse } from "./models" ; export class MediaTypesWithTracingClient extends coreClient . ServiceClient { $host : string ; param options constructor ( options ? ) { if ( ! options ) { options = { } ; } const defaults = { requestContentType : "application/json; charset=utf-8" } ; const packageDetails = `azsdk-js-media-types-service-tracing/1.0.0-preview1` ; const userAgentPrefix = options . userAgentOptions && options . userAgentOptions . userAgentPrefix ? `${ options . userAgentOptions . userAgentPrefix } ${ packageDetails }` : `${ packageDetails }` ; const optionsWithDefaults = { ... defaults , ... options , userAgentOptions : { userAgentPrefix } , baseUri : options . endpoint || "http://localhost:3000" } ; super ( optionsWithDefaults ) ; this . $host = options . $host || "http://localhost:3000" ; } param contentType param options analyzeBody ( contentType , options ? ) ; param contentType param options analyzeBody ( contentType , options ? ) ; param args async analyzeBody ( ... args ) { let operationSpec ; let operationArguments ; let options ; if ( args [ 0 ] === "application/pdf" || args [ 0 ] === "image/jpeg" || args [ 0 ] === "image/png" || args [ 0 ] === "image/tiff" ) { operationSpec = analyzeBody$binaryOperationSpec ; operationArguments = { contentType : args [ 0 ] , options : args [ 1 ] } ; options = args [ 1 ] ; } else if ( args [ 0 ] === "application/json" ) { operationSpec = analyzeBody$jsonOperationSpec ; operationArguments = { contentType : args [ 0 ] , options : args [ 1 ] } ; options = args [ 1 ] ; } else { throw new TypeError ( `"contentType" must be a valid value but instead was "${ args [ 0 ] }".` ) ; } const { span } = createSpan ( "MediaTypesWithTracingClient-analyzeBody" , options ) ; operationArguments . options = options || { } ; try { const result = await this . sendOperationRequest ( operationArguments , operationSpec ) ; return result as AnalyzeBodyResponse ; } catch ( error ) { span . setStatus ( { code : coreTracing . SpanStatusCode . UNSET , message : error . message } ) ; throw error ; } finally { span . end ( ) ; } } param contentType param options analyzeBodyNoAcceptHeader ( contentType , options ? ) ; param contentType param options analyzeBodyNoAcceptHeader ( contentType , options ? ) ; param args async analyzeBodyNoAcceptHeader ( ... args ) { let operationSpec ; let operationArguments ; let options ; if ( args [ 0 ] === "application/pdf" || args [ 0 ] === "image/jpeg" || args [ 0 ] === "image/png" || args [ 0 ] === "image/tiff" ) { operationSpec = analyzeBodyNoAcceptHeader$binaryOperationSpec ; operationArguments = { contentType : args [ 0 ] , options : args [ 1 ] } ; options = args [ 1 ] ; } else if ( args [ 0 ] === "application/json" ) { operationSpec = analyzeBodyNoAcceptHeader$jsonOperationSpec ; operationArguments = { contentType : args [ 0 ] , options : args [ 1 ] } ; options = args [ 1 ] ; } else { throw new TypeError ( `"contentType" must be a valid value but instead was "${ args [ 0 ] }".` ) ; } const { span } = createSpan ( "MediaTypesWithTracingClient-analyzeBodyNoAcceptHeader" , options ) ; operationArguments . options = options || { } ; try { const result = await this . sendOperationRequest ( operationArguments , operationSpec ) ; return result as void ; } catch ( error ) { span . setStatus ( { code : coreTracing . SpanStatusCode . UNSET , message : error . message } ) ; throw error ; } finally { span . end ( ) ; } } param options async contentTypeWithEncoding ( options ? ) { const { span } = createSpan ( "MediaTypesWithTracingClient-contentTypeWithEncoding" , options || { } ) ; try { const result = await this . sendOperationRequest ( { options } , contentTypeWithEncodingOperationSpec ) ; return result as ContentTypeWithEncodingResponse ; } catch ( error ) { span . setStatus ( { code : coreTracing . SpanStatusCode . UNSET , message : error . message } ) ; throw error ; } finally { span . end ( ) ; } } param message param options async binaryBodyWithTwoContentTypes ( message , options ? ) { const { span } = createSpan ( "MediaTypesWithTracingClient-binaryBodyWithTwoContentTypes" , options || { } ) ; try { const result = await this . sendOperationRequest ( { message , options } , binaryBodyWithTwoContentTypesOperationSpec ) ; return result as BinaryBodyWithTwoContentTypesResponse ; } catch ( error ) { span . setStatus ( { code : coreTracing . SpanStatusCode . UNSET , message : error . message } ) ; throw error ; } finally { span . end ( ) ; } } param contentType param message param options binaryBodyWithThreeContentTypes ( contentType , message , options ? ) ; param contentType param message param options binaryBodyWithThreeContentTypes ( contentType , message , options ? ) ; param args async binaryBodyWithThreeContentTypes ( ... args ) { let operationSpec ; let operationArguments ; let options ; if ( args [ 0 ] === "application/json" || args [ 0 ] === "application/octet-stream" ) { operationSpec = binaryBodyWithThreeContentTypes$binaryOperationSpec ; operationArguments = { contentType : args [ 0 ] , message : args [ 1 ] , options : args [ 2 ] } ; options = args [ 2 ] ; } else if ( args [ 0 ] === "text/plain" ) { operationSpec = binaryBodyWithThreeContentTypes$textOperationSpec ; operationArguments = { contentType : args [ 0 ] , message : args [ 1 ] , options : args [ 2 ] } ; options = args [ 2 ] ; } else { throw new TypeError ( `"contentType" must be a valid value but instead was "${ args [ 0 ] }".` ) ; } const { span } = createSpan ( "MediaTypesWithTracingClient-binaryBodyWithThreeContentTypes" , options ) ; operationArguments . options = options || { } ; try { const result = await this . sendOperationRequest ( operationArguments , operationSpec ) ; return result as BinaryBodyWithThreeContentTypesResponse ; } catch ( error ) { span . setStatus ( { code : coreTracing . SpanStatusCode . UNSET , message : error . message } ) ; throw error ; } finally { span . end ( ) ; } } param contentType param message param options putTextAndJsonBody ( contentType , message , options ? ) ; param contentType param message param options putTextAndJsonBody ( contentType , message , options ? ) ; param args async putTextAndJsonBody ( ... args ) { let operationSpec ; let operationArguments ; let options ; if ( args [ 0 ] === "text/plain" ) { operationSpec = putTextAndJsonBody$textOperationSpec ; operationArguments = { contentType : args [ 0 ] , message : args [ 1 ] , options : args [ 2 ] } ; options = args [ 2 ] ; } else if ( args [ 0 ] === "application/json" ) { operationSpec = putTextAndJsonBody$jsonOperationSpec ; operationArguments = { contentType : args [ 0 ] , message : args [ 1 ] , options : args [ 2 ] } ; options = args [ 2 ] ; } else { throw new TypeError ( `"contentType" must be a valid value but instead was "${ args [ 0 ] }".` ) ; } const { span } = createSpan ( "MediaTypesWithTracingClient-putTextAndJsonBody" , options ) ; operationArguments . options = options || { } ; try { const result = await this . sendOperationRequest ( operationArguments , operationSpec ) ; return result as PutTextAndJsonBodyResponse ; } catch ( error ) { span . setStatus ( { code : coreTracing . SpanStatusCode . UNSET , message : error . message } ) ; throw error ; } finally { span . end ( ) ; } } } const serializer = coreClient . createSerializer ( Mappers , false ) ; const analyzeBody$binaryOperationSpec = { path : "/mediatypes/analyze" , httpMethod : "POST" , responses : { 200 : { bodyMapper : { type : { name : "String" } } } } , requestBody : Parameters . input , urlParameters : [ Parameters . $host ] , headerParameters : [ Parameters . contentType , Parameters . accept ] , mediaType : "binary" , serializer } ; const analyzeBody$jsonOperationSpec = { path : "/mediatypes/analyze" , httpMethod : "POST" , responses : { 200 : { bodyMapper : { type : { name : "String" } } } } , requestBody : Parameters . input1 , urlParameters : [ Parameters . $host ] , headerParameters : [ Parameters . contentType1 , Parameters . accept1 ] , mediaType : "json" , serializer } ; const analyzeBodyNoAcceptHeader$binaryOperationSpec = { path : "/mediatypes/analyzeNoAccept" , httpMethod : "POST" , responses : { 202 : { } , default : { } } , requestBody : Parameters . input , urlParameters : [ Parameters . $host ] , headerParameters : [ Parameters . contentType ] , mediaType : "binary" , serializer } ; const analyzeBodyNoAcceptHeader$jsonOperationSpec = { path : "/mediatypes/analyzeNoAccept" , httpMethod : "POST" , responses : { 202 : { } , default : { } } , requestBody : Parameters . input1 , urlParameters : [ Parameters . $host ] , headerParameters : [ Parameters . contentType1 ] , mediaType : "json" , serializer } ; const contentTypeWithEncodingOperationSpec = { path : "/mediatypes/contentTypeWithEncoding" , httpMethod : "POST" , responses : { 200 : { bodyMapper : { type : { name : "String" } } } } , requestBody : Parameters . input2 , urlParameters : [ Parameters . $host ] , headerParameters : [ Parameters . contentType2 , Parameters . accept2 ] , mediaType : "text" , serializer } ; const binaryBodyWithTwoContentTypesOperationSpec = { path : "/mediatypes/binaryBodyTwoContentTypes" , httpMethod : "POST" , responses : { 200 : { bodyMapper : { type : { name : "String" } } } } , requestBody : Parameters . message , urlParameters : [ Parameters . $host ] , headerParameters : [ Parameters . contentType3 , Parameters . accept3 ] , mediaType : "binary" , serializer } ; const binaryBodyWithThreeContentTypes$binaryOperationSpec = { path : "/mediatypes/binaryBodyThreeContentTypes" , httpMethod : "POST" , responses : { 200 : { bodyMapper : { type : { name : "String" } } } } , requestBody : Parameters . message , urlParameters : [ Parameters . $host ] , headerParameters : [ Parameters . accept3 , Parameters . contentType4 ] , mediaType : "binary" , serializer } ; const binaryBodyWithThreeContentTypes$textOperationSpec = { path : "/mediatypes/binaryBodyThreeContentTypes" , httpMethod : "POST" , responses : { 200 : { bodyMapper : { type : { name : "String" } } } } , requestBody : Parameters . message1 , urlParameters : [ Parameters . $host ] , headerParameters : [ Parameters . contentType5 , Parameters . accept4 ] , mediaType : "text" , serializer } ; const putTextAndJsonBody$textOperationSpec = { path : "/mediatypes/textAndJson" , httpMethod : "POST" , responses : { 200 : { bodyMapper : { type : { name : "String" } } } } , requestBody : Parameters . message1 , urlParameters : [ Parameters . $host ] , headerParameters : [ Parameters . contentType5 , Parameters . accept4 ] , mediaType : "text" , serializer } ; const putTextAndJsonBody$jsonOperationSpec = { path : "/mediatypes/textAndJson" , httpMethod : "POST" , responses : { 200 : { bodyMapper : { type : { name : "String" } } } } , requestBody : Parameters . message2 , urlParameters : [ Parameters . $host ] , headerParameters : [ Parameters . contentType1 , Parameters . accept5 ] , mediaType : "json" , serializer } ;