From 8e76b7ae2e60cb2fc7edc2cf9b109a5b624aead8 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 10 Sep 2024 03:44:29 +0000 Subject: [PATCH] CodeGen from PR 3482 in test-repo-billy/azure-rest-api-specs Merge 6c7f4231c72f34d93168540dea930f470444330e into 02e500856ce974e6873e205ffdb6523ffdc60bb7 --- .../azure.ApiCenter/tsp-location.yaml | 4 + .../src/autorest.md | 2 +- .../Configuration.json | 12 + .../src/autorest.md | 55 - .../tsp-location.yaml | 4 + .../tspCodeModel.json | 7543 +++++++++++++++++ .../LiveMetrics/LiveMetrics.sln | 50 + .../src/Generated/AggregationType.cs | 57 + ...lectionConfigurationError.Serialization.cs | 170 + .../Generated/CollectionConfigurationError.cs | 96 + .../CollectionConfigurationErrorType.cs | 84 + ...llectionConfigurationInfo.Serialization.cs | 187 + .../Generated/CollectionConfigurationInfo.cs | 94 + .../DerivedMetricInfo.Serialization.cs | 193 + .../src/Generated/DerivedMetricInfo.cs | 109 + .../src/Generated/Docs/LiveMetricsClient.xml | 671 ++ ...ilterConjunctionGroupInfo.Serialization.cs | 144 + .../DocumentFilterConjunctionGroupInfo.cs | 81 + .../DocumentIngress.Serialization.cs | 151 + .../src/Generated/DocumentIngress.cs | 79 + .../DocumentStreamInfo.Serialization.cs | 154 + .../src/Generated/DocumentStreamInfo.cs | 83 + .../LiveMetrics/src/Generated/DocumentType.cs | 63 + .../src/Generated/Event.Serialization.cs | 197 + .../LiveMetrics/src/Generated/Event.cs | 36 + .../src/Generated/Exception.Serialization.cs | 214 + .../LiveMetrics/src/Generated/Exception.cs | 40 + ...lterConjunctionGroupInfo.Serialization.cs} | 65 +- .../Generated/FilterConjunctionGroupInfo.cs | 76 + .../src/Generated/FilterInfo.Serialization.cs | 152 + .../LiveMetrics/src/Generated/FilterInfo.cs | 88 + .../src/Generated/Internal/Argument.cs | 129 + .../Internal/ChangeTrackingDictionary.cs | 167 + .../Generated/Internal/ChangeTrackingList.cs | 153 + .../Internal/ModelSerializationExtensions.cs | 398 + .../src/Generated/Internal/Optional.cs | 51 + .../Internal/RequestContentHelper.cs | 136 + .../Internal/Utf8JsonRequestContent.cs | 55 + .../KeyValuePairStringString.Serialization.cs | 144 + .../src/Generated/KeyValuePairStringString.cs | 82 + .../src/Generated/LiveMetricsClient.cs | 408 + .../LiveMetricsClientBuilderExtensions.cs | 35 + .../src/Generated/LiveMetricsClientOptions.cs | 37 + .../src/Generated/LiveMetricsModelFactory.cs | 148 + .../Generated/MetricPoint.Serialization.cs} | 83 +- .../LiveMetrics/src/Generated/MetricPoint.cs | 87 + .../MonitoringDataPoint.Serialization.cs | 337 + .../src/Generated/MonitoringDataPoint.cs | 157 + .../src/Generated/PredicateType.cs | 69 + .../Generated/ProcessCpuData.Serialization.cs | 144 + .../src/Generated/ProcessCpuData.cs | 81 + .../QuotaConfigurationInfo.Serialization.cs | 159 + .../src/Generated/QuotaConfigurationInfo.cs | 82 + .../RemoteDependency.Serialization.cs | 238 + .../src/Generated/RemoteDependency.cs | 48 + .../src/Generated/Request.Serialization.cs | 242 + .../LiveMetrics/src/Generated/Request.cs | 48 + .../src/Generated/TelemetryType.cs | 66 + .../src/Generated/Trace.Serialization.cs | 197 + .../LiveMetrics/src/Generated/Trace.cs | 36 + .../UnknownDocumentIngress.Serialization.cs | 186 + .../src/Generated/UnknownDocumentIngress.cs | 30 + .../LiveMetrics/src/LiveMetrics.csproj | 19 + .../src/Properties/AssemblyInfo.cs | 6 + .../Samples/Samples_LiveMetricsClient.cs | 710 ++ .../tests/LiveMetrics.Tests.csproj | 19 + .../LiveMetrics/tsp-location.yaml | 4 + .../tsp-location.yaml | 5 +- .../src/Generated/ApiResponseFormat.cs | 51 + .../src/Generated/Assistant.Serialization.cs | 99 +- .../src/Generated/Assistant.cs | 117 +- .../AssistantCreationOptions.Serialization.cs | 103 +- .../src/Generated/AssistantCreationOptions.cs | 92 +- .../src/Generated/AssistantStreamEvent.cs | 134 + .../AssistantThread.Serialization.cs | 28 +- .../src/Generated/AssistantThread.cs | 22 +- ...tantThreadCreationOptions.Serialization.cs | 31 +- .../AssistantThreadCreationOptions.cs | 18 +- ...sistantsApiResponseFormat.Serialization.cs | 142 + .../Generated/AssistantsApiResponseFormat.cs | 68 + .../AssistantsApiResponseFormatMode.cs | 51 + .../AssistantsApiToolChoiceOptionMode.cs | 51 + .../src/Generated/AssistantsClient.cs | 3188 ++++--- .../src/Generated/AssistantsClientOptions.cs | 8 +- .../src/Generated/AssistantsModelFactory.cs | 709 +- ...AssistantsNamedToolChoice.Serialization.cs | 150 + .../Generated/AssistantsNamedToolChoice.cs | 76 + .../AssistantsNamedToolChoiceType.cs | 54 + ...deInterpreterToolResource.Serialization.cs | 145 + .../Generated/CodeInterpreterToolResource.cs | 85 + ...CreateAndRunThreadOptions.Serialization.cs | 271 +- .../Generated/CreateAndRunThreadOptions.cs | 174 +- ...preterToolResourceOptions.Serialization.cs | 152 + ...eateCodeInterpreterToolResourceOptions.cs} | 31 +- ...sourceVectorStoreOptions.Serialization.cs} | 83 +- ...ileSearchToolResourceVectorStoreOptions.cs | 100 + .../CreateRunOptions.Serialization.cs | 231 + .../src/Generated/CreateRunOptions.cs | 169 +- ...reateToolResourcesOptions.Serialization.cs | 164 + .../Generated/CreateToolResourcesOptions.cs | 119 + ...ctorStoreFileBatchRequest.Serialization.cs | 160 + .../CreateVectorStoreFileBatchRequest.cs | 88 + ...ateVectorStoreFileRequest.Serialization.cs | 150 + .../Generated/CreateVectorStoreFileRequest.cs | 87 + .../src/Generated/DoneEvent.cs | 48 + .../src/Generated/ErrorEvent.cs | 48 + .../FileSearchToolDefinition.Serialization.cs | 150 + .../src/Generated/FileSearchToolDefinition.cs | 34 + ...archToolDefinitionDetails.Serialization.cs | 142 + .../FileSearchToolDefinitionDetails.cs | 73 + .../FileSearchToolResource.Serialization.cs | 152 + .../src/Generated/FileSearchToolResource.cs | 72 + .../src/Generated/FileState.cs | 75 + .../Generated/FunctionName.Serialization.cs | 135 + .../src/Generated/FunctionName.cs | 75 + .../src/Generated/IncompleteRunDetails.cs | 51 + ...ternalAssistantFileDeletionStatusObject.cs | 48 - .../InternalMessageImageFileDetails.cs | 4 +- ...nternalMessageTextDetails.Serialization.cs | 2 +- .../Generated/InternalMessageTextDetails.cs | 8 +- .../InternalMessageTextFileCitationDetails.cs | 6 +- .../InternalMessageTextFilePathDetails.cs | 4 +- .../MessageAttachment.Serialization.cs | 172 + .../src/Generated/MessageAttachment.cs | 120 + .../Generated/MessageDelta.Serialization.cs | 153 + .../src/Generated/MessageDelta.cs | 94 + .../MessageDeltaChunk.Serialization.cs | 151 + .../{MessageFile.cs => MessageDeltaChunk.cs} | 48 +- .../src/Generated/MessageDeltaChunkObject.cs | 48 + .../MessageDeltaContent.Serialization.cs | 129 + .../src/Generated/MessageDeltaContent.cs | 80 + ...sageDeltaImageFileContent.Serialization.cs | 158 + .../Generated/MessageDeltaImageFileContent.cs | 41 + ...ltaImageFileContentObject.Serialization.cs | 138 + .../MessageDeltaImageFileContentObject.cs | 65 + ...essageDeltaTextAnnotation.Serialization.cs | 129 + .../Generated/MessageDeltaTextAnnotation.cs | 80 + .../MessageDeltaTextContent.Serialization.cs | 163 + .../src/Generated/MessageDeltaTextContent.cs | 78 + ...ageDeltaTextContentObject.Serialization.cs | 158 + .../MessageDeltaTextContentObject.cs | 41 + ...extFileCitationAnnotation.Serialization.cs | 149 + .../MessageDeltaTextFileCitationAnnotation.cs | 69 + ...eCitationAnnotationObject.Serialization.cs | 206 + ...geDeltaTextFileCitationAnnotationObject.cs | 53 + ...ltaTextFilePathAnnotation.Serialization.cs | 138 + .../MessageDeltaTextFilePathAnnotation.cs | 65 + ...tFilePathAnnotationObject.Serialization.cs | 206 + ...essageDeltaTextFilePathAnnotationObject.cs | 53 + .../src/Generated/MessageImageFileContent.cs | 2 +- .../MessageIncompleteDetails.Serialization.cs | 135 + .../src/Generated/MessageIncompleteDetails.cs | 72 + .../MessageIncompleteDetailsReason.cs | 60 + .../src/Generated/MessageStatus.cs | 54 + .../src/Generated/MessageStreamEvent.cs | 60 + .../MessageTextAnnotation.Serialization.cs | 4 - .../src/Generated/MessageTextAnnotation.cs | 18 +- .../src/Generated/MessageTextContent.cs | 2 +- ...extFileCitationAnnotation.Serialization.cs | 48 +- .../MessageTextFileCitationAnnotation.cs | 22 +- ...ageTextFilePathAnnotation.Serialization.cs | 48 +- .../MessageTextFilePathAnnotation.cs | 16 +- .../src/Generated/OpenAIFile.Serialization.cs | 28 + .../src/Generated/OpenAIFile.cs | 10 +- .../src/Generated/OpenAIFilePurpose.cs | 9 + ...OpenAIPageableListOfAssistantFileObject.cs | 48 - ...ageableListOfVectorStore.Serialization.cs} | 52 +- ....cs => OpenAIPageableListOfVectorStore.cs} | 18 +- ...bleListOfVectorStoreFile.Serialization.cs} | 52 +- ...=> OpenAIPageableListOfVectorStoreFile.cs} | 18 +- ...enAIPageableListOfVectorStoreFileObject.cs | 48 + ... OpenAIPageableListOfVectorStoreObject.cs} | 26 +- .../src/Generated/RetrievalToolDefinition.cs | 29 - .../RunCompletionUsage.Serialization.cs | 151 + .../src/Generated/RunCompletionUsage.cs | 84 + .../src/Generated/RunStep.Serialization.cs | 24 + .../src/Generated/RunStep.cs | 6 +- .../RunStepCompletionUsage.Serialization.cs | 151 + .../src/Generated/RunStepCompletionUsage.cs | 84 + .../Generated/RunStepDelta.Serialization.cs | 142 + .../src/Generated/RunStepDelta.cs | 73 + .../RunStepDeltaChunk.Serialization.cs | 151 + ...{AssistantFile.cs => RunStepDeltaChunk.cs} | 48 +- .../src/Generated/RunStepDeltaChunkObject.cs | 48 + ...terpreterDetailItemObject.Serialization.cs | 163 + ...tepDeltaCodeInterpreterDetailItemObject.cs | 82 + ...odeInterpreterImageOutput.Serialization.cs | 158 + .../RunStepDeltaCodeInterpreterImageOutput.cs | 41 + ...erpreterImageOutputObject.Serialization.cs | 138 + ...epDeltaCodeInterpreterImageOutputObject.cs | 65 + ...aCodeInterpreterLogOutput.Serialization.cs | 154 + .../RunStepDeltaCodeInterpreterLogOutput.cs | 41 + ...eltaCodeInterpreterOutput.Serialization.cs | 129 + .../RunStepDeltaCodeInterpreterOutput.cs | 80 + ...taCodeInterpreterToolCall.Serialization.cs | 166 + .../RunStepDeltaCodeInterpreterToolCall.cs | 46 + .../RunStepDeltaDetail.Serialization.cs | 127 + .../src/Generated/RunStepDeltaDetail.cs | 69 + ...epDeltaFileSearchToolCall.Serialization.cs | 177 + .../RunStepDeltaFileSearchToolCall.cs | 47 + .../RunStepDeltaFunction.Serialization.cs | 172 + .../src/Generated/RunStepDeltaFunction.cs | 73 + ...StepDeltaFunctionToolCall.Serialization.cs | 166 + .../Generated/RunStepDeltaFunctionToolCall.cs | 46 + ...nStepDeltaMessageCreation.Serialization.cs | 150 + .../Generated/RunStepDeltaMessageCreation.cs | 34 + ...eltaMessageCreationObject.Serialization.cs | 138 + .../RunStepDeltaMessageCreationObject.cs | 65 + .../RunStepDeltaToolCall.Serialization.cs | 132 + .../src/Generated/RunStepDeltaToolCall.cs | 89 + ...unStepDeltaToolCallObject.Serialization.cs | 160 + .../Generated/RunStepDeltaToolCallObject.cs | 43 + ...unStepFileSearchToolCall.Serialization.cs} | 52 +- .../Generated/RunStepFileSearchToolCall.cs | 50 + .../src/Generated/RunStepRetrievalToolCall.cs | 50 - .../src/Generated/RunStepStreamEvent.cs | 66 + .../RunStepToolCall.Serialization.cs | 2 +- .../src/Generated/RunStepToolCall.cs | 2 +- .../src/Generated/RunStepToolCallDetails.cs | 6 +- .../src/Generated/RunStreamEvent.cs | 72 + ...itToolOutputsToRunRequest.Serialization.cs | 25 +- .../SubmitToolOutputsToRunRequest.cs | 12 +- .../Generated/ThreadMessage.Serialization.cs | 132 +- .../src/Generated/ThreadMessage.cs | 72 +- ... => ThreadMessageOptions.Serialization.cs} | 73 +- ...tionMessage.cs => ThreadMessageOptions.cs} | 62 +- .../src/Generated/ThreadRun.Serialization.cs | 228 +- .../src/Generated/ThreadRun.cs | 155 +- .../src/Generated/ThreadStreamEvent.cs | 48 + .../Generated/ToolDefinition.Serialization.cs | 2 +- .../src/Generated/ToolDefinition.cs | 2 +- ...tion.cs => ToolResources.Serialization.cs} | 92 +- .../src/Generated/ToolResources.cs | 73 + .../TruncationObject.Serialization.cs | 158 + .../src/Generated/TruncationObject.cs | 91 + .../src/Generated/TruncationStrategy.cs | 51 + ...nknownMessageDeltaContent.Serialization.cs | 143 + .../Generated/UnknownMessageDeltaContent.cs | 29 + ...essageDeltaTextAnnotation.Serialization.cs | 143 + .../UnknownMessageDeltaTextAnnotation.cs | 29 + ...nownMessageTextAnnotation.Serialization.cs | 18 +- .../Generated/UnknownMessageTextAnnotation.cs | 4 +- ...eltaCodeInterpreterOutput.Serialization.cs | 143 + ...nknownRunStepDeltaCodeInterpreterOutput.cs | 29 + ...nknownRunStepDeltaDetail.Serialization.cs} | 46 +- .../Generated/UnknownRunStepDeltaDetail.cs | 28 + ...knownRunStepDeltaToolCall.Serialization.cs | 151 + .../Generated/UnknownRunStepDeltaToolCall.cs | 30 + ...reChunkingStrategyRequest.Serialization.cs | 135 + ...knownVectorStoreChunkingStrategyRequest.cs | 28 + ...eChunkingStrategyResponse.Serialization.cs | 135 + ...nownVectorStoreChunkingStrategyResponse.cs | 28 + .../UpdateAssistantOptions.Serialization.cs | 95 +- .../src/Generated/UpdateAssistantOptions.cs | 92 +- ...teAssistantThreadOptions.Serialization.cs} | 67 +- ...est.cs => UpdateAssistantThreadOptions.cs} | 51 +- ...preterToolResourceOptions.Serialization.cs | 152 + ...pdateCodeInterpreterToolResourceOptions.cs | 66 + ...SearchToolResourceOptions.Serialization.cs | 152 + .../UpdateFileSearchToolResourceOptions.cs | 66 + ...pdateToolResourcesOptions.Serialization.cs | 157 + .../Generated/UpdateToolResourcesOptions.cs | 79 + .../Generated/VectorStore.Serialization.cs | 284 + .../src/Generated/VectorStore.cs | 132 + ...toChunkingStrategyRequest.Serialization.cs | 135 + .../VectorStoreAutoChunkingStrategyRequest.cs | 29 + ...oChunkingStrategyResponse.Serialization.cs | 135 + ...VectorStoreAutoChunkingStrategyResponse.cs | 29 + ...reChunkingStrategyRequest.Serialization.cs | 127 + .../VectorStoreChunkingStrategyRequest.cs | 69 + .../VectorStoreChunkingStrategyRequestType.cs | 51 + ...eChunkingStrategyResponse.Serialization.cs | 127 + .../VectorStoreChunkingStrategyResponse.cs | 69 + ...VectorStoreChunkingStrategyResponseType.cs | 51 + ...ectorStoreDeletionStatus.Serialization.cs} | 46 +- ...Status.cs => VectorStoreDeletionStatus.cs} | 22 +- .../VectorStoreDeletionStatusObject.cs | 48 + ...ctorStoreExpirationPolicy.Serialization.cs | 143 + .../Generated/VectorStoreExpirationPolicy.cs | 78 + .../VectorStoreExpirationPolicyAnchor.cs | 48 + .../VectorStoreFile.Serialization.cs | 212 + .../src/Generated/VectorStoreFile.cs | 139 + .../VectorStoreFileBatch.Serialization.cs | 182 + .../src/Generated/VectorStoreFileBatch.cs | 106 + .../Generated/VectorStoreFileBatchObject.cs | 48 + .../Generated/VectorStoreFileBatchStatus.cs | 57 + .../VectorStoreFileCount.Serialization.cs | 173 + .../src/Generated/VectorStoreFileCount.cs | 96 + ...orStoreFileDeletionStatus.Serialization.cs | 151 + .../VectorStoreFileDeletionStatus.cs | 85 + .../VectorStoreFileDeletionStatusObject.cs | 48 + .../VectorStoreFileError.Serialization.cs | 143 + .../src/Generated/VectorStoreFileError.cs | 81 + .../src/Generated/VectorStoreFileErrorCode.cs | 57 + .../src/Generated/VectorStoreFileObject.cs | 48 + .../src/Generated/VectorStoreFileStatus.cs | 57 + .../Generated/VectorStoreFileStatusFilter.cs | 57 + .../src/Generated/VectorStoreObject.cs | 48 + .../VectorStoreOptions.Serialization.cs | 232 + .../src/Generated/VectorStoreOptions.cs | 91 + ...icChunkingStrategyOptions.Serialization.cs | 143 + ...ectorStoreStaticChunkingStrategyOptions.cs | 87 + ...icChunkingStrategyRequest.Serialization.cs | 143 + ...ectorStoreStaticChunkingStrategyRequest.cs | 44 + ...cChunkingStrategyResponse.Serialization.cs | 143 + ...ctorStoreStaticChunkingStrategyResponse.cs | 44 + .../src/Generated/VectorStoreStatus.cs | 54 + .../VectorStoreUpdateOptions.Serialization.cs | 206 + ...Request.cs => VectorStoreUpdateOptions.cs} | 22 +- .../tsp-location.yaml | 5 +- 310 files changed, 38363 insertions(+), 2189 deletions(-) create mode 100644 sdk/apicenter/azure.ApiCenter/tsp-location.yaml create mode 100644 sdk/appconfiguration/Azure.Data.AppConfiguration/Configuration.json delete mode 100644 sdk/appconfiguration/Azure.Data.AppConfiguration/src/autorest.md create mode 100644 sdk/appconfiguration/Azure.Data.AppConfiguration/tsp-location.yaml create mode 100644 sdk/appconfiguration/Azure.Data.AppConfiguration/tspCodeModel.json create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/LiveMetrics.sln create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/AggregationType.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/CollectionConfigurationError.Serialization.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/CollectionConfigurationError.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/CollectionConfigurationErrorType.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/CollectionConfigurationInfo.Serialization.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/CollectionConfigurationInfo.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DerivedMetricInfo.Serialization.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DerivedMetricInfo.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Docs/LiveMetricsClient.xml create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentFilterConjunctionGroupInfo.Serialization.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentFilterConjunctionGroupInfo.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentIngress.Serialization.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentIngress.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentStreamInfo.Serialization.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentStreamInfo.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentType.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Event.Serialization.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Event.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Exception.Serialization.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Exception.cs rename sdk/{openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateAssistantFileRequest.Serialization.cs => applicationinsights.livemetrics/LiveMetrics/src/Generated/FilterConjunctionGroupInfo.Serialization.cs} (61%) create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/FilterConjunctionGroupInfo.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/FilterInfo.Serialization.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/FilterInfo.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/Argument.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/ChangeTrackingDictionary.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/ChangeTrackingList.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/ModelSerializationExtensions.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/Optional.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/RequestContentHelper.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/Utf8JsonRequestContent.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/KeyValuePairStringString.Serialization.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/KeyValuePairStringString.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/LiveMetricsClient.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/LiveMetricsClientBuilderExtensions.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/LiveMetricsClientOptions.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/LiveMetricsModelFactory.cs rename sdk/{openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageFile.Serialization.cs => applicationinsights.livemetrics/LiveMetrics/src/Generated/MetricPoint.Serialization.cs} (61%) create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/MetricPoint.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/MonitoringDataPoint.Serialization.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/MonitoringDataPoint.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/PredicateType.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/ProcessCpuData.Serialization.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/ProcessCpuData.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/QuotaConfigurationInfo.Serialization.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/QuotaConfigurationInfo.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/RemoteDependency.Serialization.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/RemoteDependency.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Request.Serialization.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Request.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/TelemetryType.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Trace.Serialization.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Trace.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/UnknownDocumentIngress.Serialization.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/UnknownDocumentIngress.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/LiveMetrics.csproj create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/src/Properties/AssemblyInfo.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/tests/Generated/Samples/Samples_LiveMetricsClient.cs create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/tests/LiveMetrics.Tests.csproj create mode 100644 sdk/applicationinsights.livemetrics/LiveMetrics/tsp-location.yaml create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ApiResponseFormat.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantStreamEvent.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormat.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormat.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatMode.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiToolChoiceOptionMode.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsNamedToolChoice.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsNamedToolChoice.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsNamedToolChoiceType.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CodeInterpreterToolResource.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CodeInterpreterToolResource.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateCodeInterpreterToolResourceOptions.Serialization.cs rename sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/{CreateAssistantFileRequest.cs => CreateCodeInterpreterToolResourceOptions.cs} (64%) rename sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/{ThreadInitializationMessage.Serialization.cs => CreateFileSearchToolResourceVectorStoreOptions.Serialization.cs} (60%) create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateFileSearchToolResourceVectorStoreOptions.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateToolResourcesOptions.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateToolResourcesOptions.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateVectorStoreFileBatchRequest.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateVectorStoreFileBatchRequest.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateVectorStoreFileRequest.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateVectorStoreFileRequest.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/DoneEvent.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ErrorEvent.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolDefinition.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolDefinition.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolDefinitionDetails.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolDefinitionDetails.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolResource.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolResource.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileState.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FunctionName.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FunctionName.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/IncompleteRunDetails.cs delete mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatusObject.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageAttachment.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageAttachment.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDelta.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDelta.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaChunk.Serialization.cs rename sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/{MessageFile.cs => MessageDeltaChunk.cs} (56%) create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaChunkObject.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaContent.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaContent.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaImageFileContent.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaImageFileContent.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaImageFileContentObject.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaImageFileContentObject.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextAnnotation.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextAnnotation.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextContent.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextContent.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextContentObject.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextContentObject.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFileCitationAnnotation.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFileCitationAnnotation.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFileCitationAnnotationObject.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFileCitationAnnotationObject.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFilePathAnnotation.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFilePathAnnotation.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFilePathAnnotationObject.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFilePathAnnotationObject.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageIncompleteDetails.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageIncompleteDetails.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageIncompleteDetailsReason.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageStatus.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageStreamEvent.cs delete mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistantFileObject.cs rename sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/{InternalOpenAIPageableListOfMessageFile.Serialization.cs => OpenAIPageableListOfVectorStore.Serialization.cs} (64%) rename sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/{InternalOpenAIPageableListOfAssistantFile.cs => OpenAIPageableListOfVectorStore.cs} (78%) rename sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/{InternalOpenAIPageableListOfAssistantFile.Serialization.cs => OpenAIPageableListOfVectorStoreFile.Serialization.cs} (63%) rename sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/{InternalOpenAIPageableListOfMessageFile.cs => OpenAIPageableListOfVectorStoreFile.cs} (78%) create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfVectorStoreFileObject.cs rename sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/{OpenAIPageableListOfMessageFileObject.cs => OpenAIPageableListOfVectorStoreObject.cs} (56%) delete mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RetrievalToolDefinition.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunCompletionUsage.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunCompletionUsage.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCompletionUsage.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCompletionUsage.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDelta.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDelta.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaChunk.Serialization.cs rename sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/{AssistantFile.cs => RunStepDeltaChunk.cs} (51%) create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaChunkObject.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterImageOutput.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterImageOutput.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterLogOutput.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterLogOutput.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterOutput.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterOutput.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterToolCall.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterToolCall.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaDetail.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaDetail.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFileSearchToolCall.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFileSearchToolCall.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFunction.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFunction.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFunctionToolCall.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFunctionToolCall.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaMessageCreation.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaMessageCreation.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaMessageCreationObject.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaMessageCreationObject.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaToolCall.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaToolCall.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaToolCallObject.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaToolCallObject.cs rename sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/{RunStepRetrievalToolCall.Serialization.cs => RunStepFileSearchToolCall.Serialization.cs} (66%) create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepFileSearchToolCall.cs delete mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepRetrievalToolCall.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepStreamEvent.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStreamEvent.cs rename sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/{CreateMessageRequest.Serialization.cs => ThreadMessageOptions.Serialization.cs} (69%) rename sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/{ThreadInitializationMessage.cs => ThreadMessageOptions.cs} (53%) create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadStreamEvent.cs rename sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/{AssistantFile.Serialization.cs => ToolResources.Serialization.cs} (59%) create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ToolResources.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/TruncationObject.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/TruncationObject.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/TruncationStrategy.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageDeltaContent.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageDeltaContent.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageDeltaTextAnnotation.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageDeltaTextAnnotation.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.cs rename sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/{RetrievalToolDefinition.Serialization.cs => UnknownRunStepDeltaDetail.Serialization.cs} (60%) create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaDetail.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaToolCall.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaToolCall.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownVectorStoreChunkingStrategyRequest.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownVectorStoreChunkingStrategyRequest.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownVectorStoreChunkingStrategyResponse.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownVectorStoreChunkingStrategyResponse.cs rename sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/{UpdateThreadRequest.Serialization.cs => UpdateAssistantThreadOptions.Serialization.cs} (59%) rename sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/{CreateMessageRequest.cs => UpdateAssistantThreadOptions.cs} (53%) create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateCodeInterpreterToolResourceOptions.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateCodeInterpreterToolResourceOptions.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateFileSearchToolResourceOptions.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateFileSearchToolResourceOptions.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateToolResourcesOptions.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateToolResourcesOptions.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStore.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStore.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreAutoChunkingStrategyRequest.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreAutoChunkingStrategyRequest.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreAutoChunkingStrategyResponse.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreAutoChunkingStrategyResponse.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyRequest.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyRequest.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyRequestType.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyResponse.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyResponse.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyResponseType.cs rename sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/{InternalAssistantFileDeletionStatus.Serialization.cs => VectorStoreDeletionStatus.Serialization.cs} (62%) rename sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/{InternalAssistantFileDeletionStatus.cs => VectorStoreDeletionStatus.cs} (71%) create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreDeletionStatusObject.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreExpirationPolicy.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreExpirationPolicy.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreExpirationPolicyAnchor.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFile.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFile.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileBatch.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileBatch.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileBatchObject.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileBatchStatus.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileCount.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileCount.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileDeletionStatus.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileDeletionStatus.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileDeletionStatusObject.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileError.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileError.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileErrorCode.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileObject.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileStatus.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileStatusFilter.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreObject.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreOptions.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreOptions.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyOptions.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyOptions.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyRequest.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyRequest.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyResponse.Serialization.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyResponse.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStatus.cs create mode 100644 sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreUpdateOptions.Serialization.cs rename sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/{UpdateThreadRequest.cs => VectorStoreUpdateOptions.cs} (69%) diff --git a/sdk/apicenter/azure.ApiCenter/tsp-location.yaml b/sdk/apicenter/azure.ApiCenter/tsp-location.yaml new file mode 100644 index 000000000000..4927f4cc0797 --- /dev/null +++ b/sdk/apicenter/azure.ApiCenter/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/apicenter/ApiCenter.DataApi +commit: abdd04c316cd2e71dc4819b4e78eaceb50bae76c +repo: test-repo-billy/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/src/autorest.md b/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/src/autorest.md index 6b7c086d633b..23105ef9866f 100644 --- a/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/src/autorest.md +++ b/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/src/autorest.md @@ -8,7 +8,7 @@ azure-arm: true csharp: true library-name: AppComplianceAutomation namespace: Azure.ResourceManager.AppComplianceAutomation -require: https://github.com/Azure/azure-rest-api-specs/blob/f28f14c35918513bd3c3cf9f30d31ee192602525/specification/appcomplianceautomation/resource-manager/readme.md +require: /mnt/vss/_work/1/s/azure-rest-api-specs/specification/appcomplianceautomation/resource-manager/readme.md #tag: package-2024-06 output-folder: $(this-folder)/Generated clear-output-folder: true diff --git a/sdk/appconfiguration/Azure.Data.AppConfiguration/Configuration.json b/sdk/appconfiguration/Azure.Data.AppConfiguration/Configuration.json new file mode 100644 index 000000000000..cfbe79f737bb --- /dev/null +++ b/sdk/appconfiguration/Azure.Data.AppConfiguration/Configuration.json @@ -0,0 +1,12 @@ +{ + "output-folder": ".", + "namespace": "Azure.Data.AppConfiguration", + "library-name": "Azure.Data.AppConfiguration", + "model-namespace": false, + "flavor": "azure", + "use-model-reader-writer": true, + "shared-source-folders": [ + "../../TempTypeSpecFiles/node_modules/@autorest/csharp/Generator.Shared", + "../../TempTypeSpecFiles/node_modules/@autorest/csharp/Azure.Core.Shared" + ] +} diff --git a/sdk/appconfiguration/Azure.Data.AppConfiguration/src/autorest.md b/sdk/appconfiguration/Azure.Data.AppConfiguration/src/autorest.md deleted file mode 100644 index af1f2ccf84c9..000000000000 --- a/sdk/appconfiguration/Azure.Data.AppConfiguration/src/autorest.md +++ /dev/null @@ -1,55 +0,0 @@ -# Azure SDK Code Generation for Data Plane - -Run `dotnet build /t:GenerateCode` to generate code. - -### AutoRest Configuration -> see https://aka.ms/autorest -``` yaml -input-file: -- https://github.com/Azure/azure-rest-api-specs/blob/c1af3ab8e803da2f40fc90217a6d023bc13b677f/specification/appconfiguration/data-plane/Microsoft.AppConfiguration/stable/2023-11-01/appconfiguration.json -namespace: Azure.Data.AppConfiguration -title: ConfigurationClient -``` - -### Change Endpoint type to Uri -``` yaml -directive: - from: swagger-document - where: $.parameters.Endpoint - transform: $.format = "url" - ``` - -### Modify operation names -``` yaml -directive: -- rename-operation: - from: PutKeyValue - to: SetConfigurationSetting -- rename-operation: - from: DeleteKeyValue - to: DeleteConfigurationSetting -- rename-operation: - from: GetKeyValue - to: GetConfigurationSetting -- rename-operation: - from: GetKeyValues - to: GetConfigurationSettings -- rename-operation: - from: PutLock - to: CreateReadOnlyLock -- rename-operation: - from: DeleteLock - to: DeleteReadOnlyLock -- rename-operation: - from: UpdateSnapshot - to: UpdateSnapshotStatus -``` - -### Internalize protocol methods -``` yaml -directive: - from: swagger-document - where: $.paths.*.* - transform: > - $["x-accessibility"] = "internal" -``` diff --git a/sdk/appconfiguration/Azure.Data.AppConfiguration/tsp-location.yaml b/sdk/appconfiguration/Azure.Data.AppConfiguration/tsp-location.yaml new file mode 100644 index 000000000000..4423382eb7fd --- /dev/null +++ b/sdk/appconfiguration/Azure.Data.AppConfiguration/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/appconfiguration/AppConfiguration +commit: abdd04c316cd2e71dc4819b4e78eaceb50bae76c +repo: test-repo-billy/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/appconfiguration/Azure.Data.AppConfiguration/tspCodeModel.json b/sdk/appconfiguration/Azure.Data.AppConfiguration/tspCodeModel.json new file mode 100644 index 000000000000..42842361aaca --- /dev/null +++ b/sdk/appconfiguration/Azure.Data.AppConfiguration/tspCodeModel.json @@ -0,0 +1,7543 @@ +{ + "$id": "1", + "Name": "AzureAppConfiguration", + "ApiVersions": [ + "2023-11-01" + ], + "Enums": [ + { + "$id": "2", + "Kind": "enum", + "Name": "GetKeysResponseContentType", + "CrossLanguageDefinitionId": "getKeys.ResponseContentType.anonymous", + "ValueType": { + "$id": "3", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "4", + "Name": "application/vnd.microsoft.appconfig.keyset+json", + "Value": "application/vnd.microsoft.appconfig.keyset+json", + "Decorators": [] + }, + { + "$id": "5", + "Name": "application/problem+json", + "Value": "application/problem+json", + "Decorators": [] + } + ], + "IsExtensible": false, + "Usage": "Output", + "Decorators": [] + }, + { + "$id": "6", + "Kind": "enum", + "Name": "KeyValueFields", + "CrossLanguageDefinitionId": "AzureAppConfiguration.KeyValueFields", + "ValueType": { + "$id": "7", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "8", + "Name": "key", + "Value": "key", + "Description": "Key field.", + "Decorators": [] + }, + { + "$id": "9", + "Name": "label", + "Value": "label", + "Description": "Label field.", + "Decorators": [] + }, + { + "$id": "10", + "Name": "content_type", + "Value": "content_type", + "Description": "Content type field.", + "Decorators": [] + }, + { + "$id": "11", + "Name": "value", + "Value": "value", + "Description": "Value field.", + "Decorators": [] + }, + { + "$id": "12", + "Name": "last_modified", + "Value": "last_modified", + "Description": "Last modified field.", + "Decorators": [] + }, + { + "$id": "13", + "Name": "tags", + "Value": "tags", + "Description": "Tags field.", + "Decorators": [] + }, + { + "$id": "14", + "Name": "locked", + "Value": "locked", + "Description": "Locked field.", + "Decorators": [] + }, + { + "$id": "15", + "Name": "etag", + "Value": "etag", + "Description": "Etag field.", + "Decorators": [] + } + ], + "Description": "Key-value fields.", + "IsExtensible": true, + "Usage": "Input", + "Decorators": [] + }, + { + "$id": "16", + "Kind": "enum", + "Name": "GetKeyValuesResponseContentType", + "CrossLanguageDefinitionId": "getKeyValues.ResponseContentType.anonymous", + "ValueType": { + "$id": "17", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "18", + "Name": "application/vnd.microsoft.appconfig.kvset+json", + "Value": "application/vnd.microsoft.appconfig.kvset+json", + "Decorators": [] + }, + { + "$id": "19", + "Name": "application/problem+json", + "Value": "application/problem+json", + "Decorators": [] + } + ], + "IsExtensible": false, + "Usage": "Output", + "Decorators": [] + }, + { + "$id": "20", + "Kind": "enum", + "Name": "GetKeyValueResponseContentType", + "CrossLanguageDefinitionId": "getKeyValue.ResponseContentType.anonymous", + "ValueType": { + "$id": "21", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "22", + "Name": "application/vnd.microsoft.appconfig.kv+json", + "Value": "application/vnd.microsoft.appconfig.kv+json", + "Decorators": [] + }, + { + "$id": "23", + "Name": "application/problem+json", + "Value": "application/problem+json", + "Decorators": [] + } + ], + "IsExtensible": false, + "Usage": "Output", + "Decorators": [] + }, + { + "$id": "24", + "Kind": "enum", + "Name": "PutKeyValueRequestContentType", + "CrossLanguageDefinitionId": "putKeyValue.RequestContentType.anonymous", + "ValueType": { + "$id": "25", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "26", + "Name": "application/vnd.microsoft.appconfig.kv+json", + "Value": "application/vnd.microsoft.appconfig.kv+json", + "Decorators": [] + }, + { + "$id": "27", + "Name": "application/vnd.microsoft.appconfig.kvset+json", + "Value": "application/vnd.microsoft.appconfig.kvset+json", + "Decorators": [] + }, + { + "$id": "28", + "Name": "application/json", + "Value": "application/json", + "Decorators": [] + }, + { + "$id": "29", + "Name": "text/json", + "Value": "text/json", + "Decorators": [] + }, + { + "$id": "30", + "Name": "application/*+json", + "Value": "application/*+json", + "Decorators": [] + }, + { + "$id": "31", + "Name": "application/json-patch+json", + "Value": "application/json-patch+json", + "Decorators": [] + } + ], + "IsExtensible": false, + "Usage": "Input", + "Decorators": [] + }, + { + "$id": "32", + "Kind": "enum", + "Name": "PutKeyValueResponseContentType", + "CrossLanguageDefinitionId": "putKeyValue.ResponseContentType.anonymous", + "ValueType": { + "$id": "33", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "34", + "Name": "application/vnd.microsoft.appconfig.kv+json", + "Value": "application/vnd.microsoft.appconfig.kv+json", + "Decorators": [] + }, + { + "$id": "35", + "Name": "application/problem+json", + "Value": "application/problem+json", + "Decorators": [] + } + ], + "IsExtensible": false, + "Usage": "Output", + "Decorators": [] + }, + { + "$id": "36", + "Kind": "enum", + "Name": "DeleteKeyValueResponseContentType", + "CrossLanguageDefinitionId": "deleteKeyValue.ResponseContentType.anonymous", + "ValueType": { + "$id": "37", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "38", + "Name": "application/vnd.microsoft.appconfig.kv+json", + "Value": "application/vnd.microsoft.appconfig.kv+json", + "Decorators": [] + }, + { + "$id": "39", + "Name": "application/problem+json", + "Value": "application/problem+json", + "Decorators": [] + } + ], + "IsExtensible": false, + "Usage": "Output", + "Decorators": [] + }, + { + "$id": "40", + "Kind": "enum", + "Name": "SnapshotFields", + "CrossLanguageDefinitionId": "AzureAppConfiguration.SnapshotFields", + "ValueType": { + "$id": "41", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "42", + "Name": "name", + "Value": "name", + "Description": "Name field.", + "Decorators": [] + }, + { + "$id": "43", + "Name": "status", + "Value": "status", + "Description": "Status field.", + "Decorators": [] + }, + { + "$id": "44", + "Name": "filters", + "Value": "filters", + "Description": "Filters field.", + "Decorators": [] + }, + { + "$id": "45", + "Name": "composition_type", + "Value": "composition_type", + "Description": "Composition type field.", + "Decorators": [] + }, + { + "$id": "46", + "Name": "created", + "Value": "created", + "Description": "Created field.", + "Decorators": [] + }, + { + "$id": "47", + "Name": "expires", + "Value": "expires", + "Description": "Expires field.", + "Decorators": [] + }, + { + "$id": "48", + "Name": "retention_period", + "Value": "retention_period", + "Description": "Retention period field.", + "Decorators": [] + }, + { + "$id": "49", + "Name": "size", + "Value": "size", + "Description": "Size field.", + "Decorators": [] + }, + { + "$id": "50", + "Name": "items_count", + "Value": "items_count", + "Description": "Items count field.", + "Decorators": [] + }, + { + "$id": "51", + "Name": "tags", + "Value": "tags", + "Description": "Tags field.", + "Decorators": [] + }, + { + "$id": "52", + "Name": "etag", + "Value": "etag", + "Description": "Etag field.", + "Decorators": [] + } + ], + "Description": "Snapshot fields.", + "IsExtensible": true, + "Usage": "Input", + "Decorators": [] + }, + { + "$id": "53", + "Kind": "enum", + "Name": "SnapshotStatus", + "CrossLanguageDefinitionId": "AzureAppConfiguration.SnapshotStatus", + "ValueType": { + "$id": "54", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "55", + "Name": "provisioning", + "Value": "provisioning", + "Description": "Provisioning", + "Decorators": [] + }, + { + "$id": "56", + "Name": "ready", + "Value": "ready", + "Description": "Ready", + "Decorators": [] + }, + { + "$id": "57", + "Name": "archived", + "Value": "archived", + "Description": "Archived", + "Decorators": [] + }, + { + "$id": "58", + "Name": "failed", + "Value": "failed", + "Description": "Failed", + "Decorators": [] + } + ], + "Description": "Snapshot status.", + "IsExtensible": true, + "Usage": "Input,Output,JsonMergePatch,Json", + "Decorators": [] + }, + { + "$id": "59", + "Kind": "enum", + "Name": "CompositionType", + "CrossLanguageDefinitionId": "AzureAppConfiguration.CompositionType", + "ValueType": { + "$id": "60", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "61", + "Name": "key", + "Value": "key", + "Description": "The 'key' composition type.", + "Decorators": [] + }, + { + "$id": "62", + "Name": "key_label", + "Value": "key_label", + "Description": "The 'key_label' composition type.", + "Decorators": [] + } + ], + "Description": "Composition types.", + "IsExtensible": true, + "Usage": "Input,Output,Json", + "Decorators": [] + }, + { + "$id": "63", + "Kind": "enum", + "Name": "GetSnapshotsResponseContentType", + "CrossLanguageDefinitionId": "getSnapshots.ResponseContentType.anonymous", + "ValueType": { + "$id": "64", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "65", + "Name": "application/vnd.microsoft.appconfig.snapshotset+json", + "Value": "application/vnd.microsoft.appconfig.snapshotset+json", + "Decorators": [] + }, + { + "$id": "66", + "Name": "application/problem+json", + "Value": "application/problem+json", + "Decorators": [] + } + ], + "IsExtensible": false, + "Usage": "Output", + "Decorators": [] + }, + { + "$id": "67", + "Kind": "enum", + "Name": "GetSnapshotResponseContentType", + "CrossLanguageDefinitionId": "getSnapshot.ResponseContentType.anonymous", + "ValueType": { + "$id": "68", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "69", + "Name": "application/vnd.microsoft.appconfig.snapshot+json", + "Value": "application/vnd.microsoft.appconfig.snapshot+json", + "Decorators": [] + }, + { + "$id": "70", + "Name": "application/problem+json", + "Value": "application/problem+json", + "Decorators": [] + } + ], + "IsExtensible": false, + "Usage": "Output", + "Decorators": [] + }, + { + "$id": "71", + "Kind": "enum", + "Name": "OperationState", + "CrossLanguageDefinitionId": "Azure.Core.Foundations.OperationState", + "ValueType": { + "$id": "72", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "73", + "Name": "NotStarted", + "Value": "NotStarted", + "Description": "The operation has not started.", + "Decorators": [] + }, + { + "$id": "74", + "Name": "Running", + "Value": "Running", + "Description": "The operation is in progress.", + "Decorators": [] + }, + { + "$id": "75", + "Name": "Succeeded", + "Value": "Succeeded", + "Description": "The operation has completed successfully.", + "Decorators": [] + }, + { + "$id": "76", + "Name": "Failed", + "Value": "Failed", + "Description": "The operation has failed.", + "Decorators": [] + }, + { + "$id": "77", + "Name": "Canceled", + "Value": "Canceled", + "Description": "The operation has been canceled by the user.", + "Decorators": [] + } + ], + "Description": "Enum describing allowed operation states.", + "IsExtensible": true, + "Usage": "None", + "Decorators": [] + }, + { + "$id": "78", + "Kind": "enum", + "Name": "CreateSnapshotRequestContentType", + "CrossLanguageDefinitionId": "createSnapshot.RequestContentType.anonymous", + "ValueType": { + "$id": "79", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "80", + "Name": "application/vnd.microsoft.appconfig.snapshot+json", + "Value": "application/vnd.microsoft.appconfig.snapshot+json", + "Decorators": [] + }, + { + "$id": "81", + "Name": "application/json", + "Value": "application/json", + "Decorators": [] + } + ], + "IsExtensible": false, + "Usage": "Input", + "Decorators": [] + }, + { + "$id": "82", + "Kind": "enum", + "Name": "CreateSnapshotResponseContentType", + "CrossLanguageDefinitionId": "createSnapshot.ResponseContentType.anonymous", + "ValueType": { + "$id": "83", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "84", + "Name": "application/vnd.microsoft.appconfig.snapshot+json", + "Value": "application/vnd.microsoft.appconfig.snapshot+json", + "Decorators": [] + }, + { + "$id": "85", + "Name": "application/problem+json", + "Value": "application/problem+json", + "Decorators": [] + } + ], + "IsExtensible": false, + "Usage": "Output", + "Decorators": [] + }, + { + "$id": "86", + "Kind": "enum", + "Name": "UpdateSnapshotRequestContentType", + "CrossLanguageDefinitionId": "updateSnapshot.RequestContentType.anonymous", + "ValueType": { + "$id": "87", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "88", + "Name": "application/merge-patch+json", + "Value": "application/merge-patch+json", + "Decorators": [] + }, + { + "$id": "89", + "Name": "application/json", + "Value": "application/json", + "Decorators": [] + } + ], + "IsExtensible": false, + "Usage": "Input", + "Decorators": [] + }, + { + "$id": "90", + "Kind": "enum", + "Name": "UpdateSnapshotResponseContentType", + "CrossLanguageDefinitionId": "updateSnapshot.ResponseContentType.anonymous", + "ValueType": { + "$id": "91", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "92", + "Name": "application/vnd.microsoft.appconfig.snapshot+json", + "Value": "application/vnd.microsoft.appconfig.snapshot+json", + "Decorators": [] + }, + { + "$id": "93", + "Name": "application/problem+json", + "Value": "application/problem+json", + "Decorators": [] + } + ], + "IsExtensible": false, + "Usage": "Output", + "Decorators": [] + }, + { + "$id": "94", + "Kind": "enum", + "Name": "LabelFields", + "CrossLanguageDefinitionId": "AzureAppConfiguration.LabelFields", + "ValueType": { + "$id": "95", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "96", + "Name": "name", + "Value": "name", + "Description": "Name field.", + "Decorators": [] + } + ], + "Description": "Label fields.", + "IsExtensible": true, + "Usage": "Input", + "Decorators": [] + }, + { + "$id": "97", + "Kind": "enum", + "Name": "GetLabelsResponseContentType", + "CrossLanguageDefinitionId": "getLabels.ResponseContentType.anonymous", + "ValueType": { + "$id": "98", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "99", + "Name": "application/vnd.microsoft.appconfig.labelset+json", + "Value": "application/vnd.microsoft.appconfig.labelset+json", + "Decorators": [] + }, + { + "$id": "100", + "Name": "application/problem+json", + "Value": "application/problem+json", + "Decorators": [] + } + ], + "IsExtensible": false, + "Usage": "Output", + "Decorators": [] + }, + { + "$id": "101", + "Kind": "enum", + "Name": "PutLockResponseContentType", + "CrossLanguageDefinitionId": "putLock.ResponseContentType.anonymous", + "ValueType": { + "$id": "102", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "103", + "Name": "application/vnd.microsoft.appconfig.kv+json", + "Value": "application/vnd.microsoft.appconfig.kv+json", + "Decorators": [] + }, + { + "$id": "104", + "Name": "application/problem+json", + "Value": "application/problem+json", + "Decorators": [] + } + ], + "IsExtensible": false, + "Usage": "Output", + "Decorators": [] + }, + { + "$id": "105", + "Kind": "enum", + "Name": "DeleteLockResponseContentType", + "CrossLanguageDefinitionId": "deleteLock.ResponseContentType.anonymous", + "ValueType": { + "$id": "106", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "107", + "Name": "application/vnd.microsoft.appconfig.kv+json", + "Value": "application/vnd.microsoft.appconfig.kv+json", + "Decorators": [] + }, + { + "$id": "108", + "Name": "application/problem+json", + "Value": "application/problem+json", + "Decorators": [] + } + ], + "IsExtensible": false, + "Usage": "Output", + "Decorators": [] + }, + { + "$id": "109", + "Kind": "enum", + "Name": "GetRevisionsResponseContentType", + "CrossLanguageDefinitionId": "getRevisions.ResponseContentType.anonymous", + "ValueType": { + "$id": "110", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "111", + "Name": "application/vnd.microsoft.appconfig.kvset+json", + "Value": "application/vnd.microsoft.appconfig.kvset+json", + "Decorators": [] + }, + { + "$id": "112", + "Name": "application/problem+json", + "Value": "application/problem+json", + "Decorators": [] + } + ], + "IsExtensible": false, + "Usage": "Output", + "Decorators": [] + }, + { + "$id": "113", + "Kind": "enum", + "Name": "Versions", + "CrossLanguageDefinitionId": "AzureAppConfiguration.Versions", + "ValueType": { + "$id": "114", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Values": [ + { + "$id": "115", + "Name": "v2023_11_01", + "Value": "2023-11-01", + "Description": "The 2023-11-01 API version", + "Decorators": [] + } + ], + "Description": "Service API versions", + "IsExtensible": false, + "Usage": "ApiVersionEnum", + "Decorators": [] + } + ], + "Models": [ + { + "$id": "116", + "Kind": "model", + "Name": "KeyListResult", + "CrossLanguageDefinitionId": "AzureAppConfiguration.KeyListResult", + "Usage": "Output,Json", + "Description": "The result of a list request.", + "Decorators": [], + "Properties": [ + { + "$id": "117", + "Name": "items", + "SerializedName": "items", + "Description": "The collection value.", + "Type": { + "$id": "118", + "Kind": "array", + "Name": "ArrayKey", + "ValueType": { + "$id": "119", + "Kind": "model", + "Name": "Key", + "CrossLanguageDefinitionId": "AzureAppConfiguration.Key", + "Usage": "Output,Json", + "Description": "Keys serve as identifiers for key-values and are used to store and retrieve corresponding values.", + "Decorators": [], + "Properties": [ + { + "$id": "120", + "Name": "name", + "SerializedName": "name", + "Description": "The name of the key.", + "Type": { + "$id": "121", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": true, + "IsReadOnly": true, + "Decorators": [] + } + ] + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "122", + "Name": "@nextLink", + "SerializedName": "@nextLink", + "Description": "The URI that can be used to request the next set of paged results.", + "Type": { + "$id": "123", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + } + ] + }, + { + "$ref": "119" + }, + { + "$id": "124", + "Kind": "model", + "Name": "Error", + "CrossLanguageDefinitionId": "AzureAppConfiguration.Error", + "Usage": "Output,Error,Json", + "Description": "Azure App Configuration error object.", + "Decorators": [], + "Properties": [ + { + "$id": "125", + "Name": "type", + "SerializedName": "type", + "Description": "The type of the error.", + "Type": { + "$id": "126", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "127", + "Name": "title", + "SerializedName": "title", + "Description": "A brief summary of the error.", + "Type": { + "$id": "128", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "129", + "Name": "name", + "SerializedName": "name", + "Description": "The name of the parameter that resulted in the error.", + "Type": { + "$id": "130", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "131", + "Name": "detail", + "SerializedName": "detail", + "Description": "A detailed description of the error.", + "Type": { + "$id": "132", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "133", + "Name": "status", + "SerializedName": "status", + "Description": "The HTTP status code that the error maps to.", + "Type": { + "$id": "134", + "Kind": "int32", + "Name": "int32", + "CrossLanguageDefinitionId": "TypeSpec.int32", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + } + ] + }, + { + "$id": "135", + "Kind": "model", + "Name": "KeyValueListResult", + "CrossLanguageDefinitionId": "AzureAppConfiguration.KeyValueListResult", + "Usage": "Output,Json", + "Description": "The result of a list request.", + "Decorators": [], + "Properties": [ + { + "$id": "136", + "Name": "items", + "SerializedName": "items", + "Description": "The collection value.", + "Type": { + "$id": "137", + "Kind": "array", + "Name": "ArrayKeyValue", + "ValueType": { + "$id": "138", + "Kind": "model", + "Name": "KeyValue", + "CrossLanguageDefinitionId": "AzureAppConfiguration.KeyValue", + "Usage": "Input,Output,Json", + "Description": "A key-value pair representing application settings.", + "Decorators": [], + "Properties": [ + { + "$id": "139", + "Name": "key", + "SerializedName": "key", + "Description": "The key of the key-value.", + "Type": { + "$id": "140", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": true, + "IsReadOnly": true, + "Decorators": [] + }, + { + "$id": "141", + "Name": "label", + "SerializedName": "label", + "Description": "The label the key-value belongs to.", + "Type": { + "$id": "142", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "143", + "Name": "contentType", + "SerializedName": "content_type", + "Description": "The content type of the value stored within the key-value.", + "Type": { + "$id": "144", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "145", + "Name": "value", + "SerializedName": "value", + "Description": "The value of the key-value.", + "Type": { + "$id": "146", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "147", + "Name": "lastModified", + "SerializedName": "last_modified", + "Description": "A date representing the last time the key-value was modified.", + "Type": { + "$id": "148", + "Kind": "offsetDateTime", + "Name": "offsetDateTime", + "Encode": "rfc3339", + "WireType": { + "$id": "149", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "CrossLanguageDefinitionId": "TypeSpec.offsetDateTime", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "150", + "Name": "tags", + "SerializedName": "tags", + "Description": "The tags of the key-value", + "Type": { + "$id": "151", + "Kind": "dict", + "KeyType": { + "$id": "152", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "ValueType": { + "$id": "153", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "154", + "Name": "locked", + "SerializedName": "locked", + "Description": "Indicates whether the key-value is locked.", + "Type": { + "$id": "155", + "Kind": "boolean", + "Name": "boolean", + "CrossLanguageDefinitionId": "TypeSpec.boolean", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "156", + "Name": "etag", + "SerializedName": "etag", + "Description": "A value representing the current state of the resource.", + "Type": { + "$id": "157", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + } + ] + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "158", + "Name": "etag", + "SerializedName": "etag", + "Description": "An identifier representing the returned state of the resource.", + "Type": { + "$id": "159", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "160", + "Name": "@nextLink", + "SerializedName": "@nextLink", + "Description": "The URI that can be used to request the next set of paged results.", + "Type": { + "$id": "161", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + } + ] + }, + { + "$ref": "138" + }, + { + "$id": "162", + "Kind": "model", + "Name": "SnapshotListResult", + "CrossLanguageDefinitionId": "AzureAppConfiguration.SnapshotListResult", + "Usage": "Output,Json", + "Description": "The result of a snapshot list request.", + "Decorators": [], + "Properties": [ + { + "$id": "163", + "Name": "items", + "SerializedName": "items", + "Description": "The collection value.", + "Type": { + "$id": "164", + "Kind": "array", + "Name": "ArraySnapshot", + "ValueType": { + "$id": "165", + "Kind": "model", + "Name": "Snapshot", + "CrossLanguageDefinitionId": "AzureAppConfiguration.Snapshot", + "Usage": "Input,Output,Json", + "Description": "A snapshot is a named, immutable subset of an App Configuration store's key-values.", + "Decorators": [], + "Properties": [ + { + "$id": "166", + "Name": "name", + "SerializedName": "name", + "Description": "The name of the snapshot.", + "Type": { + "$id": "167", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": true, + "IsReadOnly": true, + "Decorators": [] + }, + { + "$id": "168", + "Name": "status", + "SerializedName": "status", + "Description": "The current status of the snapshot.", + "Type": { + "$ref": "53" + }, + "IsRequired": false, + "IsReadOnly": true, + "Decorators": [] + }, + { + "$id": "169", + "Name": "filters", + "SerializedName": "filters", + "Description": "A list of filters used to filter the key-values included in the snapshot.", + "Type": { + "$id": "170", + "Kind": "array", + "Name": "ArrayKeyValueFilter", + "ValueType": { + "$id": "171", + "Kind": "model", + "Name": "KeyValueFilter", + "CrossLanguageDefinitionId": "AzureAppConfiguration.KeyValueFilter", + "Usage": "Input,Output,Json", + "Description": "Enables filtering of key-values. Syntax reference:\nhttps://aka.ms/azconfig/docs/restapisnapshots", + "Decorators": [], + "Properties": [ + { + "$id": "172", + "Name": "key", + "SerializedName": "key", + "Description": "Filters key-values by their key field.", + "Type": { + "$id": "173", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": true, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "174", + "Name": "label", + "SerializedName": "label", + "Description": "Filters key-values by their label field.", + "Type": { + "$id": "175", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "176", + "Name": "tags", + "SerializedName": "tags", + "Description": "Filters key-values by their tags field.", + "Type": { + "$id": "177", + "Kind": "array", + "Name": "Array", + "ValueType": { + "$id": "178", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + } + ] + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "IsRequired": true, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "179", + "Name": "compositionType", + "SerializedName": "composition_type", + "Description": "The composition type describes how the key-values within the snapshot are\ncomposed. The 'key' composition type ensures there are no two key-values\ncontaining the same key. The 'key_label' composition type ensures there are no\ntwo key-values containing the same key and label.", + "Type": { + "$ref": "59" + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "180", + "Name": "created", + "SerializedName": "created", + "Description": "The time that the snapshot was created.", + "Type": { + "$id": "181", + "Kind": "offsetDateTime", + "Name": "offsetDateTime", + "Encode": "rfc3339", + "WireType": { + "$id": "182", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "CrossLanguageDefinitionId": "TypeSpec.offsetDateTime", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": true, + "Decorators": [] + }, + { + "$id": "183", + "Name": "expires", + "SerializedName": "expires", + "Description": "The time that the snapshot will expire.", + "Type": { + "$id": "184", + "Kind": "offsetDateTime", + "Name": "offsetDateTime", + "Encode": "rfc3339", + "WireType": { + "$id": "185", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "CrossLanguageDefinitionId": "TypeSpec.offsetDateTime", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": true, + "Decorators": [] + }, + { + "$id": "186", + "Name": "retentionPeriod", + "SerializedName": "retention_period", + "Description": "The amount of time, in seconds, that a snapshot will remain in the archived\nstate before expiring. This property is only writable during the creation of a\nsnapshot. If not specified, the default lifetime of key-value revisions will be\nused.", + "Type": { + "$id": "187", + "Kind": "int64", + "Name": "int64", + "CrossLanguageDefinitionId": "TypeSpec.int64", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "188", + "Name": "size", + "SerializedName": "size", + "Description": "The size in bytes of the snapshot.", + "Type": { + "$id": "189", + "Kind": "int64", + "Name": "int64", + "CrossLanguageDefinitionId": "TypeSpec.int64", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": true, + "Decorators": [] + }, + { + "$id": "190", + "Name": "itemsCount", + "SerializedName": "items_count", + "Description": "The amount of key-values in the snapshot.", + "Type": { + "$id": "191", + "Kind": "int64", + "Name": "int64", + "CrossLanguageDefinitionId": "TypeSpec.int64", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": true, + "Decorators": [] + }, + { + "$id": "192", + "Name": "tags", + "SerializedName": "tags", + "Description": "The tags of the snapshot.", + "Type": { + "$id": "193", + "Kind": "dict", + "KeyType": { + "$id": "194", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "ValueType": { + "$id": "195", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "196", + "Name": "etag", + "SerializedName": "etag", + "Description": "A value representing the current state of the snapshot.", + "Type": { + "$id": "197", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": true, + "Decorators": [] + } + ] + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "198", + "Name": "@nextLink", + "SerializedName": "@nextLink", + "Description": "The URI that can be used to request the next set of paged results.", + "Type": { + "$id": "199", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + } + ] + }, + { + "$ref": "165" + }, + { + "$ref": "171" + }, + { + "$id": "200", + "Kind": "model", + "Name": "OperationDetails", + "CrossLanguageDefinitionId": "AzureAppConfiguration.OperationDetails", + "Usage": "Output,Json", + "Description": "Details of a long running operation.", + "Decorators": [], + "Properties": [ + { + "$id": "201", + "Name": "id", + "SerializedName": "id", + "Description": "The unique id of the operation.", + "Type": { + "$id": "202", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": true, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "203", + "Name": "status", + "SerializedName": "status", + "Description": "The current status of the operation", + "Type": { + "$ref": "71" + }, + "IsRequired": true, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "204", + "Name": "error", + "SerializedName": "error", + "Description": "An error, available when the status is `Failed`, describing why the operation\nfailed.", + "Type": { + "$ref": "124" + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + } + ] + }, + { + "$id": "205", + "Kind": "model", + "Name": "SnapshotUpdateParameters", + "CrossLanguageDefinitionId": "AzureAppConfiguration.SnapshotUpdateParameters", + "Usage": "Input,JsonMergePatch,Json", + "Description": "Parameters used to update a snapshot.", + "Decorators": [], + "Properties": [ + { + "$id": "206", + "Name": "status", + "SerializedName": "status", + "Description": "The desired status of the snapshot.", + "Type": { + "$ref": "53" + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + } + ] + }, + { + "$id": "207", + "Kind": "model", + "Name": "LabelListResult", + "CrossLanguageDefinitionId": "AzureAppConfiguration.LabelListResult", + "Usage": "Output,Json", + "Description": "The result of a list request.", + "Decorators": [], + "Properties": [ + { + "$id": "208", + "Name": "items", + "SerializedName": "items", + "Description": "The collection value.", + "Type": { + "$id": "209", + "Kind": "array", + "Name": "ArrayLabel", + "ValueType": { + "$id": "210", + "Kind": "model", + "Name": "Label", + "CrossLanguageDefinitionId": "AzureAppConfiguration.Label", + "Usage": "Output,Json", + "Description": "Labels are used to group key-values.", + "Decorators": [], + "Properties": [ + { + "$id": "211", + "Name": "name", + "SerializedName": "name", + "Description": "The name of the label.", + "Type": { + "$id": "212", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + } + ] + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + }, + { + "$id": "213", + "Name": "@nextLink", + "SerializedName": "@nextLink", + "Description": "The URI that can be used to request the next set of paged results.", + "Type": { + "$id": "214", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "IsRequired": false, + "IsReadOnly": false, + "Decorators": [] + } + ] + }, + { + "$ref": "210" + } + ], + "Clients": [ + { + "$id": "215", + "Name": "AzureAppConfigurationClient", + "Description": "Azure App Configuration REST API", + "Operations": [ + { + "$id": "216", + "Name": "getKeys", + "ResourceName": "Key", + "Summary": "Gets a list of keys.", + "Description": "Gets a list of keys.", + "Accessibility": "public", + "Parameters": [ + { + "$id": "217", + "Name": "endpoint", + "NameInRequest": "endpoint", + "Type": { + "$id": "218", + "Kind": "url", + "Name": "url", + "CrossLanguageDefinitionId": "TypeSpec.url" + }, + "Location": "Uri", + "IsApiVersion": false, + "IsResourceParameter": false, + "IsContentType": false, + "IsRequired": true, + "IsEndpoint": true, + "SkipUrlEncoding": false, + "Explode": false, + "Kind": "Client" + }, + { + "$id": "219", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "220", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "221", + "Type": { + "$id": "222", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "223", + "Name": "name", + "NameInRequest": "name", + "Description": "A filter for the name of the returned keys.", + "Type": { + "$id": "224", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "225", + "Name": "after", + "NameInRequest": "After", + "Description": "Instructs the server to return elements that appear after the element referred\nto by the specified token.", + "Type": { + "$id": "226", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "227", + "Name": "syncToken", + "NameInRequest": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "228", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "229", + "Name": "acceptDatetime", + "NameInRequest": "Accept-Datetime", + "Description": "Requests the server to respond with the state of the resource at the specified\ntime.", + "Type": { + "$id": "230", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "231", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "232", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "233", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "116" + }, + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "234", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "235", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "236", + "Name": "contentType", + "NameInResponse": "Content-Type", + "Description": "Content-Type header", + "Type": { + "$ref": "2" + } + } + ], + "IsErrorResponse": false, + "ContentTypes": [ + "application/vnd.microsoft.appconfig.keyset+json", + "application/problem+json" + ] + } + ], + "HttpMethod": "GET", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/keys", + "BufferResponse": true, + "Paging": { + "$id": "237", + "ItemName": "items", + "NextLinkName": "@nextLink" + }, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "AzureAppConfiguration.getKeys", + "Decorators": [] + }, + { + "$id": "238", + "Name": "checkKeys", + "ResourceName": "AzureAppConfiguration", + "Summary": "Requests the headers and status of the given resource.", + "Description": "Requests the headers and status of the given resource.", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "217" + }, + { + "$id": "239", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "240", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "241", + "Type": { + "$id": "242", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "243", + "Name": "name", + "NameInRequest": "name", + "Description": "A filter for the name of the returned keys.", + "Type": { + "$id": "244", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "245", + "Name": "syncToken", + "NameInRequest": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "246", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "247", + "Name": "after", + "NameInRequest": "After", + "Description": "Instructs the server to return elements that appear after the element referred\nto by the specified token.", + "Type": { + "$id": "248", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "249", + "Name": "acceptDatetime", + "NameInRequest": "Accept-Datetime", + "Description": "Requests the server to respond with the state of the resource at the specified\ntime.", + "Type": { + "$id": "250", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "251", + "Name": "clientRequestId", + "NameInRequest": "x-ms-client-request-id", + "Description": "An opaque, globally-unique, client-generated string identifier for the request.", + "Type": { + "$id": "252", + "Kind": "string", + "Name": "uuid", + "CrossLanguageDefinitionId": "Azure.Core.uuid", + "BaseType": { + "$id": "253", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "254", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "255", + "Kind": "constant", + "ValueType": { + "$id": "256", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Value": "application/json", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "257", + "StatusCodes": [ + 200 + ], + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "258", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "259", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + } + ], + "IsErrorResponse": false + } + ], + "HttpMethod": "HEAD", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/keys", + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "AzureAppConfiguration.checkKeys", + "Decorators": [] + }, + { + "$id": "260", + "Name": "getKeyValues", + "ResourceName": "KeyValue", + "Summary": "Gets a list of key-values.", + "Description": "Gets a list of key-values.", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "217" + }, + { + "$id": "261", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "262", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "263", + "Type": { + "$id": "264", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "265", + "Name": "key", + "NameInRequest": "key", + "Description": "A filter used to match keys. Syntax reference:\nhttps://aka.ms/azconfig/docs/keyvaluefiltering", + "Type": { + "$id": "266", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "267", + "Name": "label", + "NameInRequest": "label", + "Description": "A filter used to match labels. Syntax reference:\nhttps://aka.ms/azconfig/docs/keyvaluefiltering", + "Type": { + "$id": "268", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "269", + "Name": "syncToken", + "NameInRequest": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "270", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "271", + "Name": "after", + "NameInRequest": "After", + "Description": "Instructs the server to return elements that appear after the element referred\nto by the specified token.", + "Type": { + "$id": "272", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "273", + "Name": "acceptDatetime", + "NameInRequest": "Accept-Datetime", + "Description": "Requests the server to respond with the state of the resource at the specified\ntime.", + "Type": { + "$id": "274", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "275", + "Name": "select", + "NameInRequest": "$Select", + "Description": "Used to select what fields are present in the returned resource(s).", + "Type": { + "$id": "276", + "Kind": "array", + "Name": "ArrayKeyValueFields", + "ValueType": { + "$ref": "6" + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "ArraySerializationDelimiter": ",", + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "277", + "Name": "snapshot", + "NameInRequest": "snapshot", + "Description": "A filter used get key-values for a snapshot. The value should be the name of\nthe snapshot. Not valid when used with 'key' and 'label' filters.", + "Type": { + "$id": "278", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "279", + "Name": "ifMatch", + "NameInRequest": "If-Match", + "Description": "Used to perform an operation only if the targeted resource's etag matches the\nvalue provided.", + "Type": { + "$id": "280", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "281", + "Name": "ifNoneMatch", + "NameInRequest": "If-None-Match", + "Description": "Used to perform an operation only if the targeted resource's etag does not\nmatch the value provided.", + "Type": { + "$id": "282", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "283", + "Name": "tags", + "NameInRequest": "tags", + "Description": "A filter used to query by tags. Syntax reference:\nhttps://aka.ms/azconfig/docs/keyvaluefiltering", + "Type": { + "$id": "284", + "Kind": "array", + "Name": "Array", + "ValueType": { + "$id": "285", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": true, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "286", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "287", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "288", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "135" + }, + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "289", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "290", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "291", + "Name": "etagHeader", + "NameInResponse": "ETag", + "Description": "A value representing the current state of the resource.", + "Type": { + "$id": "292", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "293", + "Name": "contentType", + "NameInResponse": "Content-Type", + "Description": "Content-Type header", + "Type": { + "$ref": "16" + } + } + ], + "IsErrorResponse": false, + "ContentTypes": [ + "application/vnd.microsoft.appconfig.kvset+json", + "application/problem+json" + ] + } + ], + "HttpMethod": "GET", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/kv", + "BufferResponse": true, + "Paging": { + "$id": "294", + "ItemName": "items", + "NextLinkName": "@nextLink" + }, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "AzureAppConfiguration.getKeyValues", + "Decorators": [] + }, + { + "$id": "295", + "Name": "checkKeyValues", + "ResourceName": "AzureAppConfiguration", + "Summary": "Requests the headers and status of the given resource.", + "Description": "Requests the headers and status of the given resource.", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "217" + }, + { + "$id": "296", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "297", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "298", + "Type": { + "$id": "299", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "300", + "Name": "key", + "NameInRequest": "key", + "Description": "A filter used to match keys. Syntax reference:\nhttps://aka.ms/azconfig/docs/keyvaluefiltering", + "Type": { + "$id": "301", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "302", + "Name": "label", + "NameInRequest": "label", + "Description": "A filter used to match labels. Syntax reference:\nhttps://aka.ms/azconfig/docs/keyvaluefiltering", + "Type": { + "$id": "303", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "304", + "Name": "syncToken", + "NameInRequest": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "305", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "306", + "Name": "after", + "NameInRequest": "After", + "Description": "Instructs the server to return elements that appear after the element referred\nto by the specified token.", + "Type": { + "$id": "307", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "308", + "Name": "acceptDatetime", + "NameInRequest": "Accept-Datetime", + "Description": "Requests the server to respond with the state of the resource at the specified\ntime.", + "Type": { + "$id": "309", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "310", + "Name": "select", + "NameInRequest": "$Select", + "Description": "Used to select what fields are present in the returned resource(s).", + "Type": { + "$id": "311", + "Kind": "array", + "Name": "ArrayKeyValueFields", + "ValueType": { + "$ref": "6" + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "ArraySerializationDelimiter": ",", + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "312", + "Name": "snapshot", + "NameInRequest": "snapshot", + "Description": "A filter used get key-values for a snapshot. Not valid when used with 'key' and 'label' filters.", + "Type": { + "$id": "313", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "314", + "Name": "ifMatch", + "NameInRequest": "If-Match", + "Description": "Used to perform an operation only if the targeted resource's etag matches the\nvalue provided.", + "Type": { + "$id": "315", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "316", + "Name": "ifNoneMatch", + "NameInRequest": "If-None-Match", + "Description": "Used to perform an operation only if the targeted resource's etag does not\nmatch the value provided.", + "Type": { + "$id": "317", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "318", + "Name": "tags", + "NameInRequest": "tags", + "Description": "A filter used to query by tags. Syntax reference:\nhttps://aka.ms/azconfig/docs/keyvaluefiltering", + "Type": { + "$id": "319", + "Kind": "array", + "Name": "Array", + "ValueType": { + "$id": "320", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": true, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "321", + "Name": "clientRequestId", + "NameInRequest": "x-ms-client-request-id", + "Description": "An opaque, globally-unique, client-generated string identifier for the request.", + "Type": { + "$id": "322", + "Kind": "string", + "Name": "uuid", + "CrossLanguageDefinitionId": "Azure.Core.uuid", + "BaseType": { + "$id": "323", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "324", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "325", + "Kind": "constant", + "ValueType": { + "$id": "326", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Value": "application/json", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "327", + "StatusCodes": [ + 200 + ], + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "328", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "329", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "330", + "Name": "etagHeader", + "NameInResponse": "ETag", + "Description": "A value representing the current state of the resource.", + "Type": { + "$id": "331", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + } + ], + "IsErrorResponse": false + } + ], + "HttpMethod": "HEAD", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/kv", + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "AzureAppConfiguration.checkKeyValues", + "Decorators": [] + }, + { + "$id": "332", + "Name": "getKeyValue", + "ResourceName": "AzureAppConfiguration", + "Summary": "Gets a single key-value.", + "Description": "Gets a single key-value.", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "217" + }, + { + "$id": "333", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "334", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "335", + "Type": { + "$id": "336", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "337", + "Name": "key", + "NameInRequest": "key", + "Description": "The key of the key-value.", + "Type": { + "$id": "338", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Path", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "339", + "Name": "label", + "NameInRequest": "label", + "Description": "The label of the key-value to retrieve.", + "Type": { + "$id": "340", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "341", + "Name": "select", + "NameInRequest": "$Select", + "Description": "Used to select what fields are present in the returned resource(s).", + "Type": { + "$id": "342", + "Kind": "array", + "Name": "ArrayKeyValueFields", + "ValueType": { + "$ref": "6" + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "ArraySerializationDelimiter": ",", + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "343", + "Name": "syncToken", + "NameInRequest": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "344", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "345", + "Name": "acceptDatetime", + "NameInRequest": "Accept-Datetime", + "Description": "Requests the server to respond with the state of the resource at the specified\ntime.", + "Type": { + "$id": "346", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "347", + "Name": "ifMatch", + "NameInRequest": "If-Match", + "Description": "Used to perform an operation only if the targeted resource's etag matches the\nvalue provided.", + "Type": { + "$id": "348", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "349", + "Name": "ifNoneMatch", + "NameInRequest": "If-None-Match", + "Description": "Used to perform an operation only if the targeted resource's etag does not\nmatch the value provided.", + "Type": { + "$id": "350", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "351", + "Name": "clientRequestId", + "NameInRequest": "x-ms-client-request-id", + "Description": "An opaque, globally-unique, client-generated string identifier for the request.", + "Type": { + "$id": "352", + "Kind": "string", + "Name": "uuid", + "CrossLanguageDefinitionId": "Azure.Core.uuid", + "BaseType": { + "$id": "353", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "354", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "355", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "356", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "138" + }, + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "357", + "Name": "clientRequestId", + "NameInResponse": "x-ms-client-request-id", + "Description": "An opaque, globally-unique, client-generated string identifier for the request.", + "Type": { + "$id": "358", + "Kind": "string", + "Name": "uuid", + "CrossLanguageDefinitionId": "Azure.Core.uuid", + "BaseType": { + "$id": "359", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + } + }, + { + "$id": "360", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "361", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "362", + "Name": "etagHeader", + "NameInResponse": "ETag", + "Description": "A value representing the current state of the resource.", + "Type": { + "$id": "363", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "364", + "Name": "contentType", + "NameInResponse": "Content-Type", + "Description": "Content-Type header", + "Type": { + "$ref": "20" + } + } + ], + "IsErrorResponse": false, + "ContentTypes": [ + "application/vnd.microsoft.appconfig.kv+json", + "application/problem+json" + ] + } + ], + "HttpMethod": "GET", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/kv/{key}", + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "AzureAppConfiguration.getKeyValue", + "Decorators": [] + }, + { + "$id": "365", + "Name": "putKeyValue", + "ResourceName": "AzureAppConfiguration", + "Summary": "Creates a key-value.", + "Description": "Creates a key-value.", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "217" + }, + { + "$id": "366", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "367", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "368", + "Type": { + "$id": "369", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "370", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Content-Type header", + "Type": { + "$ref": "24" + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "371", + "Name": "key", + "NameInRequest": "key", + "Description": "The key of the key-value to create.", + "Type": { + "$id": "372", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Path", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "373", + "Name": "label", + "NameInRequest": "label", + "Description": "The label of the key-value to create.", + "Type": { + "$id": "374", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "375", + "Name": "syncToken", + "NameInRequest": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "376", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "377", + "Name": "ifMatch", + "NameInRequest": "If-Match", + "Description": "Used to perform an operation only if the targeted resource's etag matches the\nvalue provided.", + "Type": { + "$id": "378", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "379", + "Name": "ifNoneMatch", + "NameInRequest": "If-None-Match", + "Description": "Used to perform an operation only if the targeted resource's etag does not\nmatch the value provided.", + "Type": { + "$id": "380", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "381", + "Name": "clientRequestId", + "NameInRequest": "x-ms-client-request-id", + "Description": "An opaque, globally-unique, client-generated string identifier for the request.", + "Type": { + "$id": "382", + "Kind": "string", + "Name": "uuid", + "CrossLanguageDefinitionId": "Azure.Core.uuid", + "BaseType": { + "$id": "383", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "384", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "385", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "386", + "Name": "entity", + "NameInRequest": "entity", + "Description": "The key-value to create.", + "Type": { + "$ref": "138" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "387", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "138" + }, + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "388", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "389", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "390", + "Name": "etagHeader", + "NameInResponse": "ETag", + "Description": "A value representing the current state of the resource.", + "Type": { + "$id": "391", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "392", + "Name": "contentType", + "NameInResponse": "Content-Type", + "Description": "Content-Type header", + "Type": { + "$ref": "32" + } + } + ], + "IsErrorResponse": false, + "ContentTypes": [ + "application/vnd.microsoft.appconfig.kv+json", + "application/problem+json" + ] + } + ], + "HttpMethod": "PUT", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}", + "Path": "/kv/{key}", + "RequestMediaTypes": [ + "application/vnd.microsoft.appconfig.kv+json", + "application/vnd.microsoft.appconfig.kvset+json", + "application/json", + "text/json", + "application/*+json", + "application/json-patch+json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "AzureAppConfiguration.putKeyValue", + "Decorators": [] + }, + { + "$id": "393", + "Name": "deleteKeyValue", + "ResourceName": "AzureAppConfiguration", + "Summary": "Deletes a key-value.", + "Description": "Deletes a key-value.", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "217" + }, + { + "$id": "394", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "395", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "396", + "Type": { + "$id": "397", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "398", + "Name": "key", + "NameInRequest": "key", + "Description": "The key of the key-value to delete.", + "Type": { + "$id": "399", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Path", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "400", + "Name": "label", + "NameInRequest": "label", + "Description": "The label of the key-value to delete.", + "Type": { + "$id": "401", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "402", + "Name": "syncToken", + "NameInRequest": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "403", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "404", + "Name": "ifMatch", + "NameInRequest": "If-Match", + "Description": "Used to perform an operation only if the targeted resource's etag matches the\nvalue provided.", + "Type": { + "$id": "405", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "406", + "Name": "clientRequestId", + "NameInRequest": "x-ms-client-request-id", + "Description": "An opaque, globally-unique, client-generated string identifier for the request.", + "Type": { + "$id": "407", + "Kind": "string", + "Name": "uuid", + "CrossLanguageDefinitionId": "Azure.Core.uuid", + "BaseType": { + "$id": "408", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "409", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "410", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "411", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "138" + }, + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "412", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "413", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "414", + "Name": "etagHeader", + "NameInResponse": "ETag", + "Description": "A value representing the current state of the resource.", + "Type": { + "$id": "415", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "416", + "Name": "contentType", + "NameInResponse": "Content-Type", + "Description": "Content-Type header", + "Type": { + "$ref": "36" + } + } + ], + "IsErrorResponse": false, + "ContentTypes": [ + "application/vnd.microsoft.appconfig.kv+json", + "application/problem+json" + ] + }, + { + "$id": "417", + "StatusCodes": [ + 204 + ], + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "418", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "419", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + } + ], + "IsErrorResponse": false + } + ], + "HttpMethod": "DELETE", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/kv/{key}", + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "AzureAppConfiguration.deleteKeyValue", + "Decorators": [] + }, + { + "$id": "420", + "Name": "checkKeyValue", + "ResourceName": "AzureAppConfiguration", + "Summary": "Requests the headers and status of the given resource.", + "Description": "Requests the headers and status of the given resource.", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "217" + }, + { + "$id": "421", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "422", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "423", + "Type": { + "$id": "424", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "425", + "Name": "key", + "NameInRequest": "key", + "Description": "The key of the key-value to retrieve.", + "Type": { + "$id": "426", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Path", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "427", + "Name": "label", + "NameInRequest": "label", + "Description": "The label of the key-value to retrieve.", + "Type": { + "$id": "428", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "429", + "Name": "syncToken", + "NameInRequest": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "430", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "431", + "Name": "acceptDatetime", + "NameInRequest": "Accept-Datetime", + "Description": "Requests the server to respond with the state of the resource at the specified\ntime.", + "Type": { + "$id": "432", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "433", + "Name": "ifMatch", + "NameInRequest": "If-Match", + "Description": "Used to perform an operation only if the targeted resource's etag matches the\nvalue provided.", + "Type": { + "$id": "434", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "435", + "Name": "ifNoneMatch", + "NameInRequest": "If-None-Match", + "Description": "Used to perform an operation only if the targeted resource's etag does not\nmatch the value provided.", + "Type": { + "$id": "436", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "437", + "Name": "select", + "NameInRequest": "$Select", + "Description": "Used to select what fields are present in the returned resource(s).", + "Type": { + "$id": "438", + "Kind": "array", + "Name": "ArrayKeyValueFields", + "ValueType": { + "$ref": "6" + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "ArraySerializationDelimiter": ",", + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "439", + "Name": "clientRequestId", + "NameInRequest": "x-ms-client-request-id", + "Description": "An opaque, globally-unique, client-generated string identifier for the request.", + "Type": { + "$id": "440", + "Kind": "string", + "Name": "uuid", + "CrossLanguageDefinitionId": "Azure.Core.uuid", + "BaseType": { + "$id": "441", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "442", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "443", + "Kind": "constant", + "ValueType": { + "$id": "444", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Value": "application/json", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "445", + "StatusCodes": [ + 200 + ], + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "446", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "447", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "448", + "Name": "etagHeader", + "NameInResponse": "ETag", + "Description": "A value representing the current state of the resource.", + "Type": { + "$id": "449", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + } + ], + "IsErrorResponse": false + } + ], + "HttpMethod": "HEAD", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/kv/{key}", + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "AzureAppConfiguration.checkKeyValue", + "Decorators": [] + }, + { + "$id": "450", + "Name": "getSnapshots", + "ResourceName": "Snapshot", + "Summary": "Gets a list of key-value snapshots.", + "Description": "Gets a list of key-value snapshots.", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "217" + }, + { + "$id": "451", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "452", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "453", + "Type": { + "$id": "454", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "455", + "Name": "name", + "NameInRequest": "name", + "Description": "A filter for the name of the returned snapshots.", + "Type": { + "$id": "456", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "457", + "Name": "after", + "NameInRequest": "After", + "Description": "Instructs the server to return elements that appear after the element referred\nto by the specified token.", + "Type": { + "$id": "458", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "459", + "Name": "select", + "NameInRequest": "$Select", + "Description": "Used to select what fields are present in the returned resource(s).", + "Type": { + "$id": "460", + "Kind": "array", + "Name": "ArraySnapshotFields", + "ValueType": { + "$ref": "40" + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "ArraySerializationDelimiter": ",", + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "461", + "Name": "status", + "NameInRequest": "status", + "Description": "Used to filter returned snapshots by their status property.", + "Type": { + "$id": "462", + "Kind": "array", + "Name": "ArraySnapshotStatus", + "ValueType": { + "$ref": "53" + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "ArraySerializationDelimiter": ",", + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "463", + "Name": "syncToken", + "NameInRequest": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "464", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "465", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "466", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "467", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "162" + }, + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "468", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "469", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "470", + "Name": "contentType", + "NameInResponse": "Content-Type", + "Description": "Content-Type header", + "Type": { + "$ref": "63" + } + } + ], + "IsErrorResponse": false, + "ContentTypes": [ + "application/vnd.microsoft.appconfig.snapshotset+json", + "application/problem+json" + ] + } + ], + "HttpMethod": "GET", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/snapshots", + "BufferResponse": true, + "Paging": { + "$id": "471", + "ItemName": "items", + "NextLinkName": "@nextLink" + }, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "AzureAppConfiguration.getSnapshots", + "Decorators": [] + }, + { + "$id": "472", + "Name": "checkSnapshots", + "ResourceName": "AzureAppConfiguration", + "Summary": "Requests the headers and status of the given resource.", + "Description": "Requests the headers and status of the given resource.", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "217" + }, + { + "$id": "473", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "474", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "475", + "Type": { + "$id": "476", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "477", + "Name": "syncToken", + "NameInRequest": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "478", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "479", + "Name": "after", + "NameInRequest": "After", + "Description": "Instructs the server to return elements that appear after the element referred\nto by the specified token.", + "Type": { + "$id": "480", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "481", + "Name": "clientRequestId", + "NameInRequest": "x-ms-client-request-id", + "Description": "An opaque, globally-unique, client-generated string identifier for the request.", + "Type": { + "$id": "482", + "Kind": "string", + "Name": "uuid", + "CrossLanguageDefinitionId": "Azure.Core.uuid", + "BaseType": { + "$id": "483", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "484", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "485", + "Kind": "constant", + "ValueType": { + "$id": "486", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Value": "application/json", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "487", + "StatusCodes": [ + 200 + ], + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "488", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "489", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + } + ], + "IsErrorResponse": false + } + ], + "HttpMethod": "HEAD", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/snapshots", + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "AzureAppConfiguration.checkSnapshots", + "Decorators": [] + }, + { + "$id": "490", + "Name": "getSnapshot", + "ResourceName": "Snapshot", + "Summary": "Gets a single key-value snapshot.", + "Description": "Gets a single key-value snapshot.", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "217" + }, + { + "$id": "491", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "492", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "493", + "Type": { + "$id": "494", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "495", + "Name": "name", + "NameInRequest": "name", + "Description": "The name of the snapshot.", + "Type": { + "$id": "496", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Path", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "497", + "Name": "select", + "NameInRequest": "$Select", + "Description": "Used to select what fields are present in the returned resource(s).", + "Type": { + "$id": "498", + "Kind": "array", + "Name": "ArraySnapshotFields", + "ValueType": { + "$ref": "40" + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "ArraySerializationDelimiter": ",", + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "499", + "Name": "syncToken", + "NameInRequest": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "500", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "501", + "Name": "ifMatch", + "NameInRequest": "If-Match", + "Description": "Used to perform an operation only if the targeted resource's etag matches the\nvalue provided.", + "Type": { + "$id": "502", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "503", + "Name": "ifNoneMatch", + "NameInRequest": "If-None-Match", + "Description": "Used to perform an operation only if the targeted resource's etag does not\nmatch the value provided.", + "Type": { + "$id": "504", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "505", + "Name": "clientRequestId", + "NameInRequest": "x-ms-client-request-id", + "Description": "An opaque, globally-unique, client-generated string identifier for the request.", + "Type": { + "$id": "506", + "Kind": "string", + "Name": "uuid", + "CrossLanguageDefinitionId": "Azure.Core.uuid", + "BaseType": { + "$id": "507", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "508", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "509", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "510", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "165" + }, + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "511", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "512", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "513", + "Name": "etagHeader", + "NameInResponse": "ETag", + "Description": "A value representing the current state of the resource.", + "Type": { + "$id": "514", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "515", + "Name": "link", + "NameInResponse": "Link", + "Description": "Includes links to related resources.", + "Type": { + "$id": "516", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "517", + "Name": "clientRequestId", + "NameInResponse": "x-ms-client-request-id", + "Description": "An opaque, globally-unique, client-generated string identifier for the request.", + "Type": { + "$id": "518", + "Kind": "string", + "Name": "uuid", + "CrossLanguageDefinitionId": "Azure.Core.uuid", + "BaseType": { + "$id": "519", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + } + }, + { + "$id": "520", + "Name": "contentType", + "NameInResponse": "Content-Type", + "Description": "Content-Type header", + "Type": { + "$ref": "67" + } + } + ], + "IsErrorResponse": false, + "ContentTypes": [ + "application/vnd.microsoft.appconfig.snapshot+json", + "application/problem+json" + ] + } + ], + "HttpMethod": "GET", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/snapshots/{name}", + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "AzureAppConfiguration.getSnapshot", + "Decorators": [] + }, + { + "$id": "521", + "Name": "getOperationDetails", + "ResourceName": "AzureAppConfiguration", + "Summary": "Gets the state of a long running operation.", + "Description": "Gets the state of a long running operation.", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "217" + }, + { + "$id": "522", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "523", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "524", + "Type": { + "$id": "525", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "526", + "Name": "snapshot", + "NameInRequest": "snapshot", + "Description": "Snapshot identifier for the long running operation.", + "Type": { + "$id": "527", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "528", + "Name": "clientRequestId", + "NameInRequest": "x-ms-client-request-id", + "Description": "An opaque, globally-unique, client-generated string identifier for the request.", + "Type": { + "$id": "529", + "Kind": "string", + "Name": "uuid", + "CrossLanguageDefinitionId": "Azure.Core.uuid", + "BaseType": { + "$id": "530", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "531", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "532", + "Kind": "constant", + "ValueType": { + "$id": "533", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Value": "application/json", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "534", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "200" + }, + "BodyMediaType": "Json", + "Headers": [], + "IsErrorResponse": false, + "ContentTypes": [ + "application/json" + ] + } + ], + "HttpMethod": "GET", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/operations", + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "AzureAppConfiguration.getOperationDetails", + "Decorators": [] + }, + { + "$id": "535", + "Name": "createSnapshot", + "ResourceName": "AzureAppConfiguration", + "Summary": "Creates a key-value snapshot.", + "Description": "Creates a key-value snapshot.", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "217" + }, + { + "$id": "536", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "537", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "538", + "Type": { + "$id": "539", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "540", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Content-Type header", + "Type": { + "$ref": "78" + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "541", + "Name": "name", + "NameInRequest": "name", + "Description": "The name of the key-value snapshot to create.", + "Type": { + "$id": "542", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Path", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "543", + "Name": "syncToken", + "NameInRequest": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "544", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "545", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "546", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "547", + "Name": "entity", + "NameInRequest": "entity", + "Description": "The key-value snapshot to create.", + "Type": { + "$ref": "165" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "548", + "StatusCodes": [ + 201 + ], + "BodyType": { + "$ref": "165" + }, + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "549", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "550", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "551", + "Name": "etagHeader", + "NameInResponse": "ETag", + "Description": "A value representing the current state of the resource.", + "Type": { + "$id": "552", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "553", + "Name": "link", + "NameInResponse": "Link", + "Description": "Includes links to related resources.", + "Type": { + "$id": "554", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "555", + "Name": "operationLocation", + "NameInResponse": "Operation-Location", + "Description": "The location for monitoring the operation state.", + "Type": { + "$id": "556", + "Kind": "url", + "Name": "ResourceLocation", + "CrossLanguageDefinitionId": "TypeSpec.Rest.ResourceLocation", + "BaseType": { + "$id": "557", + "Kind": "url", + "Name": "url", + "CrossLanguageDefinitionId": "TypeSpec.url", + "Decorators": [] + }, + "Decorators": [] + } + }, + { + "$id": "558", + "Name": "contentType", + "NameInResponse": "Content-Type", + "Description": "Content-Type header", + "Type": { + "$ref": "82" + } + } + ], + "IsErrorResponse": false, + "ContentTypes": [ + "application/vnd.microsoft.appconfig.snapshot+json", + "application/problem+json" + ] + } + ], + "HttpMethod": "PUT", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}", + "Path": "/snapshots/{name}", + "RequestMediaTypes": [ + "application/vnd.microsoft.appconfig.snapshot+json", + "application/json" + ], + "BufferResponse": true, + "LongRunning": { + "$id": "559", + "FinalStateVia": 2, + "FinalResponse": { + "$id": "560", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "124" + }, + "BodyMediaType": "Json" + } + }, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "AzureAppConfiguration.createSnapshot", + "Decorators": [] + }, + { + "$id": "561", + "Name": "updateSnapshot", + "ResourceName": "AzureAppConfiguration", + "Summary": "Updates the state of a key-value snapshot.", + "Description": "Updates the state of a key-value snapshot.", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "217" + }, + { + "$id": "562", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "563", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "564", + "Type": { + "$id": "565", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "566", + "Name": "contentType", + "NameInRequest": "Content-Type", + "Description": "Content-Type header", + "Type": { + "$ref": "86" + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": true, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "567", + "Name": "name", + "NameInRequest": "name", + "Description": "The name of the key-value snapshot to update.", + "Type": { + "$id": "568", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Path", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "569", + "Name": "syncToken", + "NameInRequest": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "570", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "571", + "Name": "ifMatch", + "NameInRequest": "If-Match", + "Description": "Used to perform an operation only if the targeted resource's etag matches the\nvalue provided.", + "Type": { + "$id": "572", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "573", + "Name": "ifNoneMatch", + "NameInRequest": "If-None-Match", + "Description": "Used to perform an operation only if the targeted resource's etag does not\nmatch the value provided.", + "Type": { + "$id": "574", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "575", + "Name": "clientRequestId", + "NameInRequest": "x-ms-client-request-id", + "Description": "An opaque, globally-unique, client-generated string identifier for the request.", + "Type": { + "$id": "576", + "Kind": "string", + "Name": "uuid", + "CrossLanguageDefinitionId": "Azure.Core.uuid", + "BaseType": { + "$id": "577", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "578", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "579", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "580", + "Name": "entity", + "NameInRequest": "entity", + "Description": "The parameters used to update the snapshot.", + "Type": { + "$ref": "205" + }, + "Location": "Body", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "581", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "165" + }, + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "582", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "583", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "584", + "Name": "etagHeader", + "NameInResponse": "ETag", + "Description": "A value representing the current state of the resource.", + "Type": { + "$id": "585", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "586", + "Name": "link", + "NameInResponse": "Link", + "Description": "Includes links to related resources.", + "Type": { + "$id": "587", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "588", + "Name": "contentType", + "NameInResponse": "Content-Type", + "Description": "Content-Type header", + "Type": { + "$ref": "90" + } + } + ], + "IsErrorResponse": false, + "ContentTypes": [ + "application/vnd.microsoft.appconfig.snapshot+json", + "application/problem+json" + ] + } + ], + "HttpMethod": "PATCH", + "RequestBodyMediaType": "Json", + "Uri": "{endpoint}", + "Path": "/snapshots/{name}", + "RequestMediaTypes": [ + "application/merge-patch+json", + "application/json" + ], + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": false, + "CrossLanguageDefinitionId": "AzureAppConfiguration.updateSnapshot", + "Decorators": [] + }, + { + "$id": "589", + "Name": "checkSnapshot", + "ResourceName": "AzureAppConfiguration", + "Summary": "Requests the headers and status of the given resource.", + "Description": "Requests the headers and status of the given resource.", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "217" + }, + { + "$id": "590", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "591", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "592", + "Type": { + "$id": "593", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "594", + "Name": "name", + "NameInRequest": "name", + "Description": "The name of the key-value snapshot to check.", + "Type": { + "$id": "595", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Path", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "596", + "Name": "syncToken", + "NameInRequest": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "597", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "598", + "Name": "ifMatch", + "NameInRequest": "If-Match", + "Description": "Used to perform an operation only if the targeted resource's etag matches the\nvalue provided.", + "Type": { + "$id": "599", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "600", + "Name": "ifNoneMatch", + "NameInRequest": "If-None-Match", + "Description": "Used to perform an operation only if the targeted resource's etag does not\nmatch the value provided.", + "Type": { + "$id": "601", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "602", + "Name": "clientRequestId", + "NameInRequest": "x-ms-client-request-id", + "Description": "An opaque, globally-unique, client-generated string identifier for the request.", + "Type": { + "$id": "603", + "Kind": "string", + "Name": "uuid", + "CrossLanguageDefinitionId": "Azure.Core.uuid", + "BaseType": { + "$id": "604", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "605", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "606", + "Kind": "constant", + "ValueType": { + "$id": "607", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Value": "application/json", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "608", + "StatusCodes": [ + 200 + ], + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "609", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "610", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "611", + "Name": "etagHeader", + "NameInResponse": "ETag", + "Description": "A value representing the current state of the resource.", + "Type": { + "$id": "612", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "613", + "Name": "link", + "NameInResponse": "Link", + "Description": "Includes links to related resources.", + "Type": { + "$id": "614", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + } + ], + "IsErrorResponse": false + } + ], + "HttpMethod": "HEAD", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/snapshots/{name}", + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "AzureAppConfiguration.checkSnapshot", + "Decorators": [] + }, + { + "$id": "615", + "Name": "getLabels", + "ResourceName": "AzureAppConfiguration", + "Summary": "Gets a list of labels.", + "Description": "Gets a list of labels.", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "217" + }, + { + "$id": "616", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "617", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "618", + "Type": { + "$id": "619", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "620", + "Name": "name", + "NameInRequest": "name", + "Description": "A filter for the name of the returned labels.", + "Type": { + "$id": "621", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "622", + "Name": "syncToken", + "NameInRequest": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "623", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "624", + "Name": "after", + "NameInRequest": "After", + "Description": "Instructs the server to return elements that appear after the element referred\nto by the specified token.", + "Type": { + "$id": "625", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "626", + "Name": "acceptDatetime", + "NameInRequest": "Accept-Datetime", + "Description": "Requests the server to respond with the state of the resource at the specified\ntime.", + "Type": { + "$id": "627", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "628", + "Name": "select", + "NameInRequest": "$Select", + "Description": "Used to select what fields are present in the returned resource(s).", + "Type": { + "$id": "629", + "Kind": "array", + "Name": "ArrayLabelFields", + "ValueType": { + "$ref": "94" + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "ArraySerializationDelimiter": ",", + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "630", + "Name": "clientRequestId", + "NameInRequest": "x-ms-client-request-id", + "Description": "An opaque, globally-unique, client-generated string identifier for the request.", + "Type": { + "$id": "631", + "Kind": "string", + "Name": "uuid", + "CrossLanguageDefinitionId": "Azure.Core.uuid", + "BaseType": { + "$id": "632", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "633", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "634", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "635", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "207" + }, + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "636", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "637", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "638", + "Name": "contentType", + "NameInResponse": "Content-Type", + "Description": "Content-Type header", + "Type": { + "$ref": "97" + } + } + ], + "IsErrorResponse": false, + "ContentTypes": [ + "application/vnd.microsoft.appconfig.labelset+json", + "application/problem+json" + ] + } + ], + "HttpMethod": "GET", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/labels", + "BufferResponse": true, + "Paging": { + "$id": "639", + "ItemName": "items", + "NextLinkName": "@nextLink" + }, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "AzureAppConfiguration.getLabels", + "Decorators": [] + }, + { + "$id": "640", + "Name": "checkLabels", + "ResourceName": "AzureAppConfiguration", + "Summary": "Requests the headers and status of the given resource.", + "Description": "Requests the headers and status of the given resource.", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "217" + }, + { + "$id": "641", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "642", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "643", + "Type": { + "$id": "644", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "645", + "Name": "name", + "NameInRequest": "name", + "Description": "A filter for the name of the returned labels.", + "Type": { + "$id": "646", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "647", + "Name": "syncToken", + "NameInRequest": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "648", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "649", + "Name": "after", + "NameInRequest": "After", + "Description": "Instructs the server to return elements that appear after the element referred\nto by the specified token.", + "Type": { + "$id": "650", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "651", + "Name": "acceptDatetime", + "NameInRequest": "Accept-Datetime", + "Description": "Requests the server to respond with the state of the resource at the specified\ntime.", + "Type": { + "$id": "652", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "653", + "Name": "select", + "NameInRequest": "$Select", + "Description": "Used to select what fields are present in the returned resource(s).", + "Type": { + "$id": "654", + "Kind": "array", + "Name": "ArrayLabelFields", + "ValueType": { + "$ref": "94" + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "ArraySerializationDelimiter": ",", + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "655", + "Name": "clientRequestId", + "NameInRequest": "x-ms-client-request-id", + "Description": "An opaque, globally-unique, client-generated string identifier for the request.", + "Type": { + "$id": "656", + "Kind": "string", + "Name": "uuid", + "CrossLanguageDefinitionId": "Azure.Core.uuid", + "BaseType": { + "$id": "657", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "658", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "659", + "Kind": "constant", + "ValueType": { + "$id": "660", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Value": "application/json", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "661", + "StatusCodes": [ + 200 + ], + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "662", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "663", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + } + ], + "IsErrorResponse": false + } + ], + "HttpMethod": "HEAD", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/labels", + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "AzureAppConfiguration.checkLabels", + "Decorators": [] + }, + { + "$id": "664", + "Name": "putLock", + "ResourceName": "AzureAppConfiguration", + "Summary": "Locks a key-value.", + "Description": "Locks a key-value.", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "217" + }, + { + "$id": "665", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "666", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "667", + "Type": { + "$id": "668", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "669", + "Name": "key", + "NameInRequest": "key", + "Description": "The key of the key-value to lock.", + "Type": { + "$id": "670", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Path", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "671", + "Name": "label", + "NameInRequest": "label", + "Description": "The label, if any, of the key-value to lock.", + "Type": { + "$id": "672", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "673", + "Name": "syncToken", + "NameInRequest": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "674", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "675", + "Name": "ifMatch", + "NameInRequest": "If-Match", + "Description": "Used to perform an operation only if the targeted resource's etag matches the\nvalue provided.", + "Type": { + "$id": "676", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "677", + "Name": "ifNoneMatch", + "NameInRequest": "If-None-Match", + "Description": "Used to perform an operation only if the targeted resource's etag does not\nmatch the value provided.", + "Type": { + "$id": "678", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "679", + "Name": "clientRequestId", + "NameInRequest": "x-ms-client-request-id", + "Description": "An opaque, globally-unique, client-generated string identifier for the request.", + "Type": { + "$id": "680", + "Kind": "string", + "Name": "uuid", + "CrossLanguageDefinitionId": "Azure.Core.uuid", + "BaseType": { + "$id": "681", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "682", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "683", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "684", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "138" + }, + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "685", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "686", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "687", + "Name": "etagHeader", + "NameInResponse": "ETag", + "Description": "A value representing the current state of the resource.", + "Type": { + "$id": "688", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "689", + "Name": "contentType", + "NameInResponse": "Content-Type", + "Description": "Content-Type header", + "Type": { + "$ref": "101" + } + } + ], + "IsErrorResponse": false, + "ContentTypes": [ + "application/vnd.microsoft.appconfig.kv+json", + "application/problem+json" + ] + } + ], + "HttpMethod": "PUT", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/locks/{key}", + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "AzureAppConfiguration.putLock", + "Decorators": [] + }, + { + "$id": "690", + "Name": "deleteLock", + "ResourceName": "AzureAppConfiguration", + "Summary": "Unlocks a key-value.", + "Description": "Unlocks a key-value.", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "217" + }, + { + "$id": "691", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "692", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "693", + "Type": { + "$id": "694", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "695", + "Name": "key", + "NameInRequest": "key", + "Description": "The key of the key-value to unlock.", + "Type": { + "$id": "696", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Path", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "697", + "Name": "label", + "NameInRequest": "label", + "Description": "The label, if any, of the key-value to unlock.", + "Type": { + "$id": "698", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "699", + "Name": "syncToken", + "NameInRequest": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "700", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "701", + "Name": "ifMatch", + "NameInRequest": "If-Match", + "Description": "Used to perform an operation only if the targeted resource's etag matches the\nvalue provided.", + "Type": { + "$id": "702", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "703", + "Name": "ifNoneMatch", + "NameInRequest": "If-None-Match", + "Description": "Used to perform an operation only if the targeted resource's etag does not\nmatch the value provided.", + "Type": { + "$id": "704", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "705", + "Name": "clientRequestId", + "NameInRequest": "x-ms-client-request-id", + "Description": "An opaque, globally-unique, client-generated string identifier for the request.", + "Type": { + "$id": "706", + "Kind": "string", + "Name": "uuid", + "CrossLanguageDefinitionId": "Azure.Core.uuid", + "BaseType": { + "$id": "707", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "708", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "709", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "710", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "138" + }, + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "711", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "712", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "713", + "Name": "etagHeader", + "NameInResponse": "ETag", + "Description": "A value representing the current state of the resource.", + "Type": { + "$id": "714", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "715", + "Name": "contentType", + "NameInResponse": "Content-Type", + "Description": "Content-Type header", + "Type": { + "$ref": "105" + } + } + ], + "IsErrorResponse": false, + "ContentTypes": [ + "application/vnd.microsoft.appconfig.kv+json", + "application/problem+json" + ] + } + ], + "HttpMethod": "DELETE", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/locks/{key}", + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "AzureAppConfiguration.deleteLock", + "Decorators": [] + }, + { + "$id": "716", + "Name": "getRevisions", + "ResourceName": "AzureAppConfiguration", + "Summary": "Gets a list of key-value revisions.", + "Description": "Gets a list of key-value revisions.", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "217" + }, + { + "$id": "717", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "718", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "719", + "Type": { + "$id": "720", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "721", + "Name": "key", + "NameInRequest": "key", + "Description": "A filter used to match keys. Syntax reference:\nhttps://aka.ms/azconfig/docs/restapirevisions", + "Type": { + "$id": "722", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "723", + "Name": "label", + "NameInRequest": "label", + "Description": "A filter used to match labels. Syntax reference:\nhttps://aka.ms/azconfig/docs/restapirevisions", + "Type": { + "$id": "724", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "725", + "Name": "syncToken", + "NameInRequest": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "726", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "727", + "Name": "after", + "NameInRequest": "After", + "Description": "Instructs the server to return elements that appear after the element referred\nto by the specified token.", + "Type": { + "$id": "728", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "729", + "Name": "acceptDatetime", + "NameInRequest": "Accept-Datetime", + "Description": "Requests the server to respond with the state of the resource at the specified\ntime.", + "Type": { + "$id": "730", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "731", + "Name": "select", + "NameInRequest": "$Select", + "Description": "Used to select what fields are present in the returned resource(s).", + "Type": { + "$id": "732", + "Kind": "array", + "Name": "ArrayKeyValueFields", + "ValueType": { + "$ref": "6" + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "ArraySerializationDelimiter": ",", + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "733", + "Name": "tags", + "NameInRequest": "tags", + "Description": "A filter used to query by tags. Syntax reference:\nhttps://aka.ms/azconfig/docs/restapirevisions", + "Type": { + "$id": "734", + "Kind": "array", + "Name": "Array", + "ValueType": { + "$id": "735", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": true, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "736", + "Name": "clientRequestId", + "NameInRequest": "x-ms-client-request-id", + "Description": "An opaque, globally-unique, client-generated string identifier for the request.", + "Type": { + "$id": "737", + "Kind": "string", + "Name": "uuid", + "CrossLanguageDefinitionId": "Azure.Core.uuid", + "BaseType": { + "$id": "738", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "739", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "740", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "741", + "StatusCodes": [ + 200 + ], + "BodyType": { + "$ref": "135" + }, + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "742", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "743", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "744", + "Name": "etagHeader", + "NameInResponse": "ETag", + "Description": "A value representing the current state of the resource.", + "Type": { + "$id": "745", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "746", + "Name": "contentType", + "NameInResponse": "Content-Type", + "Description": "Content-Type header", + "Type": { + "$ref": "109" + } + } + ], + "IsErrorResponse": false, + "ContentTypes": [ + "application/vnd.microsoft.appconfig.kvset+json", + "application/problem+json" + ] + } + ], + "HttpMethod": "GET", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/revisions", + "BufferResponse": true, + "Paging": { + "$id": "747", + "ItemName": "items", + "NextLinkName": "@nextLink" + }, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "AzureAppConfiguration.getRevisions", + "Decorators": [] + }, + { + "$id": "748", + "Name": "checkRevisions", + "ResourceName": "AzureAppConfiguration", + "Summary": "Requests the headers and status of the given resource.", + "Description": "Requests the headers and status of the given resource.", + "Accessibility": "public", + "Parameters": [ + { + "$ref": "217" + }, + { + "$id": "749", + "Name": "apiVersion", + "NameInRequest": "api-version", + "Description": "The API version to use for this operation.", + "Type": { + "$id": "750", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": true, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Client", + "DefaultValue": { + "$id": "751", + "Type": { + "$id": "752", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string" + }, + "Value": "2023-11-01" + }, + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "753", + "Name": "key", + "NameInRequest": "key", + "Description": "A filter used to match keys. Syntax reference:\nhttps://aka.ms/azconfig/docs/restapirevisions", + "Type": { + "$id": "754", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "755", + "Name": "label", + "NameInRequest": "label", + "Description": "A filter used to match labels. Syntax reference:\nhttps://aka.ms/azconfig/docs/restapirevisions", + "Type": { + "$id": "756", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "757", + "Name": "syncToken", + "NameInRequest": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "758", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "759", + "Name": "after", + "NameInRequest": "After", + "Description": "Instructs the server to return elements that appear after the element referred\nto by the specified token.", + "Type": { + "$id": "760", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "761", + "Name": "acceptDatetime", + "NameInRequest": "Accept-Datetime", + "Description": "Requests the server to respond with the state of the resource at the specified\ntime.", + "Type": { + "$id": "762", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "763", + "Name": "select", + "NameInRequest": "$Select", + "Description": "Used to select what fields are present in the returned resource(s).", + "Type": { + "$id": "764", + "Kind": "array", + "Name": "ArrayKeyValueFields", + "ValueType": { + "$ref": "6" + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "ArraySerializationDelimiter": ",", + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "765", + "Name": "tags", + "NameInRequest": "tags", + "Description": "A filter used to query by tags. Syntax reference:\nhttps://aka.ms/azconfig/docs/restapirevisions", + "Type": { + "$id": "766", + "Kind": "array", + "Name": "Array", + "ValueType": { + "$id": "767", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "CrossLanguageDefinitionId": "TypeSpec.Array", + "Decorators": [] + }, + "Location": "Query", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": true, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "768", + "Name": "clientRequestId", + "NameInRequest": "x-ms-client-request-id", + "Description": "An opaque, globally-unique, client-generated string identifier for the request.", + "Type": { + "$id": "769", + "Kind": "string", + "Name": "uuid", + "CrossLanguageDefinitionId": "Azure.Core.uuid", + "BaseType": { + "$id": "770", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": false, + "Kind": "Method", + "Decorators": [], + "SkipUrlEncoding": false + }, + { + "$id": "771", + "Name": "accept", + "NameInRequest": "Accept", + "Type": { + "$id": "772", + "Kind": "constant", + "ValueType": { + "$id": "773", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + }, + "Value": "application/json", + "Decorators": [] + }, + "Location": "Header", + "IsApiVersion": false, + "IsContentType": false, + "IsEndpoint": false, + "Explode": false, + "IsRequired": true, + "Kind": "Constant", + "Decorators": [], + "SkipUrlEncoding": false + } + ], + "Responses": [ + { + "$id": "774", + "StatusCodes": [ + 200 + ], + "BodyMediaType": "Json", + "Headers": [ + { + "$id": "775", + "Name": "syncToken", + "NameInResponse": "Sync-Token", + "Description": "Used to guarantee real-time consistency between requests.", + "Type": { + "$id": "776", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + }, + { + "$id": "777", + "Name": "etagHeader", + "NameInResponse": "ETag", + "Description": "A value representing the current state of the resource.", + "Type": { + "$id": "778", + "Kind": "string", + "Name": "string", + "CrossLanguageDefinitionId": "TypeSpec.string", + "Decorators": [] + } + } + ], + "IsErrorResponse": false + } + ], + "HttpMethod": "HEAD", + "RequestBodyMediaType": "None", + "Uri": "{endpoint}", + "Path": "/revisions", + "BufferResponse": true, + "GenerateProtocolMethod": true, + "GenerateConvenienceMethod": true, + "CrossLanguageDefinitionId": "AzureAppConfiguration.checkRevisions", + "Decorators": [] + } + ], + "Protocol": { + "$id": "779" + }, + "Parameters": [ + { + "$ref": "217" + } + ], + "Decorators": [] + } + ], + "Auth": { + "$id": "780", + "ApiKey": { + "$id": "781", + "Name": "Connection String" + }, + "OAuth2": { + "$id": "782", + "Scopes": [ + "https://azconfig.io/.default" + ] + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/LiveMetrics.sln b/sdk/applicationinsights.livemetrics/LiveMetrics/LiveMetrics.sln new file mode 100644 index 000000000000..202d00182aa1 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/LiveMetrics.sln @@ -0,0 +1,50 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveMetrics", "src\LiveMetrics.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiveMetrics.Tests", "tests\LiveMetrics.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/AggregationType.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/AggregationType.cs new file mode 100644 index 000000000000..0e23be972e91 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/AggregationType.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace LiveMetrics +{ + /// Aggregation type. + public readonly partial struct AggregationType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AggregationType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AvgValue = "Avg"; + private const string SumValue = "Sum"; + private const string MinValue = "Min"; + private const string MaxValue = "Max"; + + /// Average. + public static AggregationType Avg { get; } = new AggregationType(AvgValue); + /// Sum. + public static AggregationType Sum { get; } = new AggregationType(SumValue); + /// Minimum. + public static AggregationType Min { get; } = new AggregationType(MinValue); + /// Maximum. + public static AggregationType Max { get; } = new AggregationType(MaxValue); + /// Determines if two values are the same. + public static bool operator ==(AggregationType left, AggregationType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AggregationType left, AggregationType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator AggregationType(string value) => new AggregationType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AggregationType other && Equals(other); + /// + public bool Equals(AggregationType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/CollectionConfigurationError.Serialization.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/CollectionConfigurationError.Serialization.cs new file mode 100644 index 000000000000..a359ba3fd714 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/CollectionConfigurationError.Serialization.cs @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace LiveMetrics +{ + public partial class CollectionConfigurationError : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CollectionConfigurationError)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("CollectionConfigurationErrorType"u8); + writer.WriteStringValue(CollectionConfigurationErrorType.ToString()); + writer.WritePropertyName("Message"u8); + writer.WriteStringValue(Message); + writer.WritePropertyName("FullException"u8); + writer.WriteStringValue(FullException); + writer.WritePropertyName("Data"u8); + writer.WriteStartArray(); + foreach (var item in Data) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CollectionConfigurationError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CollectionConfigurationError)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCollectionConfigurationError(document.RootElement, options); + } + + internal static CollectionConfigurationError DeserializeCollectionConfigurationError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CollectionConfigurationErrorType collectionConfigurationErrorType = default; + string message = default; + string fullException = default; + IList data = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("CollectionConfigurationErrorType"u8)) + { + collectionConfigurationErrorType = new CollectionConfigurationErrorType(property.Value.GetString()); + continue; + } + if (property.NameEquals("Message"u8)) + { + message = property.Value.GetString(); + continue; + } + if (property.NameEquals("FullException"u8)) + { + fullException = property.Value.GetString(); + continue; + } + if (property.NameEquals("Data"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(KeyValuePairStringString.DeserializeKeyValuePairStringString(item, options)); + } + data = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CollectionConfigurationError(collectionConfigurationErrorType, message, fullException, data, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CollectionConfigurationError)} does not support writing '{options.Format}' format."); + } + } + + CollectionConfigurationError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCollectionConfigurationError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CollectionConfigurationError)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CollectionConfigurationError FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeCollectionConfigurationError(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/CollectionConfigurationError.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/CollectionConfigurationError.cs new file mode 100644 index 000000000000..2c827786fc4b --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/CollectionConfigurationError.cs @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace LiveMetrics +{ + /// Represents an error while SDK parses and applies an instance of CollectionConfigurationInfo. + public partial class CollectionConfigurationError + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Error type. + /// Error message. + /// Exception that led to the creation of the configuration error. + /// Custom properties to add more information to the error. + /// , or is null. + public CollectionConfigurationError(CollectionConfigurationErrorType collectionConfigurationErrorType, string message, string fullException, IEnumerable data) + { + Argument.AssertNotNull(message, nameof(message)); + Argument.AssertNotNull(fullException, nameof(fullException)); + Argument.AssertNotNull(data, nameof(data)); + + CollectionConfigurationErrorType = collectionConfigurationErrorType; + Message = message; + FullException = fullException; + Data = data.ToList(); + } + + /// Initializes a new instance of . + /// Error type. + /// Error message. + /// Exception that led to the creation of the configuration error. + /// Custom properties to add more information to the error. + /// Keeps track of any properties unknown to the library. + internal CollectionConfigurationError(CollectionConfigurationErrorType collectionConfigurationErrorType, string message, string fullException, IList data, IDictionary serializedAdditionalRawData) + { + CollectionConfigurationErrorType = collectionConfigurationErrorType; + Message = message; + FullException = fullException; + Data = data; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CollectionConfigurationError() + { + } + + /// Error type. + public CollectionConfigurationErrorType CollectionConfigurationErrorType { get; } + /// Error message. + public string Message { get; } + /// Exception that led to the creation of the configuration error. + public string FullException { get; } + /// Custom properties to add more information to the error. + public IList Data { get; } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/CollectionConfigurationErrorType.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/CollectionConfigurationErrorType.cs new file mode 100644 index 000000000000..fcbc32b254f5 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/CollectionConfigurationErrorType.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace LiveMetrics +{ + /// Collection configuration error type reported by the client SDK. + public readonly partial struct CollectionConfigurationErrorType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public CollectionConfigurationErrorType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UnknownValue = "Unknown"; + private const string PerformanceCounterParsingValue = "PerformanceCounterParsing"; + private const string PerformanceCounterUnexpectedValue = "PerformanceCounterUnexpected"; + private const string PerformanceCounterDuplicateIdsValue = "PerformanceCounterDuplicateIds"; + private const string DocumentStreamDuplicateIdsValue = "DocumentStreamDuplicateIds"; + private const string DocumentStreamFailureToCreateValue = "DocumentStreamFailureToCreate"; + private const string DocumentStreamFailureToCreateFilterUnexpectedValue = "DocumentStreamFailureToCreateFilterUnexpected"; + private const string MetricDuplicateIdsValue = "MetricDuplicateIds"; + private const string MetricTelemetryTypeUnsupportedValue = "MetricTelemetryTypeUnsupported"; + private const string MetricFailureToCreateValue = "MetricFailureToCreate"; + private const string MetricFailureToCreateFilterUnexpectedValue = "MetricFailureToCreateFilterUnexpected"; + private const string FilterFailureToCreateUnexpectedValue = "FilterFailureToCreateUnexpected"; + private const string CollectionConfigurationFailureToCreateUnexpectedValue = "CollectionConfigurationFailureToCreateUnexpected"; + + /// Unknown error type. + public static CollectionConfigurationErrorType Unknown { get; } = new CollectionConfigurationErrorType(UnknownValue); + /// Performance counter parsing error. + public static CollectionConfigurationErrorType PerformanceCounterParsing { get; } = new CollectionConfigurationErrorType(PerformanceCounterParsingValue); + /// Performance counter unexpected error. + public static CollectionConfigurationErrorType PerformanceCounterUnexpected { get; } = new CollectionConfigurationErrorType(PerformanceCounterUnexpectedValue); + /// Performance counter duplicate ids. + public static CollectionConfigurationErrorType PerformanceCounterDuplicateIds { get; } = new CollectionConfigurationErrorType(PerformanceCounterDuplicateIdsValue); + /// Document stream duplication ids. + public static CollectionConfigurationErrorType DocumentStreamDuplicateIds { get; } = new CollectionConfigurationErrorType(DocumentStreamDuplicateIdsValue); + /// Document stream failed to create. + public static CollectionConfigurationErrorType DocumentStreamFailureToCreate { get; } = new CollectionConfigurationErrorType(DocumentStreamFailureToCreateValue); + /// Document stream failed to create filter unexpectedly. + public static CollectionConfigurationErrorType DocumentStreamFailureToCreateFilterUnexpected { get; } = new CollectionConfigurationErrorType(DocumentStreamFailureToCreateFilterUnexpectedValue); + /// Metric duplicate ids. + public static CollectionConfigurationErrorType MetricDuplicateIds { get; } = new CollectionConfigurationErrorType(MetricDuplicateIdsValue); + /// Metric telemetry type unsupported. + public static CollectionConfigurationErrorType MetricTelemetryTypeUnsupported { get; } = new CollectionConfigurationErrorType(MetricTelemetryTypeUnsupportedValue); + /// Metric failed to create. + public static CollectionConfigurationErrorType MetricFailureToCreate { get; } = new CollectionConfigurationErrorType(MetricFailureToCreateValue); + /// Metric failed to create filter unexpectedly. + public static CollectionConfigurationErrorType MetricFailureToCreateFilterUnexpected { get; } = new CollectionConfigurationErrorType(MetricFailureToCreateFilterUnexpectedValue); + /// Filter failed to create unexpectedly. + public static CollectionConfigurationErrorType FilterFailureToCreateUnexpected { get; } = new CollectionConfigurationErrorType(FilterFailureToCreateUnexpectedValue); + /// Collection configuration failed to create unexpectedly. + public static CollectionConfigurationErrorType CollectionConfigurationFailureToCreateUnexpected { get; } = new CollectionConfigurationErrorType(CollectionConfigurationFailureToCreateUnexpectedValue); + /// Determines if two values are the same. + public static bool operator ==(CollectionConfigurationErrorType left, CollectionConfigurationErrorType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(CollectionConfigurationErrorType left, CollectionConfigurationErrorType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator CollectionConfigurationErrorType(string value) => new CollectionConfigurationErrorType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is CollectionConfigurationErrorType other && Equals(other); + /// + public bool Equals(CollectionConfigurationErrorType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/CollectionConfigurationInfo.Serialization.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/CollectionConfigurationInfo.Serialization.cs new file mode 100644 index 000000000000..48593c5c360f --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/CollectionConfigurationInfo.Serialization.cs @@ -0,0 +1,187 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace LiveMetrics +{ + public partial class CollectionConfigurationInfo : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CollectionConfigurationInfo)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("ETag"u8); + writer.WriteStringValue(ETag); + writer.WritePropertyName("Metrics"u8); + writer.WriteStartArray(); + foreach (var item in Metrics) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("DocumentStreams"u8); + writer.WriteStartArray(); + foreach (var item in DocumentStreams) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(QuotaInfo)) + { + writer.WritePropertyName("QuotaInfo"u8); + writer.WriteObjectValue(QuotaInfo, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CollectionConfigurationInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CollectionConfigurationInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCollectionConfigurationInfo(document.RootElement, options); + } + + internal static CollectionConfigurationInfo DeserializeCollectionConfigurationInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string eTag = default; + IReadOnlyList metrics = default; + IReadOnlyList documentStreams = default; + QuotaConfigurationInfo quotaInfo = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ETag"u8)) + { + eTag = property.Value.GetString(); + continue; + } + if (property.NameEquals("Metrics"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DerivedMetricInfo.DeserializeDerivedMetricInfo(item, options)); + } + metrics = array; + continue; + } + if (property.NameEquals("DocumentStreams"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DocumentStreamInfo.DeserializeDocumentStreamInfo(item, options)); + } + documentStreams = array; + continue; + } + if (property.NameEquals("QuotaInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + quotaInfo = QuotaConfigurationInfo.DeserializeQuotaConfigurationInfo(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CollectionConfigurationInfo(eTag, metrics, documentStreams, quotaInfo, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CollectionConfigurationInfo)} does not support writing '{options.Format}' format."); + } + } + + CollectionConfigurationInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCollectionConfigurationInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CollectionConfigurationInfo)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CollectionConfigurationInfo FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeCollectionConfigurationInfo(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/CollectionConfigurationInfo.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/CollectionConfigurationInfo.cs new file mode 100644 index 000000000000..2202b8fcc18b --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/CollectionConfigurationInfo.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace LiveMetrics +{ + /// Represents the collection configuration - a customizable description of performance counters, metrics, and full telemetry documents to be collected by the client SDK. + public partial class CollectionConfigurationInfo + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// An encoded string that indicates whether the collection configuration is changed. + /// An array of metric configuration info. + /// An array of document stream configuration info. + /// , or is null. + internal CollectionConfigurationInfo(string eTag, IEnumerable metrics, IEnumerable documentStreams) + { + Argument.AssertNotNull(eTag, nameof(eTag)); + Argument.AssertNotNull(metrics, nameof(metrics)); + Argument.AssertNotNull(documentStreams, nameof(documentStreams)); + + ETag = eTag; + Metrics = metrics.ToList(); + DocumentStreams = documentStreams.ToList(); + } + + /// Initializes a new instance of . + /// An encoded string that indicates whether the collection configuration is changed. + /// An array of metric configuration info. + /// An array of document stream configuration info. + /// Controls document quotas to be sent to Live Metrics. + /// Keeps track of any properties unknown to the library. + internal CollectionConfigurationInfo(string eTag, IReadOnlyList metrics, IReadOnlyList documentStreams, QuotaConfigurationInfo quotaInfo, IDictionary serializedAdditionalRawData) + { + ETag = eTag; + Metrics = metrics; + DocumentStreams = documentStreams; + QuotaInfo = quotaInfo; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CollectionConfigurationInfo() + { + } + + /// An encoded string that indicates whether the collection configuration is changed. + public string ETag { get; } + /// An array of metric configuration info. + public IReadOnlyList Metrics { get; } + /// An array of document stream configuration info. + public IReadOnlyList DocumentStreams { get; } + /// Controls document quotas to be sent to Live Metrics. + public QuotaConfigurationInfo QuotaInfo { get; } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DerivedMetricInfo.Serialization.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DerivedMetricInfo.Serialization.cs new file mode 100644 index 000000000000..17baa33a86a4 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DerivedMetricInfo.Serialization.cs @@ -0,0 +1,193 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace LiveMetrics +{ + public partial class DerivedMetricInfo : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DerivedMetricInfo)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("Id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("TelemetryType"u8); + writer.WriteStringValue(TelemetryType); + writer.WritePropertyName("FilterGroups"u8); + writer.WriteStartArray(); + foreach (var item in FilterGroups) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("Projection"u8); + writer.WriteStringValue(Projection); + writer.WritePropertyName("Aggregation"u8); + writer.WriteStringValue(Aggregation.ToString()); + writer.WritePropertyName("BackEndAggregation"u8); + writer.WriteStringValue(BackEndAggregation.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DerivedMetricInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DerivedMetricInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDerivedMetricInfo(document.RootElement, options); + } + + internal static DerivedMetricInfo DeserializeDerivedMetricInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string telemetryType = default; + IReadOnlyList filterGroups = default; + string projection = default; + AggregationType aggregation = default; + AggregationType backEndAggregation = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("Id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("TelemetryType"u8)) + { + telemetryType = property.Value.GetString(); + continue; + } + if (property.NameEquals("FilterGroups"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(FilterConjunctionGroupInfo.DeserializeFilterConjunctionGroupInfo(item, options)); + } + filterGroups = array; + continue; + } + if (property.NameEquals("Projection"u8)) + { + projection = property.Value.GetString(); + continue; + } + if (property.NameEquals("Aggregation"u8)) + { + aggregation = new AggregationType(property.Value.GetString()); + continue; + } + if (property.NameEquals("BackEndAggregation"u8)) + { + backEndAggregation = new AggregationType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DerivedMetricInfo( + id, + telemetryType, + filterGroups, + projection, + aggregation, + backEndAggregation, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(DerivedMetricInfo)} does not support writing '{options.Format}' format."); + } + } + + DerivedMetricInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeDerivedMetricInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DerivedMetricInfo)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static DerivedMetricInfo FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeDerivedMetricInfo(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DerivedMetricInfo.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DerivedMetricInfo.cs new file mode 100644 index 000000000000..bf65e8969c59 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DerivedMetricInfo.cs @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace LiveMetrics +{ + /// A metric configuration set by UX to scope the metrics it's interested in. + public partial class DerivedMetricInfo + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// metric configuration identifier. + /// Telemetry type. + /// A collection of filters to scope metrics that UX needs. + /// Telemetry's metric dimension whose value is to be aggregated. Example values: Duration, Count(),... + /// Aggregation type. This is the aggregation done from everything within a single server. + /// Aggregation type. This Aggregation is done across the values for all the servers taken together. + /// , , or is null. + internal DerivedMetricInfo(string id, string telemetryType, IEnumerable filterGroups, string projection, AggregationType aggregation, AggregationType backEndAggregation) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(telemetryType, nameof(telemetryType)); + Argument.AssertNotNull(filterGroups, nameof(filterGroups)); + Argument.AssertNotNull(projection, nameof(projection)); + + Id = id; + TelemetryType = telemetryType; + FilterGroups = filterGroups.ToList(); + Projection = projection; + Aggregation = aggregation; + BackEndAggregation = backEndAggregation; + } + + /// Initializes a new instance of . + /// metric configuration identifier. + /// Telemetry type. + /// A collection of filters to scope metrics that UX needs. + /// Telemetry's metric dimension whose value is to be aggregated. Example values: Duration, Count(),... + /// Aggregation type. This is the aggregation done from everything within a single server. + /// Aggregation type. This Aggregation is done across the values for all the servers taken together. + /// Keeps track of any properties unknown to the library. + internal DerivedMetricInfo(string id, string telemetryType, IReadOnlyList filterGroups, string projection, AggregationType aggregation, AggregationType backEndAggregation, IDictionary serializedAdditionalRawData) + { + Id = id; + TelemetryType = telemetryType; + FilterGroups = filterGroups; + Projection = projection; + Aggregation = aggregation; + BackEndAggregation = backEndAggregation; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DerivedMetricInfo() + { + } + + /// metric configuration identifier. + public string Id { get; } + /// Telemetry type. + public string TelemetryType { get; } + /// A collection of filters to scope metrics that UX needs. + public IReadOnlyList FilterGroups { get; } + /// Telemetry's metric dimension whose value is to be aggregated. Example values: Duration, Count(),... + public string Projection { get; } + /// Aggregation type. This is the aggregation done from everything within a single server. + public AggregationType Aggregation { get; } + /// Aggregation type. This Aggregation is done across the values for all the servers taken together. + public AggregationType BackEndAggregation { get; } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Docs/LiveMetricsClient.xml b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Docs/LiveMetricsClient.xml new file mode 100644 index 000000000000..43feea8747a6 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Docs/LiveMetricsClient.xml @@ -0,0 +1,671 @@ + + + + + +This sample shows how to call IsSubscribedAsync. + response = await client.IsSubscribedAsync(""); +]]> +This sample shows how to call IsSubscribedAsync with all parameters. +", +1234, +"", +"", +"", +"", +true, +true) +{ + Timestamp = DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"), + TransmissionTime = DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"), + Metrics = { new MetricPoint("", 123.45, 1234) }, + Documents = {new Request + { + Name = "", + Url = new Uri("http://localhost:3000"), + ResponseCode = "", + Duration = "", + DocumentStreamIds = {""}, + Properties = {new KeyValuePairStringString("", "")}, + }}, + TopCpuProcesses = { new ProcessCpuData("", 1234) }, + CollectionConfigurationErrors = {new CollectionConfigurationError(CollectionConfigurationErrorType.Unknown, "", "", new KeyValuePairStringString[] + { + default + })}, +}; +Response response = await client.IsSubscribedAsync("", monitoringDataPoint: monitoringDataPoint, transmissionTime: 1234L, machineName: "", instanceName: "", streamId: "", roleName: "", invariantVersion: "", configurationEtag: new ETag("")); +]]> + + + +This sample shows how to call IsSubscribed. + response = client.IsSubscribed(""); +]]> +This sample shows how to call IsSubscribed with all parameters. +", +1234, +"", +"", +"", +"", +true, +true) +{ + Timestamp = DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"), + TransmissionTime = DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"), + Metrics = { new MetricPoint("", 123.45, 1234) }, + Documents = {new Request + { + Name = "", + Url = new Uri("http://localhost:3000"), + ResponseCode = "", + Duration = "", + DocumentStreamIds = {""}, + Properties = {new KeyValuePairStringString("", "")}, + }}, + TopCpuProcesses = { new ProcessCpuData("", 1234) }, + CollectionConfigurationErrors = {new CollectionConfigurationError(CollectionConfigurationErrorType.Unknown, "", "", new KeyValuePairStringString[] + { + default + })}, +}; +Response response = client.IsSubscribed("", monitoringDataPoint: monitoringDataPoint, transmissionTime: 1234L, machineName: "", instanceName: "", streamId: "", roleName: "", invariantVersion: "", configurationEtag: new ETag("")); +]]> + + + +This sample shows how to call IsSubscribedAsync and parse the result. +", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("ETag").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Id").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("TelemetryType").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("FieldName").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Predicate").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Comparand").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Projection").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Aggregation").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("BackEndAggregation").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("Id").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("TelemetryType").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("FieldName").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Predicate").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Comparand").ToString()); +]]> +This sample shows how to call IsSubscribedAsync with all parameters and request content and parse the result. +", + InvariantVersion = 1234, + Instance = "", + RoleName = "", + MachineName = "", + StreamId = "", + Timestamp = "2022-05-10T18:57:31.2311892Z", + TransmissionTime = "2022-05-10T18:57:31.2311892Z", + IsWebApp = true, + PerformanceCollectionSupported = true, + Metrics = new object[] + { + new + { + Name = "", + Value = 123.45, + Weight = 1234, + } + }, + Documents = new object[] + { + new + { + DocumentType = "Request", + Name = "", + Url = "http://localhost:3000", + ResponseCode = "", + Duration = "", + DocumentStreamIds = new object[] + { + "" + }, + Properties = new object[] + { + new + { + key = "", + value = "", + } + }, + } + }, + TopCpuProcesses = new object[] + { + new + { + ProcessName = "", + CpuPercentage = 1234, + } + }, + CollectionConfigurationErrors = new object[] + { + new + { + CollectionConfigurationErrorType = "Unknown", + Message = "", + FullException = "", + Data = new object[] + { + null + }, + } + }, +}); +Response response = await client.IsSubscribedAsync("", content, transmissionTime: 1234L, machineName: "", instanceName: "", streamId: "", roleName: "", invariantVersion: "", configurationEtag: new ETag("")); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("ETag").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Id").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("TelemetryType").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("FieldName").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Predicate").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Comparand").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Projection").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Aggregation").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("BackEndAggregation").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("Id").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("TelemetryType").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("FieldName").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Predicate").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Comparand").ToString()); +Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("InitialQuota").ToString()); +Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("MaxQuota").ToString()); +Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("QuotaAccrualRatePerSec").ToString()); +]]> + + + +This sample shows how to call IsSubscribed and parse the result. +", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("ETag").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Id").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("TelemetryType").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("FieldName").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Predicate").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Comparand").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Projection").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Aggregation").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("BackEndAggregation").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("Id").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("TelemetryType").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("FieldName").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Predicate").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Comparand").ToString()); +]]> +This sample shows how to call IsSubscribed with all parameters and request content and parse the result. +", + InvariantVersion = 1234, + Instance = "", + RoleName = "", + MachineName = "", + StreamId = "", + Timestamp = "2022-05-10T18:57:31.2311892Z", + TransmissionTime = "2022-05-10T18:57:31.2311892Z", + IsWebApp = true, + PerformanceCollectionSupported = true, + Metrics = new object[] + { + new + { + Name = "", + Value = 123.45, + Weight = 1234, + } + }, + Documents = new object[] + { + new + { + DocumentType = "Request", + Name = "", + Url = "http://localhost:3000", + ResponseCode = "", + Duration = "", + DocumentStreamIds = new object[] + { + "" + }, + Properties = new object[] + { + new + { + key = "", + value = "", + } + }, + } + }, + TopCpuProcesses = new object[] + { + new + { + ProcessName = "", + CpuPercentage = 1234, + } + }, + CollectionConfigurationErrors = new object[] + { + new + { + CollectionConfigurationErrorType = "Unknown", + Message = "", + FullException = "", + Data = new object[] + { + null + }, + } + }, +}); +Response response = client.IsSubscribed("", content, transmissionTime: 1234L, machineName: "", instanceName: "", streamId: "", roleName: "", invariantVersion: "", configurationEtag: new ETag("")); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("ETag").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Id").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("TelemetryType").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("FieldName").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Predicate").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Comparand").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Projection").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Aggregation").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("BackEndAggregation").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("Id").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("TelemetryType").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("FieldName").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Predicate").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Comparand").ToString()); +Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("InitialQuota").ToString()); +Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("MaxQuota").ToString()); +Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("QuotaAccrualRatePerSec").ToString()); +]]> + + + +This sample shows how to call PublishAsync. + response = await client.PublishAsync(""); +]]> +This sample shows how to call PublishAsync with all parameters. + response = await client.PublishAsync("", monitoringDataPoints: new MonitoringDataPoint[] +{ + new MonitoringDataPoint( + "", + 1234, + "", + "", + "", + "", + true, + true) + { + Timestamp = DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"), + TransmissionTime = DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"), + Metrics = {new MetricPoint("", 123.45, 1234)}, + Documents = {new Request + { + Name = "", + Url = new Uri("http://localhost:3000"), + ResponseCode = "", + Duration = "", + DocumentStreamIds = {""}, + Properties = {new KeyValuePairStringString("", "")}, + }}, + TopCpuProcesses = {new ProcessCpuData("", 1234)}, + CollectionConfigurationErrors = {new CollectionConfigurationError(CollectionConfigurationErrorType.Unknown, "", "", new KeyValuePairStringString[] + { + default + })}, + } +}, configurationEtag: new ETag(""), transmissionTime: 1234L); +]]> + + + +This sample shows how to call Publish. + response = client.Publish(""); +]]> +This sample shows how to call Publish with all parameters. + response = client.Publish("", monitoringDataPoints: new MonitoringDataPoint[] +{ + new MonitoringDataPoint( + "", + 1234, + "", + "", + "", + "", + true, + true) + { + Timestamp = DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"), + TransmissionTime = DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"), + Metrics = {new MetricPoint("", 123.45, 1234)}, + Documents = {new Request + { + Name = "", + Url = new Uri("http://localhost:3000"), + ResponseCode = "", + Duration = "", + DocumentStreamIds = {""}, + Properties = {new KeyValuePairStringString("", "")}, + }}, + TopCpuProcesses = {new ProcessCpuData("", 1234)}, + CollectionConfigurationErrors = {new CollectionConfigurationError(CollectionConfigurationErrorType.Unknown, "", "", new KeyValuePairStringString[] + { + default + })}, + } +}, configurationEtag: new ETag(""), transmissionTime: 1234L); +]]> + + + +This sample shows how to call PublishAsync and parse the result. +", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("ETag").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Id").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("TelemetryType").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("FieldName").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Predicate").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Comparand").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Projection").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Aggregation").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("BackEndAggregation").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("Id").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("TelemetryType").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("FieldName").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Predicate").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Comparand").ToString()); +]]> +This sample shows how to call PublishAsync with all parameters and request content and parse the result. +", + InvariantVersion = 1234, + Instance = "", + RoleName = "", + MachineName = "", + StreamId = "", + Timestamp = "2022-05-10T18:57:31.2311892Z", + TransmissionTime = "2022-05-10T18:57:31.2311892Z", + IsWebApp = true, + PerformanceCollectionSupported = true, + Metrics = new object[] + { + new + { + Name = "", + Value = 123.45, + Weight = 1234, + } + }, + Documents = new object[] + { + new + { + DocumentType = "Request", + Name = "", + Url = "http://localhost:3000", + ResponseCode = "", + Duration = "", + DocumentStreamIds = new object[] + { + "" + }, + Properties = new object[] + { + new + { + key = "", + value = "", + } + }, + } + }, + TopCpuProcesses = new object[] + { + new + { + ProcessName = "", + CpuPercentage = 1234, + } + }, + CollectionConfigurationErrors = new object[] + { + new + { + CollectionConfigurationErrorType = "Unknown", + Message = "", + FullException = "", + Data = new object[] + { + null + }, + } + }, + } +}); +Response response = await client.PublishAsync("", content, configurationEtag: new ETag(""), transmissionTime: 1234L); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("ETag").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Id").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("TelemetryType").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("FieldName").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Predicate").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Comparand").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Projection").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Aggregation").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("BackEndAggregation").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("Id").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("TelemetryType").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("FieldName").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Predicate").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Comparand").ToString()); +Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("InitialQuota").ToString()); +Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("MaxQuota").ToString()); +Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("QuotaAccrualRatePerSec").ToString()); +]]> + + + +This sample shows how to call Publish and parse the result. +", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("ETag").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Id").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("TelemetryType").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("FieldName").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Predicate").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Comparand").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Projection").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Aggregation").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("BackEndAggregation").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("Id").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("TelemetryType").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("FieldName").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Predicate").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Comparand").ToString()); +]]> +This sample shows how to call Publish with all parameters and request content and parse the result. +", + InvariantVersion = 1234, + Instance = "", + RoleName = "", + MachineName = "", + StreamId = "", + Timestamp = "2022-05-10T18:57:31.2311892Z", + TransmissionTime = "2022-05-10T18:57:31.2311892Z", + IsWebApp = true, + PerformanceCollectionSupported = true, + Metrics = new object[] + { + new + { + Name = "", + Value = 123.45, + Weight = 1234, + } + }, + Documents = new object[] + { + new + { + DocumentType = "Request", + Name = "", + Url = "http://localhost:3000", + ResponseCode = "", + Duration = "", + DocumentStreamIds = new object[] + { + "" + }, + Properties = new object[] + { + new + { + key = "", + value = "", + } + }, + } + }, + TopCpuProcesses = new object[] + { + new + { + ProcessName = "", + CpuPercentage = 1234, + } + }, + CollectionConfigurationErrors = new object[] + { + new + { + CollectionConfigurationErrorType = "Unknown", + Message = "", + FullException = "", + Data = new object[] + { + null + }, + } + }, + } +}); +Response response = client.Publish("", content, configurationEtag: new ETag(""), transmissionTime: 1234L); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("ETag").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Id").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("TelemetryType").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("FieldName").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Predicate").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Comparand").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Projection").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Aggregation").ToString()); +Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("BackEndAggregation").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("Id").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("TelemetryType").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("FieldName").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Predicate").ToString()); +Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Comparand").ToString()); +Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("InitialQuota").ToString()); +Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("MaxQuota").ToString()); +Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("QuotaAccrualRatePerSec").ToString()); +]]> + + + \ No newline at end of file diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentFilterConjunctionGroupInfo.Serialization.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentFilterConjunctionGroupInfo.Serialization.cs new file mode 100644 index 000000000000..e7de6a3e4334 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentFilterConjunctionGroupInfo.Serialization.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace LiveMetrics +{ + public partial class DocumentFilterConjunctionGroupInfo : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DocumentFilterConjunctionGroupInfo)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("TelemetryType"u8); + writer.WriteStringValue(TelemetryType.ToString()); + writer.WritePropertyName("Filters"u8); + writer.WriteObjectValue(Filters, options); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DocumentFilterConjunctionGroupInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DocumentFilterConjunctionGroupInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDocumentFilterConjunctionGroupInfo(document.RootElement, options); + } + + internal static DocumentFilterConjunctionGroupInfo DeserializeDocumentFilterConjunctionGroupInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TelemetryType telemetryType = default; + FilterConjunctionGroupInfo filters = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("TelemetryType"u8)) + { + telemetryType = new TelemetryType(property.Value.GetString()); + continue; + } + if (property.NameEquals("Filters"u8)) + { + filters = FilterConjunctionGroupInfo.DeserializeFilterConjunctionGroupInfo(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DocumentFilterConjunctionGroupInfo(telemetryType, filters, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(DocumentFilterConjunctionGroupInfo)} does not support writing '{options.Format}' format."); + } + } + + DocumentFilterConjunctionGroupInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeDocumentFilterConjunctionGroupInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DocumentFilterConjunctionGroupInfo)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static DocumentFilterConjunctionGroupInfo FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeDocumentFilterConjunctionGroupInfo(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentFilterConjunctionGroupInfo.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentFilterConjunctionGroupInfo.cs new file mode 100644 index 000000000000..ab47aa5a5a85 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentFilterConjunctionGroupInfo.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace LiveMetrics +{ + /// A collection of filters for a specific telemetry type. + public partial class DocumentFilterConjunctionGroupInfo + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Telemetry type. + /// An array of filter groups. + /// is null. + internal DocumentFilterConjunctionGroupInfo(TelemetryType telemetryType, FilterConjunctionGroupInfo filters) + { + Argument.AssertNotNull(filters, nameof(filters)); + + TelemetryType = telemetryType; + Filters = filters; + } + + /// Initializes a new instance of . + /// Telemetry type. + /// An array of filter groups. + /// Keeps track of any properties unknown to the library. + internal DocumentFilterConjunctionGroupInfo(TelemetryType telemetryType, FilterConjunctionGroupInfo filters, IDictionary serializedAdditionalRawData) + { + TelemetryType = telemetryType; + Filters = filters; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DocumentFilterConjunctionGroupInfo() + { + } + + /// Telemetry type. + public TelemetryType TelemetryType { get; } + /// An array of filter groups. + public FilterConjunctionGroupInfo Filters { get; } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentIngress.Serialization.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentIngress.Serialization.cs new file mode 100644 index 000000000000..1be02faa164f --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentIngress.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace LiveMetrics +{ + [PersistableModelProxy(typeof(UnknownDocumentIngress))] + public partial class DocumentIngress : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DocumentIngress)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("DocumentType"u8); + writer.WriteStringValue(DocumentType.ToString()); + if (Optional.IsCollectionDefined(DocumentStreamIds)) + { + writer.WritePropertyName("DocumentStreamIds"u8); + writer.WriteStartArray(); + foreach (var item in DocumentStreamIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("Properties"u8); + writer.WriteStartArray(); + foreach (var item in Properties) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DocumentIngress IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DocumentIngress)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDocumentIngress(document.RootElement, options); + } + + internal static DocumentIngress DeserializeDocumentIngress(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("DocumentType", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "Event": return Event.DeserializeEvent(element, options); + case "Exception": return Exception.DeserializeException(element, options); + case "RemoteDependency": return RemoteDependency.DeserializeRemoteDependency(element, options); + case "Request": return Request.DeserializeRequest(element, options); + case "Trace": return Trace.DeserializeTrace(element, options); + } + } + return UnknownDocumentIngress.DeserializeUnknownDocumentIngress(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(DocumentIngress)} does not support writing '{options.Format}' format."); + } + } + + DocumentIngress IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeDocumentIngress(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DocumentIngress)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static DocumentIngress FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeDocumentIngress(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentIngress.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentIngress.cs new file mode 100644 index 000000000000..495a1ba03e02 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentIngress.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace LiveMetrics +{ + /// + /// Base class of the specific document types. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + public abstract partial class DocumentIngress + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected DocumentIngress() + { + DocumentStreamIds = new ChangeTrackingList(); + Properties = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Telemetry type. Types not defined in enum will get replaced with a 'Unknown' type. + /// An array of document streaming ids. Each id identifies a flow of documents customized by UX customers. + /// Collection of custom properties. + /// Keeps track of any properties unknown to the library. + internal DocumentIngress(DocumentType documentType, IList documentStreamIds, IList properties, IDictionary serializedAdditionalRawData) + { + DocumentType = documentType; + DocumentStreamIds = documentStreamIds; + Properties = properties; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Telemetry type. Types not defined in enum will get replaced with a 'Unknown' type. + internal DocumentType DocumentType { get; set; } + /// An array of document streaming ids. Each id identifies a flow of documents customized by UX customers. + public IList DocumentStreamIds { get; } + /// Collection of custom properties. + public IList Properties { get; } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentStreamInfo.Serialization.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentStreamInfo.Serialization.cs new file mode 100644 index 000000000000..aa75dce40ded --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentStreamInfo.Serialization.cs @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace LiveMetrics +{ + public partial class DocumentStreamInfo : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DocumentStreamInfo)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("Id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("DocumentFilterGroups"u8); + writer.WriteStartArray(); + foreach (var item in DocumentFilterGroups) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DocumentStreamInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DocumentStreamInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDocumentStreamInfo(document.RootElement, options); + } + + internal static DocumentStreamInfo DeserializeDocumentStreamInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + IReadOnlyList documentFilterGroups = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("Id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("DocumentFilterGroups"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DocumentFilterConjunctionGroupInfo.DeserializeDocumentFilterConjunctionGroupInfo(item, options)); + } + documentFilterGroups = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DocumentStreamInfo(id, documentFilterGroups, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(DocumentStreamInfo)} does not support writing '{options.Format}' format."); + } + } + + DocumentStreamInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeDocumentStreamInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DocumentStreamInfo)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static DocumentStreamInfo FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeDocumentStreamInfo(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentStreamInfo.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentStreamInfo.cs new file mode 100644 index 000000000000..02101af6454e --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentStreamInfo.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace LiveMetrics +{ + /// Configurations/filters set by UX to scope the document/telemetry it's interested in. + public partial class DocumentStreamInfo + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Identifier of the document stream initiated by a UX. + /// Gets or sets an OR-connected collection of filter groups. + /// or is null. + internal DocumentStreamInfo(string id, IEnumerable documentFilterGroups) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(documentFilterGroups, nameof(documentFilterGroups)); + + Id = id; + DocumentFilterGroups = documentFilterGroups.ToList(); + } + + /// Initializes a new instance of . + /// Identifier of the document stream initiated by a UX. + /// Gets or sets an OR-connected collection of filter groups. + /// Keeps track of any properties unknown to the library. + internal DocumentStreamInfo(string id, IReadOnlyList documentFilterGroups, IDictionary serializedAdditionalRawData) + { + Id = id; + DocumentFilterGroups = documentFilterGroups; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DocumentStreamInfo() + { + } + + /// Identifier of the document stream initiated by a UX. + public string Id { get; } + /// Gets or sets an OR-connected collection of filter groups. + public IReadOnlyList DocumentFilterGroups { get; } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentType.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentType.cs new file mode 100644 index 000000000000..43d78ae38ff3 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/DocumentType.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace LiveMetrics +{ + /// Document type. + internal readonly partial struct DocumentType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DocumentType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string RequestValue = "Request"; + private const string RemoteDependencyValue = "RemoteDependency"; + private const string ExceptionValue = "Exception"; + private const string EventValue = "Event"; + private const string TraceValue = "Trace"; + private const string UnknownValue = "Unknown"; + + /// Represents a request telemetry type. + public static DocumentType Request { get; } = new DocumentType(RequestValue); + /// Represents a remote dependency telemetry type. + public static DocumentType RemoteDependency { get; } = new DocumentType(RemoteDependencyValue); + /// Represents an exception telemetry type. + public static DocumentType Exception { get; } = new DocumentType(ExceptionValue); + /// Represents an event telemetry type. + public static DocumentType Event { get; } = new DocumentType(EventValue); + /// Represents a trace telemetry type. + public static DocumentType Trace { get; } = new DocumentType(TraceValue); + /// Represents an unknown telemetry type. + public static DocumentType Unknown { get; } = new DocumentType(UnknownValue); + /// Determines if two values are the same. + public static bool operator ==(DocumentType left, DocumentType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DocumentType left, DocumentType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DocumentType(string value) => new DocumentType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DocumentType other && Equals(other); + /// + public bool Equals(DocumentType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Event.Serialization.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Event.Serialization.cs new file mode 100644 index 000000000000..e5129532dcdb --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Event.Serialization.cs @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace LiveMetrics +{ + public partial class Event : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Event)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("Name"u8); + writer.WriteStringValue(Name); + } + writer.WritePropertyName("DocumentType"u8); + writer.WriteStringValue(DocumentType.ToString()); + if (Optional.IsCollectionDefined(DocumentStreamIds)) + { + writer.WritePropertyName("DocumentStreamIds"u8); + writer.WriteStartArray(); + foreach (var item in DocumentStreamIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("Properties"u8); + writer.WriteStartArray(); + foreach (var item in Properties) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + Event IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Event)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeEvent(document.RootElement, options); + } + + internal static Event DeserializeEvent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + DocumentType documentType = default; + IList documentStreamIds = default; + IList properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("Name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("DocumentType"u8)) + { + documentType = new DocumentType(property.Value.GetString()); + continue; + } + if (property.NameEquals("DocumentStreamIds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + documentStreamIds = array; + continue; + } + if (property.NameEquals("Properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(KeyValuePairStringString.DeserializeKeyValuePairStringString(item, options)); + } + properties = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Event(documentType, documentStreamIds ?? new ChangeTrackingList(), properties ?? new ChangeTrackingList(), serializedAdditionalRawData, name); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Event)} does not support writing '{options.Format}' format."); + } + } + + Event IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeEvent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Event)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new Event FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeEvent(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Event.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Event.cs new file mode 100644 index 000000000000..ac0ba2ec5b66 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Event.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace LiveMetrics +{ + /// Event document type. + public partial class Event : DocumentIngress + { + /// Initializes a new instance of . + public Event() + { + DocumentType = DocumentType.Event; + } + + /// Initializes a new instance of . + /// Telemetry type. Types not defined in enum will get replaced with a 'Unknown' type. + /// An array of document streaming ids. Each id identifies a flow of documents customized by UX customers. + /// Collection of custom properties. + /// Keeps track of any properties unknown to the library. + /// Event name. + internal Event(DocumentType documentType, IList documentStreamIds, IList properties, IDictionary serializedAdditionalRawData, string name) : base(documentType, documentStreamIds, properties, serializedAdditionalRawData) + { + Name = name; + } + + /// Event name. + public string Name { get; set; } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Exception.Serialization.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Exception.Serialization.cs new file mode 100644 index 000000000000..d4166a6a8d44 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Exception.Serialization.cs @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace LiveMetrics +{ + public partial class Exception : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Exception)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ExceptionType)) + { + writer.WritePropertyName("ExceptionType"u8); + writer.WriteStringValue(ExceptionType); + } + if (Optional.IsDefined(ExceptionMessage)) + { + writer.WritePropertyName("ExceptionMessage"u8); + writer.WriteStringValue(ExceptionMessage); + } + writer.WritePropertyName("DocumentType"u8); + writer.WriteStringValue(DocumentType.ToString()); + if (Optional.IsCollectionDefined(DocumentStreamIds)) + { + writer.WritePropertyName("DocumentStreamIds"u8); + writer.WriteStartArray(); + foreach (var item in DocumentStreamIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("Properties"u8); + writer.WriteStartArray(); + foreach (var item in Properties) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + Exception IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Exception)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeException(document.RootElement, options); + } + + internal static Exception DeserializeException(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string exceptionType = default; + string exceptionMessage = default; + DocumentType documentType = default; + IList documentStreamIds = default; + IList properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ExceptionType"u8)) + { + exceptionType = property.Value.GetString(); + continue; + } + if (property.NameEquals("ExceptionMessage"u8)) + { + exceptionMessage = property.Value.GetString(); + continue; + } + if (property.NameEquals("DocumentType"u8)) + { + documentType = new DocumentType(property.Value.GetString()); + continue; + } + if (property.NameEquals("DocumentStreamIds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + documentStreamIds = array; + continue; + } + if (property.NameEquals("Properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(KeyValuePairStringString.DeserializeKeyValuePairStringString(item, options)); + } + properties = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Exception( + documentType, + documentStreamIds ?? new ChangeTrackingList(), + properties ?? new ChangeTrackingList(), + serializedAdditionalRawData, + exceptionType, + exceptionMessage); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Exception)} does not support writing '{options.Format}' format."); + } + } + + Exception IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeException(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Exception)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new Exception FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeException(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Exception.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Exception.cs new file mode 100644 index 000000000000..33c36b88e5e0 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Exception.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace LiveMetrics +{ + /// Exception document type. + public partial class Exception : DocumentIngress + { + /// Initializes a new instance of . + public Exception() + { + DocumentType = DocumentType.Exception; + } + + /// Initializes a new instance of . + /// Telemetry type. Types not defined in enum will get replaced with a 'Unknown' type. + /// An array of document streaming ids. Each id identifies a flow of documents customized by UX customers. + /// Collection of custom properties. + /// Keeps track of any properties unknown to the library. + /// Exception type name. + /// Exception message. + internal Exception(DocumentType documentType, IList documentStreamIds, IList properties, IDictionary serializedAdditionalRawData, string exceptionType, string exceptionMessage) : base(documentType, documentStreamIds, properties, serializedAdditionalRawData) + { + ExceptionType = exceptionType; + ExceptionMessage = exceptionMessage; + } + + /// Exception type name. + public string ExceptionType { get; set; } + /// Exception message. + public string ExceptionMessage { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateAssistantFileRequest.Serialization.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/FilterConjunctionGroupInfo.Serialization.cs similarity index 61% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateAssistantFileRequest.Serialization.cs rename to sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/FilterConjunctionGroupInfo.Serialization.cs index 3abf92d075f2..b06b826b356b 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateAssistantFileRequest.Serialization.cs +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/FilterConjunctionGroupInfo.Serialization.cs @@ -9,25 +9,31 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure; using Azure.Core; -namespace Azure.AI.OpenAI.Assistants +namespace LiveMetrics { - internal partial class CreateAssistantFileRequest : IUtf8JsonSerializable, IJsonModel + public partial class FilterConjunctionGroupInfo : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(CreateAssistantFileRequest)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(FilterConjunctionGroupInfo)} does not support writing '{format}' format."); } writer.WriteStartObject(); - writer.WritePropertyName("file_id"u8); - writer.WriteStringValue(FileId); + writer.WritePropertyName("Filters"u8); + writer.WriteStartArray(); + foreach (var item in Filters) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -46,19 +52,19 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe writer.WriteEndObject(); } - CreateAssistantFileRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + FilterConjunctionGroupInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(CreateAssistantFileRequest)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(FilterConjunctionGroupInfo)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCreateAssistantFileRequest(document.RootElement, options); + return DeserializeFilterConjunctionGroupInfo(document.RootElement, options); } - internal static CreateAssistantFileRequest DeserializeCreateAssistantFileRequest(JsonElement element, ModelReaderWriterOptions options = null) + internal static FilterConjunctionGroupInfo DeserializeFilterConjunctionGroupInfo(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -66,14 +72,19 @@ internal static CreateAssistantFileRequest DeserializeCreateAssistantFileRequest { return null; } - string fileId = default; + IReadOnlyList filters = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("file_id"u8)) + if (property.NameEquals("Filters"u8)) { - fileId = property.Value.GetString(); + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(FilterInfo.DeserializeFilterInfo(item, options)); + } + filters = array; continue; } if (options.Format != "W") @@ -82,46 +93,46 @@ internal static CreateAssistantFileRequest DeserializeCreateAssistantFileRequest } } serializedAdditionalRawData = rawDataDictionary; - return new CreateAssistantFileRequest(fileId, serializedAdditionalRawData); + return new FilterConjunctionGroupInfo(filters, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(CreateAssistantFileRequest)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(FilterConjunctionGroupInfo)} does not support writing '{options.Format}' format."); } } - CreateAssistantFileRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + FilterConjunctionGroupInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data); - return DeserializeCreateAssistantFileRequest(document.RootElement, options); + return DeserializeFilterConjunctionGroupInfo(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(CreateAssistantFileRequest)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(FilterConjunctionGroupInfo)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static CreateAssistantFileRequest FromResponse(Response response) + internal static FilterConjunctionGroupInfo FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content); - return DeserializeCreateAssistantFileRequest(document.RootElement); + return DeserializeFilterConjunctionGroupInfo(document.RootElement); } /// Convert into a . diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/FilterConjunctionGroupInfo.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/FilterConjunctionGroupInfo.cs new file mode 100644 index 000000000000..16ce6d4a1f18 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/FilterConjunctionGroupInfo.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace LiveMetrics +{ + /// An AND-connected group of FilterInfo objects. + public partial class FilterConjunctionGroupInfo + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// An array of filters. + /// is null. + internal FilterConjunctionGroupInfo(IEnumerable filters) + { + Argument.AssertNotNull(filters, nameof(filters)); + + Filters = filters.ToList(); + } + + /// Initializes a new instance of . + /// An array of filters. + /// Keeps track of any properties unknown to the library. + internal FilterConjunctionGroupInfo(IReadOnlyList filters, IDictionary serializedAdditionalRawData) + { + Filters = filters; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FilterConjunctionGroupInfo() + { + } + + /// An array of filters. + public IReadOnlyList Filters { get; } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/FilterInfo.Serialization.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/FilterInfo.Serialization.cs new file mode 100644 index 000000000000..18a7b1c91d54 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/FilterInfo.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace LiveMetrics +{ + public partial class FilterInfo : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FilterInfo)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("FieldName"u8); + writer.WriteStringValue(FieldName); + writer.WritePropertyName("Predicate"u8); + writer.WriteStringValue(Predicate.ToString()); + writer.WritePropertyName("Comparand"u8); + writer.WriteStringValue(Comparand); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + FilterInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FilterInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFilterInfo(document.RootElement, options); + } + + internal static FilterInfo DeserializeFilterInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fieldName = default; + PredicateType predicate = default; + string comparand = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("FieldName"u8)) + { + fieldName = property.Value.GetString(); + continue; + } + if (property.NameEquals("Predicate"u8)) + { + predicate = new PredicateType(property.Value.GetString()); + continue; + } + if (property.NameEquals("Comparand"u8)) + { + comparand = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FilterInfo(fieldName, predicate, comparand, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FilterInfo)} does not support writing '{options.Format}' format."); + } + } + + FilterInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFilterInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FilterInfo)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static FilterInfo FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFilterInfo(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/FilterInfo.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/FilterInfo.cs new file mode 100644 index 000000000000..227a405ba0cb --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/FilterInfo.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace LiveMetrics +{ + /// A filter set on UX. + public partial class FilterInfo + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// dimension name of the filter. + /// Operator of the filter. + /// Comparand of the filter. + /// or is null. + internal FilterInfo(string fieldName, PredicateType predicate, string comparand) + { + Argument.AssertNotNull(fieldName, nameof(fieldName)); + Argument.AssertNotNull(comparand, nameof(comparand)); + + FieldName = fieldName; + Predicate = predicate; + Comparand = comparand; + } + + /// Initializes a new instance of . + /// dimension name of the filter. + /// Operator of the filter. + /// Comparand of the filter. + /// Keeps track of any properties unknown to the library. + internal FilterInfo(string fieldName, PredicateType predicate, string comparand, IDictionary serializedAdditionalRawData) + { + FieldName = fieldName; + Predicate = predicate; + Comparand = comparand; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FilterInfo() + { + } + + /// dimension name of the filter. + public string FieldName { get; } + /// Operator of the filter. + public PredicateType Predicate { get; } + /// Comparand of the filter. + public string Comparand { get; } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/Argument.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..fd93d797ccdf --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/Argument.cs @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace LiveMetrics +{ + internal static class Argument + { + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value is ICollection collectionOfT && collectionOfT.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + } + + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", name); + } + } + + public static void AssertNotNullOrWhiteSpace(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); + } + } + + public static void AssertNotDefault(ref T value, string name) + where T : struct, IEquatable + { + if (value.Equals(default)) + { + throw new ArgumentException("Value cannot be empty.", name); + } + } + + public static void AssertInRange(T value, T minimum, T maximum, string name) + where T : notnull, IComparable + { + if (minimum.CompareTo(value) > 0) + { + throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); + } + if (maximum.CompareTo(value) < 0) + { + throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); + } + } + + public static void AssertEnumDefined(Type enumType, object value, string name) + { + if (!Enum.IsDefined(enumType, value)) + { + throw new ArgumentException($"Value not defined for {enumType.FullName}.", name); + } + } + + public static T CheckNotNull(T value, string name) + where T : class + { + AssertNotNull(value, name); + return value; + } + + public static string CheckNotNullOrEmpty(string value, string name) + { + AssertNotNullOrEmpty(value, name); + return value; + } + + public static void AssertNull(T value, string name, string message = null) + { + if (value != null) + { + throw new ArgumentException(message ?? "Value must be null.", name); + } + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..adba2e33ac67 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace LiveMetrics +{ + internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + public bool IsUndefined => _innerDictionary == null; + + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + IEnumerable IReadOnlyDictionary.Keys => Keys; + + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) + { + value = default; + return false; + } + return EnsureDictionary().TryGetValue(key, out value); + } + + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/ChangeTrackingList.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..d80288a80595 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace LiveMetrics +{ + internal class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + public bool IsUndefined => _innerList == null; + + public int Count => IsUndefined ? 0 : EnsureList().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..88ff058c3168 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,398 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Text.Json; +using System.Xml; +using Azure.Core; + +namespace LiveMetrics +{ + internal static class ModelSerializationExtensions + { + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + var dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + var list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + var text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + { + throw new JsonException($"A property '{property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + var value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case IUtf8JsonSerializable serializable: + serializable.Write(writer); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + + internal static class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Azure SDK requires it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; + int size = checked(numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ConvertToString(object value, string format = null) => value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when format != null => ToString(b0, format), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when format != null => ToString(dateTime, format), + TimeSpan timeSpan when format != null => ToString(timeSpan, format), + TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/Optional.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..eeab5e028d1a --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/Optional.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace LiveMetrics +{ + internal static class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + + public static bool IsDefined(string value) + { + return value != null; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/RequestContentHelper.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/RequestContentHelper.cs new file mode 100644 index 000000000000..fe0b285b88d9 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/RequestContentHelper.cs @@ -0,0 +1,136 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace LiveMetrics +{ + internal static class RequestContentHelper + { + public static RequestContent FromEnumerable(IEnumerable enumerable) + where T : notnull + { + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteStartArray(); + foreach (var item in enumerable) + { + content.JsonWriter.WriteObjectValue(item, ModelSerializationExtensions.WireOptions); + } + content.JsonWriter.WriteEndArray(); + + return content; + } + + public static RequestContent FromEnumerable(IEnumerable enumerable) + { + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteStartArray(); + foreach (var item in enumerable) + { + if (item == null) + { + content.JsonWriter.WriteNullValue(); + } + else + { +#if NET6_0_OR_GREATER + content.JsonWriter.WriteRawValue(item); +#else + using (JsonDocument document = JsonDocument.Parse(item)) + { + JsonSerializer.Serialize(content.JsonWriter, document.RootElement); + } +#endif + } + } + content.JsonWriter.WriteEndArray(); + + return content; + } + + public static RequestContent FromEnumerable(ReadOnlySpan span) + where T : notnull + { + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteStartArray(); + for (int i = 0; i < span.Length; i++) + { + content.JsonWriter.WriteObjectValue(span[i], ModelSerializationExtensions.WireOptions); + } + content.JsonWriter.WriteEndArray(); + + return content; + } + + public static RequestContent FromDictionary(IDictionary dictionary) + where TValue : notnull + { + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteStartObject(); + foreach (var item in dictionary) + { + content.JsonWriter.WritePropertyName(item.Key); + content.JsonWriter.WriteObjectValue(item.Value, ModelSerializationExtensions.WireOptions); + } + content.JsonWriter.WriteEndObject(); + + return content; + } + + public static RequestContent FromDictionary(IDictionary dictionary) + { + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteStartObject(); + foreach (var item in dictionary) + { + content.JsonWriter.WritePropertyName(item.Key); + if (item.Value == null) + { + content.JsonWriter.WriteNullValue(); + } + else + { +#if NET6_0_OR_GREATER + content.JsonWriter.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(content.JsonWriter, document.RootElement); + } +#endif + } + } + content.JsonWriter.WriteEndObject(); + + return content; + } + + public static RequestContent FromObject(object value) + { + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(value, ModelSerializationExtensions.WireOptions); + return content; + } + + public static RequestContent FromObject(BinaryData value) + { + Utf8JsonRequestContent content = new Utf8JsonRequestContent(); +#if NET6_0_OR_GREATER + content.JsonWriter.WriteRawValue(value); +#else + using (JsonDocument document = JsonDocument.Parse(value)) + { + JsonSerializer.Serialize(content.JsonWriter, document.RootElement); + } +#endif + return content; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..0d748623b16d --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.IO; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace LiveMetrics +{ + internal class Utf8JsonRequestContent : RequestContent + { + private readonly MemoryStream _stream; + private readonly RequestContent _content; + + public Utf8JsonRequestContent() + { + _stream = new MemoryStream(); + _content = Create(_stream); + JsonWriter = new Utf8JsonWriter(_stream); + } + + public Utf8JsonWriter JsonWriter { get; } + + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { + await JsonWriter.FlushAsync().ConfigureAwait(false); + await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + } + + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { + JsonWriter.Flush(); + _content.WriteTo(stream, cancellationToken); + } + + public override bool TryComputeLength(out long length) + { + length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; + return true; + } + + public override void Dispose() + { + JsonWriter.Dispose(); + _content.Dispose(); + _stream.Dispose(); + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/KeyValuePairStringString.Serialization.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/KeyValuePairStringString.Serialization.cs new file mode 100644 index 000000000000..4512b35484ca --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/KeyValuePairStringString.Serialization.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace LiveMetrics +{ + public partial class KeyValuePairStringString : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KeyValuePairStringString)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("key"u8); + writer.WriteStringValue(Key); + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + KeyValuePairStringString IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KeyValuePairStringString)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKeyValuePairStringString(document.RootElement, options); + } + + internal static KeyValuePairStringString DeserializeKeyValuePairStringString(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string key = default; + string value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("key"u8)) + { + key = property.Value.GetString(); + continue; + } + if (property.NameEquals("value"u8)) + { + value = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KeyValuePairStringString(key, value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(KeyValuePairStringString)} does not support writing '{options.Format}' format."); + } + } + + KeyValuePairStringString IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeKeyValuePairStringString(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KeyValuePairStringString)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static KeyValuePairStringString FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeKeyValuePairStringString(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/KeyValuePairStringString.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/KeyValuePairStringString.cs new file mode 100644 index 000000000000..ebe35b0f0370 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/KeyValuePairStringString.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace LiveMetrics +{ + /// Key-value pair of string and string. + public partial class KeyValuePairStringString + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Key of the key-value pair. + /// Value of the key-value pair. + /// or is null. + public KeyValuePairStringString(string key, string value) + { + Argument.AssertNotNull(key, nameof(key)); + Argument.AssertNotNull(value, nameof(value)); + + Key = key; + Value = value; + } + + /// Initializes a new instance of . + /// Key of the key-value pair. + /// Value of the key-value pair. + /// Keeps track of any properties unknown to the library. + internal KeyValuePairStringString(string key, string value, IDictionary serializedAdditionalRawData) + { + Key = key; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal KeyValuePairStringString() + { + } + + /// Key of the key-value pair. + public string Key { get; } + /// Value of the key-value pair. + public string Value { get; } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/LiveMetricsClient.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/LiveMetricsClient.cs new file mode 100644 index 000000000000..48b465ab2013 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/LiveMetricsClient.cs @@ -0,0 +1,408 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace LiveMetrics +{ + // Data plane generated client. + /// Live Metrics REST APIs. + public partial class LiveMetricsClient + { + private static readonly string[] AuthorizationScopes = new string[] { "https://monitor.azure.com/.default" }; + private readonly TokenCredential _tokenCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of LiveMetricsClient for mocking. + protected LiveMetricsClient() + { + } + + /// Initializes a new instance of LiveMetricsClient. + /// A credential used to authenticate to an Azure Service. + /// is null. + public LiveMetricsClient(TokenCredential credential) : this(new Uri("https://global.livediagnostics.monitor.azure.com"), credential, new LiveMetricsClientOptions()) + { + } + + /// Initializes a new instance of LiveMetricsClient. + /// The endpoint of the Live Metrics service. + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public LiveMetricsClient(Uri endpoint, TokenCredential credential, LiveMetricsClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new LiveMetricsClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _tokenCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new BearerTokenAuthenticationPolicy(_tokenCredential, AuthorizationScopes) }, new ResponseClassifier()); + _endpoint = endpoint; + _apiVersion = options.Version; + } + + /// Determine whether there is any subscription to the metrics and documents. + /// The instrumentation key of the target Application Insights component for which the client checks whether there's any subscription to it. + /// Data contract between Application Insights client SDK and Live Metrics. /QuickPulseService.svc/ping uses this as a backup source of machine name, instance name and invariant version. + /// Timestamp when the client transmits the metrics and documents to Live Metrics. A 8-byte long type of ticks. + /// Computer name where Application Insights SDK lives. Live Metrics uses machine name with instance name as a backup. + /// Service instance name where Application Insights SDK lives. Live Metrics uses machine name with instance name as a backup. + /// Identifies an Application Insights SDK as trusted agent to report metrics and documents. + /// Cloud role name of the service. + /// Version/generation of the data contract (MonitoringDataPoint) between the client and Live Metrics. + /// An encoded string that indicates whether the collection configuration is changed. + /// The cancellation token to use. + /// is null. + /// + public virtual async Task> IsSubscribedAsync(string ikey, MonitoringDataPoint monitoringDataPoint = null, long? transmissionTime = null, string machineName = null, string instanceName = null, string streamId = null, string roleName = null, string invariantVersion = null, ETag? configurationEtag = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(ikey, nameof(ikey)); + + using RequestContent content = monitoringDataPoint?.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await IsSubscribedAsync(ikey, content, transmissionTime, machineName, instanceName, streamId, roleName, invariantVersion, configurationEtag, context).ConfigureAwait(false); + return Response.FromValue(CollectionConfigurationInfo.FromResponse(response), response); + } + + /// Determine whether there is any subscription to the metrics and documents. + /// The instrumentation key of the target Application Insights component for which the client checks whether there's any subscription to it. + /// Data contract between Application Insights client SDK and Live Metrics. /QuickPulseService.svc/ping uses this as a backup source of machine name, instance name and invariant version. + /// Timestamp when the client transmits the metrics and documents to Live Metrics. A 8-byte long type of ticks. + /// Computer name where Application Insights SDK lives. Live Metrics uses machine name with instance name as a backup. + /// Service instance name where Application Insights SDK lives. Live Metrics uses machine name with instance name as a backup. + /// Identifies an Application Insights SDK as trusted agent to report metrics and documents. + /// Cloud role name of the service. + /// Version/generation of the data contract (MonitoringDataPoint) between the client and Live Metrics. + /// An encoded string that indicates whether the collection configuration is changed. + /// The cancellation token to use. + /// is null. + /// + public virtual Response IsSubscribed(string ikey, MonitoringDataPoint monitoringDataPoint = null, long? transmissionTime = null, string machineName = null, string instanceName = null, string streamId = null, string roleName = null, string invariantVersion = null, ETag? configurationEtag = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(ikey, nameof(ikey)); + + using RequestContent content = monitoringDataPoint?.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = IsSubscribed(ikey, content, transmissionTime, machineName, instanceName, streamId, roleName, invariantVersion, configurationEtag, context); + return Response.FromValue(CollectionConfigurationInfo.FromResponse(response), response); + } + + /// + /// [Protocol Method] Determine whether there is any subscription to the metrics and documents. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The instrumentation key of the target Application Insights component for which the client checks whether there's any subscription to it. + /// The content to send as the body of the request. + /// Timestamp when the client transmits the metrics and documents to Live Metrics. A 8-byte long type of ticks. + /// Computer name where Application Insights SDK lives. Live Metrics uses machine name with instance name as a backup. + /// Service instance name where Application Insights SDK lives. Live Metrics uses machine name with instance name as a backup. + /// Identifies an Application Insights SDK as trusted agent to report metrics and documents. + /// Cloud role name of the service. + /// Version/generation of the data contract (MonitoringDataPoint) between the client and Live Metrics. + /// An encoded string that indicates whether the collection configuration is changed. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task IsSubscribedAsync(string ikey, RequestContent content, long? transmissionTime = null, string machineName = null, string instanceName = null, string streamId = null, string roleName = null, string invariantVersion = null, ETag? configurationEtag = null, RequestContext context = null) + { + Argument.AssertNotNull(ikey, nameof(ikey)); + + using var scope = ClientDiagnostics.CreateScope("LiveMetricsClient.IsSubscribed"); + scope.Start(); + try + { + using HttpMessage message = CreateIsSubscribedRequest(ikey, content, transmissionTime, machineName, instanceName, streamId, roleName, invariantVersion, configurationEtag, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (System.Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Determine whether there is any subscription to the metrics and documents. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The instrumentation key of the target Application Insights component for which the client checks whether there's any subscription to it. + /// The content to send as the body of the request. + /// Timestamp when the client transmits the metrics and documents to Live Metrics. A 8-byte long type of ticks. + /// Computer name where Application Insights SDK lives. Live Metrics uses machine name with instance name as a backup. + /// Service instance name where Application Insights SDK lives. Live Metrics uses machine name with instance name as a backup. + /// Identifies an Application Insights SDK as trusted agent to report metrics and documents. + /// Cloud role name of the service. + /// Version/generation of the data contract (MonitoringDataPoint) between the client and Live Metrics. + /// An encoded string that indicates whether the collection configuration is changed. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response IsSubscribed(string ikey, RequestContent content, long? transmissionTime = null, string machineName = null, string instanceName = null, string streamId = null, string roleName = null, string invariantVersion = null, ETag? configurationEtag = null, RequestContext context = null) + { + Argument.AssertNotNull(ikey, nameof(ikey)); + + using var scope = ClientDiagnostics.CreateScope("LiveMetricsClient.IsSubscribed"); + scope.Start(); + try + { + using HttpMessage message = CreateIsSubscribedRequest(ikey, content, transmissionTime, machineName, instanceName, streamId, roleName, invariantVersion, configurationEtag, context); + return _pipeline.ProcessMessage(message, context); + } + catch (System.Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Publish live metrics to the Live Metrics service when there is an active subscription to the metrics. + /// The instrumentation key of the target Application Insights component for which the client checks whether there's any subscription to it. + /// Data contract between the client and Live Metrics. /QuickPulseService.svc/ping uses this as a backup source of machine name, instance name and invariant version. + /// An encoded string that indicates whether the collection configuration is changed. + /// Timestamp when the client transmits the metrics and documents to Live Metrics. A 8-byte long type of ticks. + /// The cancellation token to use. + /// is null. + /// + public virtual async Task> PublishAsync(string ikey, IEnumerable monitoringDataPoints = null, ETag? configurationEtag = null, long? transmissionTime = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(ikey, nameof(ikey)); + + using RequestContent content = monitoringDataPoints != null ? RequestContentHelper.FromEnumerable(monitoringDataPoints) : null; + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await PublishAsync(ikey, content, configurationEtag, transmissionTime, context).ConfigureAwait(false); + return Response.FromValue(CollectionConfigurationInfo.FromResponse(response), response); + } + + /// Publish live metrics to the Live Metrics service when there is an active subscription to the metrics. + /// The instrumentation key of the target Application Insights component for which the client checks whether there's any subscription to it. + /// Data contract between the client and Live Metrics. /QuickPulseService.svc/ping uses this as a backup source of machine name, instance name and invariant version. + /// An encoded string that indicates whether the collection configuration is changed. + /// Timestamp when the client transmits the metrics and documents to Live Metrics. A 8-byte long type of ticks. + /// The cancellation token to use. + /// is null. + /// + public virtual Response Publish(string ikey, IEnumerable monitoringDataPoints = null, ETag? configurationEtag = null, long? transmissionTime = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(ikey, nameof(ikey)); + + using RequestContent content = monitoringDataPoints != null ? RequestContentHelper.FromEnumerable(monitoringDataPoints) : null; + RequestContext context = FromCancellationToken(cancellationToken); + Response response = Publish(ikey, content, configurationEtag, transmissionTime, context); + return Response.FromValue(CollectionConfigurationInfo.FromResponse(response), response); + } + + /// + /// [Protocol Method] Publish live metrics to the Live Metrics service when there is an active subscription to the metrics. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The instrumentation key of the target Application Insights component for which the client checks whether there's any subscription to it. + /// The content to send as the body of the request. + /// An encoded string that indicates whether the collection configuration is changed. + /// Timestamp when the client transmits the metrics and documents to Live Metrics. A 8-byte long type of ticks. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task PublishAsync(string ikey, RequestContent content, ETag? configurationEtag = null, long? transmissionTime = null, RequestContext context = null) + { + Argument.AssertNotNull(ikey, nameof(ikey)); + + using var scope = ClientDiagnostics.CreateScope("LiveMetricsClient.Publish"); + scope.Start(); + try + { + using HttpMessage message = CreatePublishRequest(ikey, content, configurationEtag, transmissionTime, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (System.Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Publish live metrics to the Live Metrics service when there is an active subscription to the metrics. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The instrumentation key of the target Application Insights component for which the client checks whether there's any subscription to it. + /// The content to send as the body of the request. + /// An encoded string that indicates whether the collection configuration is changed. + /// Timestamp when the client transmits the metrics and documents to Live Metrics. A 8-byte long type of ticks. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response Publish(string ikey, RequestContent content, ETag? configurationEtag = null, long? transmissionTime = null, RequestContext context = null) + { + Argument.AssertNotNull(ikey, nameof(ikey)); + + using var scope = ClientDiagnostics.CreateScope("LiveMetricsClient.Publish"); + scope.Start(); + try + { + using HttpMessage message = CreatePublishRequest(ikey, content, configurationEtag, transmissionTime, context); + return _pipeline.ProcessMessage(message, context); + } + catch (System.Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateIsSubscribedRequest(string ikey, RequestContent content, long? transmissionTime, string machineName, string instanceName, string streamId, string roleName, string invariantVersion, ETag? configurationEtag, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/QuickPulseService.svc/ping", false); + uri.AppendQuery("ikey", ikey, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + if (transmissionTime != null) + { + request.Headers.Add("x-ms-qps-transmission-time", transmissionTime.Value); + } + if (machineName != null) + { + request.Headers.Add("x-ms-qps-machine-name", machineName); + } + if (instanceName != null) + { + request.Headers.Add("x-ms-qps-instance-name", instanceName); + } + if (streamId != null) + { + request.Headers.Add("x-ms-qps-stream-id", streamId); + } + if (roleName != null) + { + request.Headers.Add("x-ms-qps-role-name", roleName); + } + if (invariantVersion != null) + { + request.Headers.Add("x-ms-qps-invariant-version", invariantVersion); + } + if (configurationEtag != null) + { + request.Headers.Add("x-ms-qps-configuration-etag", configurationEtag.Value); + } + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreatePublishRequest(string ikey, RequestContent content, ETag? configurationEtag, long? transmissionTime, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/QuickPulseService.svc/post", false); + uri.AppendQuery("ikey", ikey, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + if (configurationEtag != null) + { + request.Headers.Add("x-ms-qps-configuration-etag", configurationEtag.Value); + } + if (transmissionTime != null) + { + request.Headers.Add("x-ms-qps-transmission-time", transmissionTime.Value); + } + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/LiveMetricsClientBuilderExtensions.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/LiveMetricsClientBuilderExtensions.cs new file mode 100644 index 000000000000..8ecb9e953fd2 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/LiveMetricsClientBuilderExtensions.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core.Extensions; +using LiveMetrics; + +namespace Microsoft.Extensions.Azure +{ + /// Extension methods to add to client builder. + public static partial class LiveMetricsClientBuilderExtensions + { + /// Registers a instance. + /// The builder to register with. + /// The endpoint of the Live Metrics service. + public static IAzureClientBuilder AddLiveMetricsClient(this TBuilder builder, Uri endpoint) + where TBuilder : IAzureClientFactoryBuilderWithCredential + { + return builder.RegisterClientFactory((options, cred) => new LiveMetricsClient(endpoint, cred, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The configuration values. + public static IAzureClientBuilder AddLiveMetricsClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/LiveMetricsClientOptions.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/LiveMetricsClientOptions.cs new file mode 100644 index 000000000000..570f16b4a1b1 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/LiveMetricsClientOptions.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace LiveMetrics +{ + /// Client options for LiveMetricsClient. + public partial class LiveMetricsClientOptions : ClientOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2024_04_01_Preview; + + /// The version of the service to use. + public enum ServiceVersion + { + /// Service version "2024-04-01-preview". + V2024_04_01_Preview = 1, + } + + internal string Version { get; } + + /// Initializes new instance of LiveMetricsClientOptions. + public LiveMetricsClientOptions(ServiceVersion version = LatestVersion) + { + Version = version switch + { + ServiceVersion.V2024_04_01_Preview => "2024-04-01-preview", + _ => throw new NotSupportedException() + }; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/LiveMetricsModelFactory.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/LiveMetricsModelFactory.cs new file mode 100644 index 000000000000..512a865451bb --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/LiveMetricsModelFactory.cs @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace LiveMetrics +{ + /// Model factory for models. + public static partial class LiveMetricsModelFactory + { + /// Initializes a new instance of . + /// Application Insights SDK version. + /// Version/generation of the data contract (MonitoringDataPoint) between SDK and Live Metrics. + /// Service instance name where Application Insights SDK lives. + /// Service role name. + /// Computer name where Application Insights SDK lives. + /// Identifies an Application Insights SDK as a trusted agent to report metrics and documents. + /// Data point generation timestamp. + /// Timestamp when the client transmits the metrics and documents to Live Metrics. + /// True if the current application is an Azure Web App. + /// True if performance counters collection is supported. + /// An array of metric data points. + /// + /// An array of documents of a specific type {Request}, {RemoteDependency}, {Exception}, {Event}, or {Trace} + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// An array of top cpu consumption data point. + /// An array of error while SDK parses and applies the {CollectionConfigurationInfo} provided by Live Metrics. + /// A new instance for mocking. + public static MonitoringDataPoint MonitoringDataPoint(string version = null, int invariantVersion = default, string instance = null, string roleName = null, string machineName = null, string streamId = null, DateTimeOffset? timestamp = null, DateTimeOffset? transmissionTime = null, bool isWebApp = default, bool performanceCollectionSupported = default, IEnumerable metrics = null, IEnumerable documents = null, IEnumerable topCpuProcesses = null, IEnumerable collectionConfigurationErrors = null) + { + metrics ??= new List(); + documents ??= new List(); + topCpuProcesses ??= new List(); + collectionConfigurationErrors ??= new List(); + + return new MonitoringDataPoint( + version, + invariantVersion, + instance, + roleName, + machineName, + streamId, + timestamp, + transmissionTime, + isWebApp, + performanceCollectionSupported, + metrics?.ToList(), + documents?.ToList(), + topCpuProcesses?.ToList(), + collectionConfigurationErrors?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// An encoded string that indicates whether the collection configuration is changed. + /// An array of metric configuration info. + /// An array of document stream configuration info. + /// Controls document quotas to be sent to Live Metrics. + /// A new instance for mocking. + public static CollectionConfigurationInfo CollectionConfigurationInfo(string eTag = null, IEnumerable metrics = null, IEnumerable documentStreams = null, QuotaConfigurationInfo quotaInfo = null) + { + metrics ??= new List(); + documentStreams ??= new List(); + + return new CollectionConfigurationInfo(eTag, metrics?.ToList(), documentStreams?.ToList(), quotaInfo, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// metric configuration identifier. + /// Telemetry type. + /// A collection of filters to scope metrics that UX needs. + /// Telemetry's metric dimension whose value is to be aggregated. Example values: Duration, Count(),... + /// Aggregation type. This is the aggregation done from everything within a single server. + /// Aggregation type. This Aggregation is done across the values for all the servers taken together. + /// A new instance for mocking. + public static DerivedMetricInfo DerivedMetricInfo(string id = null, string telemetryType = null, IEnumerable filterGroups = null, string projection = null, AggregationType aggregation = default, AggregationType backEndAggregation = default) + { + filterGroups ??= new List(); + + return new DerivedMetricInfo( + id, + telemetryType, + filterGroups?.ToList(), + projection, + aggregation, + backEndAggregation, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// An array of filters. + /// A new instance for mocking. + public static FilterConjunctionGroupInfo FilterConjunctionGroupInfo(IEnumerable filters = null) + { + filters ??= new List(); + + return new FilterConjunctionGroupInfo(filters?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// dimension name of the filter. + /// Operator of the filter. + /// Comparand of the filter. + /// A new instance for mocking. + public static FilterInfo FilterInfo(string fieldName = null, PredicateType predicate = default, string comparand = null) + { + return new FilterInfo(fieldName, predicate, comparand, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Identifier of the document stream initiated by a UX. + /// Gets or sets an OR-connected collection of filter groups. + /// A new instance for mocking. + public static DocumentStreamInfo DocumentStreamInfo(string id = null, IEnumerable documentFilterGroups = null) + { + documentFilterGroups ??= new List(); + + return new DocumentStreamInfo(id, documentFilterGroups?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Telemetry type. + /// An array of filter groups. + /// A new instance for mocking. + public static DocumentFilterConjunctionGroupInfo DocumentFilterConjunctionGroupInfo(TelemetryType telemetryType = default, FilterConjunctionGroupInfo filters = null) + { + return new DocumentFilterConjunctionGroupInfo(telemetryType, filters, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Initial quota. + /// Max quota. + /// Quota accrual rate per second. + /// A new instance for mocking. + public static QuotaConfigurationInfo QuotaConfigurationInfo(float? initialQuota = null, float maxQuota = default, float quotaAccrualRatePerSec = default) + { + return new QuotaConfigurationInfo(initialQuota, maxQuota, quotaAccrualRatePerSec, serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageFile.Serialization.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/MetricPoint.Serialization.cs similarity index 61% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageFile.Serialization.cs rename to sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/MetricPoint.Serialization.cs index c1c5a4d65a5f..967317d72bdc 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageFile.Serialization.cs +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/MetricPoint.Serialization.cs @@ -9,31 +9,30 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Text.Json; +using Azure; using Azure.Core; -namespace Azure.AI.OpenAI.Assistants +namespace LiveMetrics { - public partial class MessageFile : IUtf8JsonSerializable, IJsonModel + public partial class MetricPoint : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(MessageFile)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(MetricPoint)} does not support writing '{format}' format."); } writer.WriteStartObject(); - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object); - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); - writer.WritePropertyName("message_id"u8); - writer.WriteStringValue(MessageId); + writer.WritePropertyName("Name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("Value"u8); + writer.WriteNumberValue(Value); + writer.WritePropertyName("Weight"u8); + writer.WriteNumberValue(Weight); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -52,19 +51,19 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptio writer.WriteEndObject(); } - MessageFile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + MetricPoint IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(MessageFile)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(MetricPoint)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeMessageFile(document.RootElement, options); + return DeserializeMetricPoint(document.RootElement, options); } - internal static MessageFile DeserializeMessageFile(JsonElement element, ModelReaderWriterOptions options = null) + internal static MetricPoint DeserializeMetricPoint(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -72,32 +71,26 @@ internal static MessageFile DeserializeMessageFile(JsonElement element, ModelRea { return null; } - string id = default; - string @object = default; - DateTimeOffset createdAt = default; - string messageId = default; + string name = default; + double value = default; + int weight = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) + if (property.NameEquals("Name"u8)) { - id = property.Value.GetString(); + name = property.Value.GetString(); continue; } - if (property.NameEquals("object"u8)) + if (property.NameEquals("Value"u8)) { - @object = property.Value.GetString(); + value = property.Value.GetDouble(); continue; } - if (property.NameEquals("created_at"u8)) + if (property.NameEquals("Weight"u8)) { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); - continue; - } - if (property.NameEquals("message_id"u8)) - { - messageId = property.Value.GetString(); + weight = property.Value.GetInt32(); continue; } if (options.Format != "W") @@ -106,46 +99,46 @@ internal static MessageFile DeserializeMessageFile(JsonElement element, ModelRea } } serializedAdditionalRawData = rawDataDictionary; - return new MessageFile(id, @object, createdAt, messageId, serializedAdditionalRawData); + return new MetricPoint(name, value, weight, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(MessageFile)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(MetricPoint)} does not support writing '{options.Format}' format."); } } - MessageFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + MetricPoint IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data); - return DeserializeMessageFile(document.RootElement, options); + return DeserializeMetricPoint(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(MessageFile)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(MetricPoint)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static MessageFile FromResponse(Response response) + internal static MetricPoint FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content); - return DeserializeMessageFile(document.RootElement); + return DeserializeMetricPoint(document.RootElement); } /// Convert into a . diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/MetricPoint.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/MetricPoint.cs new file mode 100644 index 000000000000..8c523231a237 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/MetricPoint.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace LiveMetrics +{ + /// Metric data point. + public partial class MetricPoint + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Metric name. + /// Metric value. + /// Metric weight. + /// is null. + public MetricPoint(string name, double value, int weight) + { + Argument.AssertNotNull(name, nameof(name)); + + Name = name; + Value = value; + Weight = weight; + } + + /// Initializes a new instance of . + /// Metric name. + /// Metric value. + /// Metric weight. + /// Keeps track of any properties unknown to the library. + internal MetricPoint(string name, double value, int weight, IDictionary serializedAdditionalRawData) + { + Name = name; + Value = value; + Weight = weight; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MetricPoint() + { + } + + /// Metric name. + public string Name { get; } + /// Metric value. + public double Value { get; } + /// Metric weight. + public int Weight { get; } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/MonitoringDataPoint.Serialization.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/MonitoringDataPoint.Serialization.cs new file mode 100644 index 000000000000..7919da945ac9 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/MonitoringDataPoint.Serialization.cs @@ -0,0 +1,337 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace LiveMetrics +{ + public partial class MonitoringDataPoint : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MonitoringDataPoint)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("Version"u8); + writer.WriteStringValue(Version); + writer.WritePropertyName("InvariantVersion"u8); + writer.WriteNumberValue(InvariantVersion); + writer.WritePropertyName("Instance"u8); + writer.WriteStringValue(Instance); + writer.WritePropertyName("RoleName"u8); + writer.WriteStringValue(RoleName); + writer.WritePropertyName("MachineName"u8); + writer.WriteStringValue(MachineName); + writer.WritePropertyName("StreamId"u8); + writer.WriteStringValue(StreamId); + if (Optional.IsDefined(Timestamp)) + { + writer.WritePropertyName("Timestamp"u8); + writer.WriteStringValue(Timestamp.Value, "O"); + } + if (Optional.IsDefined(TransmissionTime)) + { + writer.WritePropertyName("TransmissionTime"u8); + writer.WriteStringValue(TransmissionTime.Value, "O"); + } + writer.WritePropertyName("IsWebApp"u8); + writer.WriteBooleanValue(IsWebApp); + writer.WritePropertyName("PerformanceCollectionSupported"u8); + writer.WriteBooleanValue(PerformanceCollectionSupported); + if (Optional.IsCollectionDefined(Metrics)) + { + writer.WritePropertyName("Metrics"u8); + writer.WriteStartArray(); + foreach (var item in Metrics) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Documents)) + { + writer.WritePropertyName("Documents"u8); + writer.WriteStartArray(); + foreach (var item in Documents) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(TopCpuProcesses)) + { + writer.WritePropertyName("TopCpuProcesses"u8); + writer.WriteStartArray(); + foreach (var item in TopCpuProcesses) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(CollectionConfigurationErrors)) + { + writer.WritePropertyName("CollectionConfigurationErrors"u8); + writer.WriteStartArray(); + foreach (var item in CollectionConfigurationErrors) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + MonitoringDataPoint IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MonitoringDataPoint)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMonitoringDataPoint(document.RootElement, options); + } + + internal static MonitoringDataPoint DeserializeMonitoringDataPoint(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string version = default; + int invariantVersion = default; + string instance = default; + string roleName = default; + string machineName = default; + string streamId = default; + DateTimeOffset? timestamp = default; + DateTimeOffset? transmissionTime = default; + bool isWebApp = default; + bool performanceCollectionSupported = default; + IList metrics = default; + IList documents = default; + IList topCpuProcesses = default; + IList collectionConfigurationErrors = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("Version"u8)) + { + version = property.Value.GetString(); + continue; + } + if (property.NameEquals("InvariantVersion"u8)) + { + invariantVersion = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("Instance"u8)) + { + instance = property.Value.GetString(); + continue; + } + if (property.NameEquals("RoleName"u8)) + { + roleName = property.Value.GetString(); + continue; + } + if (property.NameEquals("MachineName"u8)) + { + machineName = property.Value.GetString(); + continue; + } + if (property.NameEquals("StreamId"u8)) + { + streamId = property.Value.GetString(); + continue; + } + if (property.NameEquals("Timestamp"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + timestamp = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("TransmissionTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + transmissionTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("IsWebApp"u8)) + { + isWebApp = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("PerformanceCollectionSupported"u8)) + { + performanceCollectionSupported = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("Metrics"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricPoint.DeserializeMetricPoint(item, options)); + } + metrics = array; + continue; + } + if (property.NameEquals("Documents"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(DocumentIngress.DeserializeDocumentIngress(item, options)); + } + documents = array; + continue; + } + if (property.NameEquals("TopCpuProcesses"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ProcessCpuData.DeserializeProcessCpuData(item, options)); + } + topCpuProcesses = array; + continue; + } + if (property.NameEquals("CollectionConfigurationErrors"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(CollectionConfigurationError.DeserializeCollectionConfigurationError(item, options)); + } + collectionConfigurationErrors = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MonitoringDataPoint( + version, + invariantVersion, + instance, + roleName, + machineName, + streamId, + timestamp, + transmissionTime, + isWebApp, + performanceCollectionSupported, + metrics ?? new ChangeTrackingList(), + documents ?? new ChangeTrackingList(), + topCpuProcesses ?? new ChangeTrackingList(), + collectionConfigurationErrors ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MonitoringDataPoint)} does not support writing '{options.Format}' format."); + } + } + + MonitoringDataPoint IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMonitoringDataPoint(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MonitoringDataPoint)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MonitoringDataPoint FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMonitoringDataPoint(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/MonitoringDataPoint.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/MonitoringDataPoint.cs new file mode 100644 index 000000000000..5198042c9af1 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/MonitoringDataPoint.cs @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace LiveMetrics +{ + /// Monitoring data point coming from the client, which includes metrics, documents and other metadata info. + public partial class MonitoringDataPoint + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Application Insights SDK version. + /// Version/generation of the data contract (MonitoringDataPoint) between SDK and Live Metrics. + /// Service instance name where Application Insights SDK lives. + /// Service role name. + /// Computer name where Application Insights SDK lives. + /// Identifies an Application Insights SDK as a trusted agent to report metrics and documents. + /// True if the current application is an Azure Web App. + /// True if performance counters collection is supported. + /// , , , or is null. + public MonitoringDataPoint(string version, int invariantVersion, string instance, string roleName, string machineName, string streamId, bool isWebApp, bool performanceCollectionSupported) + { + Argument.AssertNotNull(version, nameof(version)); + Argument.AssertNotNull(instance, nameof(instance)); + Argument.AssertNotNull(roleName, nameof(roleName)); + Argument.AssertNotNull(machineName, nameof(machineName)); + Argument.AssertNotNull(streamId, nameof(streamId)); + + Version = version; + InvariantVersion = invariantVersion; + Instance = instance; + RoleName = roleName; + MachineName = machineName; + StreamId = streamId; + IsWebApp = isWebApp; + PerformanceCollectionSupported = performanceCollectionSupported; + Metrics = new ChangeTrackingList(); + Documents = new ChangeTrackingList(); + TopCpuProcesses = new ChangeTrackingList(); + CollectionConfigurationErrors = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Application Insights SDK version. + /// Version/generation of the data contract (MonitoringDataPoint) between SDK and Live Metrics. + /// Service instance name where Application Insights SDK lives. + /// Service role name. + /// Computer name where Application Insights SDK lives. + /// Identifies an Application Insights SDK as a trusted agent to report metrics and documents. + /// Data point generation timestamp. + /// Timestamp when the client transmits the metrics and documents to Live Metrics. + /// True if the current application is an Azure Web App. + /// True if performance counters collection is supported. + /// An array of metric data points. + /// + /// An array of documents of a specific type {Request}, {RemoteDependency}, {Exception}, {Event}, or {Trace} + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + /// An array of top cpu consumption data point. + /// An array of error while SDK parses and applies the {CollectionConfigurationInfo} provided by Live Metrics. + /// Keeps track of any properties unknown to the library. + internal MonitoringDataPoint(string version, int invariantVersion, string instance, string roleName, string machineName, string streamId, DateTimeOffset? timestamp, DateTimeOffset? transmissionTime, bool isWebApp, bool performanceCollectionSupported, IList metrics, IList documents, IList topCpuProcesses, IList collectionConfigurationErrors, IDictionary serializedAdditionalRawData) + { + Version = version; + InvariantVersion = invariantVersion; + Instance = instance; + RoleName = roleName; + MachineName = machineName; + StreamId = streamId; + Timestamp = timestamp; + TransmissionTime = transmissionTime; + IsWebApp = isWebApp; + PerformanceCollectionSupported = performanceCollectionSupported; + Metrics = metrics; + Documents = documents; + TopCpuProcesses = topCpuProcesses; + CollectionConfigurationErrors = collectionConfigurationErrors; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MonitoringDataPoint() + { + } + + /// Application Insights SDK version. + public string Version { get; } + /// Version/generation of the data contract (MonitoringDataPoint) between SDK and Live Metrics. + public int InvariantVersion { get; } + /// Service instance name where Application Insights SDK lives. + public string Instance { get; } + /// Service role name. + public string RoleName { get; } + /// Computer name where Application Insights SDK lives. + public string MachineName { get; } + /// Identifies an Application Insights SDK as a trusted agent to report metrics and documents. + public string StreamId { get; } + /// Data point generation timestamp. + public DateTimeOffset? Timestamp { get; set; } + /// Timestamp when the client transmits the metrics and documents to Live Metrics. + public DateTimeOffset? TransmissionTime { get; set; } + /// True if the current application is an Azure Web App. + public bool IsWebApp { get; } + /// True if performance counters collection is supported. + public bool PerformanceCollectionSupported { get; } + /// An array of metric data points. + public IList Metrics { get; } + /// + /// An array of documents of a specific type {Request}, {RemoteDependency}, {Exception}, {Event}, or {Trace} + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , , , and . + /// + public IList Documents { get; } + /// An array of top cpu consumption data point. + public IList TopCpuProcesses { get; } + /// An array of error while SDK parses and applies the {CollectionConfigurationInfo} provided by Live Metrics. + public IList CollectionConfigurationErrors { get; } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/PredicateType.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/PredicateType.cs new file mode 100644 index 000000000000..5ce922651c42 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/PredicateType.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace LiveMetrics +{ + /// Enum representing the different types of predicates. + public readonly partial struct PredicateType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public PredicateType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string EqualValue = "Equal"; + private const string NotEqualValue = "NotEqual"; + private const string LessThanValue = "LessThan"; + private const string GreaterThanValue = "GreaterThan"; + private const string LessThanOrEqualValue = "LessThanOrEqual"; + private const string GreaterThanOrEqualValue = "GreaterThanOrEqual"; + private const string ContainsValue = "Contains"; + private const string DoesNotContainValue = "DoesNotContain"; + + /// Represents an equality predicate. + public static PredicateType Equal { get; } = new PredicateType(EqualValue); + /// Represents a not-equal predicate. + public static PredicateType NotEqual { get; } = new PredicateType(NotEqualValue); + /// Represents a less-than predicate. + public static PredicateType LessThan { get; } = new PredicateType(LessThanValue); + /// Represents a greater-than predicate. + public static PredicateType GreaterThan { get; } = new PredicateType(GreaterThanValue); + /// Represents a less-than-or-equal predicate. + public static PredicateType LessThanOrEqual { get; } = new PredicateType(LessThanOrEqualValue); + /// Represents a greater-than-or-equal predicate. + public static PredicateType GreaterThanOrEqual { get; } = new PredicateType(GreaterThanOrEqualValue); + /// Represents a contains predicate. + public static PredicateType Contains { get; } = new PredicateType(ContainsValue); + /// Represents a does-not-contain predicate. + public static PredicateType DoesNotContain { get; } = new PredicateType(DoesNotContainValue); + /// Determines if two values are the same. + public static bool operator ==(PredicateType left, PredicateType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(PredicateType left, PredicateType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator PredicateType(string value) => new PredicateType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is PredicateType other && Equals(other); + /// + public bool Equals(PredicateType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/ProcessCpuData.Serialization.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/ProcessCpuData.Serialization.cs new file mode 100644 index 000000000000..62a0419aad72 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/ProcessCpuData.Serialization.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace LiveMetrics +{ + public partial class ProcessCpuData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProcessCpuData)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("ProcessName"u8); + writer.WriteStringValue(ProcessName); + writer.WritePropertyName("CpuPercentage"u8); + writer.WriteNumberValue(CpuPercentage); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + ProcessCpuData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ProcessCpuData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeProcessCpuData(document.RootElement, options); + } + + internal static ProcessCpuData DeserializeProcessCpuData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string processName = default; + int cpuPercentage = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ProcessName"u8)) + { + processName = property.Value.GetString(); + continue; + } + if (property.NameEquals("CpuPercentage"u8)) + { + cpuPercentage = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ProcessCpuData(processName, cpuPercentage, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ProcessCpuData)} does not support writing '{options.Format}' format."); + } + } + + ProcessCpuData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeProcessCpuData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ProcessCpuData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ProcessCpuData FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeProcessCpuData(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/ProcessCpuData.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/ProcessCpuData.cs new file mode 100644 index 000000000000..c4f1d9457d5e --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/ProcessCpuData.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace LiveMetrics +{ + /// CPU consumption datapoint. + public partial class ProcessCpuData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Process name. + /// CPU consumption percentage. + /// is null. + public ProcessCpuData(string processName, int cpuPercentage) + { + Argument.AssertNotNull(processName, nameof(processName)); + + ProcessName = processName; + CpuPercentage = cpuPercentage; + } + + /// Initializes a new instance of . + /// Process name. + /// CPU consumption percentage. + /// Keeps track of any properties unknown to the library. + internal ProcessCpuData(string processName, int cpuPercentage, IDictionary serializedAdditionalRawData) + { + ProcessName = processName; + CpuPercentage = cpuPercentage; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ProcessCpuData() + { + } + + /// Process name. + public string ProcessName { get; } + /// CPU consumption percentage. + public int CpuPercentage { get; } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/QuotaConfigurationInfo.Serialization.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/QuotaConfigurationInfo.Serialization.cs new file mode 100644 index 000000000000..9dbaece79bf9 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/QuotaConfigurationInfo.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace LiveMetrics +{ + public partial class QuotaConfigurationInfo : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QuotaConfigurationInfo)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(InitialQuota)) + { + writer.WritePropertyName("InitialQuota"u8); + writer.WriteNumberValue(InitialQuota.Value); + } + writer.WritePropertyName("MaxQuota"u8); + writer.WriteNumberValue(MaxQuota); + writer.WritePropertyName("QuotaAccrualRatePerSec"u8); + writer.WriteNumberValue(QuotaAccrualRatePerSec); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + QuotaConfigurationInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(QuotaConfigurationInfo)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeQuotaConfigurationInfo(document.RootElement, options); + } + + internal static QuotaConfigurationInfo DeserializeQuotaConfigurationInfo(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + float? initialQuota = default; + float maxQuota = default; + float quotaAccrualRatePerSec = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("InitialQuota"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + initialQuota = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("MaxQuota"u8)) + { + maxQuota = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("QuotaAccrualRatePerSec"u8)) + { + quotaAccrualRatePerSec = property.Value.GetSingle(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new QuotaConfigurationInfo(initialQuota, maxQuota, quotaAccrualRatePerSec, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(QuotaConfigurationInfo)} does not support writing '{options.Format}' format."); + } + } + + QuotaConfigurationInfo IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeQuotaConfigurationInfo(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(QuotaConfigurationInfo)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static QuotaConfigurationInfo FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeQuotaConfigurationInfo(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/QuotaConfigurationInfo.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/QuotaConfigurationInfo.cs new file mode 100644 index 000000000000..3c09c73551fb --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/QuotaConfigurationInfo.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace LiveMetrics +{ + /// Controls document quotas to be sent to Live Metrics. + public partial class QuotaConfigurationInfo + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Max quota. + /// Quota accrual rate per second. + internal QuotaConfigurationInfo(float maxQuota, float quotaAccrualRatePerSec) + { + MaxQuota = maxQuota; + QuotaAccrualRatePerSec = quotaAccrualRatePerSec; + } + + /// Initializes a new instance of . + /// Initial quota. + /// Max quota. + /// Quota accrual rate per second. + /// Keeps track of any properties unknown to the library. + internal QuotaConfigurationInfo(float? initialQuota, float maxQuota, float quotaAccrualRatePerSec, IDictionary serializedAdditionalRawData) + { + InitialQuota = initialQuota; + MaxQuota = maxQuota; + QuotaAccrualRatePerSec = quotaAccrualRatePerSec; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal QuotaConfigurationInfo() + { + } + + /// Initial quota. + public float? InitialQuota { get; } + /// Max quota. + public float MaxQuota { get; } + /// Quota accrual rate per second. + public float QuotaAccrualRatePerSec { get; } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/RemoteDependency.Serialization.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/RemoteDependency.Serialization.cs new file mode 100644 index 000000000000..7f3d42e578fa --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/RemoteDependency.Serialization.cs @@ -0,0 +1,238 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace LiveMetrics +{ + public partial class RemoteDependency : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RemoteDependency)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("Name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(CommandName)) + { + writer.WritePropertyName("CommandName"u8); + writer.WriteStringValue(CommandName); + } + if (Optional.IsDefined(ResultCode)) + { + writer.WritePropertyName("ResultCode"u8); + writer.WriteStringValue(ResultCode); + } + if (Optional.IsDefined(Duration)) + { + writer.WritePropertyName("Duration"u8); + writer.WriteStringValue(Duration); + } + writer.WritePropertyName("DocumentType"u8); + writer.WriteStringValue(DocumentType.ToString()); + if (Optional.IsCollectionDefined(DocumentStreamIds)) + { + writer.WritePropertyName("DocumentStreamIds"u8); + writer.WriteStartArray(); + foreach (var item in DocumentStreamIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("Properties"u8); + writer.WriteStartArray(); + foreach (var item in Properties) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RemoteDependency IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RemoteDependency)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRemoteDependency(document.RootElement, options); + } + + internal static RemoteDependency DeserializeRemoteDependency(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string commandName = default; + string resultCode = default; + string duration = default; + DocumentType documentType = default; + IList documentStreamIds = default; + IList properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("Name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("CommandName"u8)) + { + commandName = property.Value.GetString(); + continue; + } + if (property.NameEquals("ResultCode"u8)) + { + resultCode = property.Value.GetString(); + continue; + } + if (property.NameEquals("Duration"u8)) + { + duration = property.Value.GetString(); + continue; + } + if (property.NameEquals("DocumentType"u8)) + { + documentType = new DocumentType(property.Value.GetString()); + continue; + } + if (property.NameEquals("DocumentStreamIds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + documentStreamIds = array; + continue; + } + if (property.NameEquals("Properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(KeyValuePairStringString.DeserializeKeyValuePairStringString(item, options)); + } + properties = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RemoteDependency( + documentType, + documentStreamIds ?? new ChangeTrackingList(), + properties ?? new ChangeTrackingList(), + serializedAdditionalRawData, + name, + commandName, + resultCode, + duration); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RemoteDependency)} does not support writing '{options.Format}' format."); + } + } + + RemoteDependency IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRemoteDependency(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RemoteDependency)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RemoteDependency FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRemoteDependency(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/RemoteDependency.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/RemoteDependency.cs new file mode 100644 index 000000000000..6cab0e3ad447 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/RemoteDependency.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace LiveMetrics +{ + /// RemoteDependency document type. + public partial class RemoteDependency : DocumentIngress + { + /// Initializes a new instance of . + public RemoteDependency() + { + DocumentType = DocumentType.RemoteDependency; + } + + /// Initializes a new instance of . + /// Telemetry type. Types not defined in enum will get replaced with a 'Unknown' type. + /// An array of document streaming ids. Each id identifies a flow of documents customized by UX customers. + /// Collection of custom properties. + /// Keeps track of any properties unknown to the library. + /// Name of the command initiated with this dependency call, e.g., GET /username. + /// URL of the dependency call to the target, with all query string parameters. + /// Result code of a dependency call. Examples are SQL error code and HTTP status code. + /// Request duration in ISO 8601 duration format, i.e., P[n]Y[n]M[n]DT[n]H[n]M[n]S or P[n]W. + internal RemoteDependency(DocumentType documentType, IList documentStreamIds, IList properties, IDictionary serializedAdditionalRawData, string name, string commandName, string resultCode, string duration) : base(documentType, documentStreamIds, properties, serializedAdditionalRawData) + { + Name = name; + CommandName = commandName; + ResultCode = resultCode; + Duration = duration; + } + + /// Name of the command initiated with this dependency call, e.g., GET /username. + public string Name { get; set; } + /// URL of the dependency call to the target, with all query string parameters. + public string CommandName { get; set; } + /// Result code of a dependency call. Examples are SQL error code and HTTP status code. + public string ResultCode { get; set; } + /// Request duration in ISO 8601 duration format, i.e., P[n]Y[n]M[n]DT[n]H[n]M[n]S or P[n]W. + public string Duration { get; set; } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Request.Serialization.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Request.Serialization.cs new file mode 100644 index 000000000000..ac09ba508b63 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Request.Serialization.cs @@ -0,0 +1,242 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace LiveMetrics +{ + public partial class Request : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Request)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("Name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Url)) + { + writer.WritePropertyName("Url"u8); + writer.WriteStringValue(Url.AbsoluteUri); + } + if (Optional.IsDefined(ResponseCode)) + { + writer.WritePropertyName("ResponseCode"u8); + writer.WriteStringValue(ResponseCode); + } + if (Optional.IsDefined(Duration)) + { + writer.WritePropertyName("Duration"u8); + writer.WriteStringValue(Duration); + } + writer.WritePropertyName("DocumentType"u8); + writer.WriteStringValue(DocumentType.ToString()); + if (Optional.IsCollectionDefined(DocumentStreamIds)) + { + writer.WritePropertyName("DocumentStreamIds"u8); + writer.WriteStartArray(); + foreach (var item in DocumentStreamIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("Properties"u8); + writer.WriteStartArray(); + foreach (var item in Properties) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + Request IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Request)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRequest(document.RootElement, options); + } + + internal static Request DeserializeRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + Uri url = default; + string responseCode = default; + string duration = default; + DocumentType documentType = default; + IList documentStreamIds = default; + IList properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("Name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("Url"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + url = new Uri(property.Value.GetString()); + continue; + } + if (property.NameEquals("ResponseCode"u8)) + { + responseCode = property.Value.GetString(); + continue; + } + if (property.NameEquals("Duration"u8)) + { + duration = property.Value.GetString(); + continue; + } + if (property.NameEquals("DocumentType"u8)) + { + documentType = new DocumentType(property.Value.GetString()); + continue; + } + if (property.NameEquals("DocumentStreamIds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + documentStreamIds = array; + continue; + } + if (property.NameEquals("Properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(KeyValuePairStringString.DeserializeKeyValuePairStringString(item, options)); + } + properties = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Request( + documentType, + documentStreamIds ?? new ChangeTrackingList(), + properties ?? new ChangeTrackingList(), + serializedAdditionalRawData, + name, + url, + responseCode, + duration); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Request)} does not support writing '{options.Format}' format."); + } + } + + Request IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Request)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new Request FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRequest(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Request.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Request.cs new file mode 100644 index 000000000000..98ccc03686b9 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Request.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace LiveMetrics +{ + /// Request document type. + public partial class Request : DocumentIngress + { + /// Initializes a new instance of . + public Request() + { + DocumentType = DocumentType.Request; + } + + /// Initializes a new instance of . + /// Telemetry type. Types not defined in enum will get replaced with a 'Unknown' type. + /// An array of document streaming ids. Each id identifies a flow of documents customized by UX customers. + /// Collection of custom properties. + /// Keeps track of any properties unknown to the library. + /// Name of the request, e.g., 'GET /values/{id}'. + /// Request URL with all query string parameters. + /// Result of a request execution. For http requests, it could be some HTTP status code. + /// Request duration in ISO 8601 duration format, i.e., P[n]Y[n]M[n]DT[n]H[n]M[n]S or P[n]W. + internal Request(DocumentType documentType, IList documentStreamIds, IList properties, IDictionary serializedAdditionalRawData, string name, Uri url, string responseCode, string duration) : base(documentType, documentStreamIds, properties, serializedAdditionalRawData) + { + Name = name; + Url = url; + ResponseCode = responseCode; + Duration = duration; + } + + /// Name of the request, e.g., 'GET /values/{id}'. + public string Name { get; set; } + /// Request URL with all query string parameters. + public Uri Url { get; set; } + /// Result of a request execution. For http requests, it could be some HTTP status code. + public string ResponseCode { get; set; } + /// Request duration in ISO 8601 duration format, i.e., P[n]Y[n]M[n]DT[n]H[n]M[n]S or P[n]W. + public string Duration { get; set; } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/TelemetryType.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/TelemetryType.cs new file mode 100644 index 000000000000..b5c423ff1982 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/TelemetryType.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace LiveMetrics +{ + /// Telemetry type. + public readonly partial struct TelemetryType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TelemetryType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string RequestValue = "Request"; + private const string DependencyValue = "Dependency"; + private const string ExceptionValue = "Exception"; + private const string EventValue = "Event"; + private const string MetricValue = "Metric"; + private const string PerformanceCounterValue = "PerformanceCounter"; + private const string TraceValue = "Trace"; + + /// Represents a request telemetry type. + public static TelemetryType Request { get; } = new TelemetryType(RequestValue); + /// Represents a dependency telemetry type. + public static TelemetryType Dependency { get; } = new TelemetryType(DependencyValue); + /// Represents an exception telemetry type. + public static TelemetryType Exception { get; } = new TelemetryType(ExceptionValue); + /// Represents an event telemetry type. + public static TelemetryType Event { get; } = new TelemetryType(EventValue); + /// Represents a metric telemetry type. + public static TelemetryType Metric { get; } = new TelemetryType(MetricValue); + /// Represents a performance counter telemetry type. + public static TelemetryType PerformanceCounter { get; } = new TelemetryType(PerformanceCounterValue); + /// Represents a trace telemetry type. + public static TelemetryType Trace { get; } = new TelemetryType(TraceValue); + /// Determines if two values are the same. + public static bool operator ==(TelemetryType left, TelemetryType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TelemetryType left, TelemetryType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator TelemetryType(string value) => new TelemetryType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TelemetryType other && Equals(other); + /// + public bool Equals(TelemetryType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Trace.Serialization.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Trace.Serialization.cs new file mode 100644 index 000000000000..a03b5793b57b --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Trace.Serialization.cs @@ -0,0 +1,197 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace LiveMetrics +{ + public partial class Trace : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Trace)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Message)) + { + writer.WritePropertyName("Message"u8); + writer.WriteStringValue(Message); + } + writer.WritePropertyName("DocumentType"u8); + writer.WriteStringValue(DocumentType.ToString()); + if (Optional.IsCollectionDefined(DocumentStreamIds)) + { + writer.WritePropertyName("DocumentStreamIds"u8); + writer.WriteStartArray(); + foreach (var item in DocumentStreamIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("Properties"u8); + writer.WriteStartArray(); + foreach (var item in Properties) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + Trace IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Trace)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTrace(document.RootElement, options); + } + + internal static Trace DeserializeTrace(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string message = default; + DocumentType documentType = default; + IList documentStreamIds = default; + IList properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("Message"u8)) + { + message = property.Value.GetString(); + continue; + } + if (property.NameEquals("DocumentType"u8)) + { + documentType = new DocumentType(property.Value.GetString()); + continue; + } + if (property.NameEquals("DocumentStreamIds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + documentStreamIds = array; + continue; + } + if (property.NameEquals("Properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(KeyValuePairStringString.DeserializeKeyValuePairStringString(item, options)); + } + properties = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Trace(documentType, documentStreamIds ?? new ChangeTrackingList(), properties ?? new ChangeTrackingList(), serializedAdditionalRawData, message); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Trace)} does not support writing '{options.Format}' format."); + } + } + + Trace IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTrace(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Trace)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new Trace FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTrace(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Trace.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Trace.cs new file mode 100644 index 000000000000..411e5ec67d06 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/Trace.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace LiveMetrics +{ + /// Trace document type. + public partial class Trace : DocumentIngress + { + /// Initializes a new instance of . + public Trace() + { + DocumentType = DocumentType.Trace; + } + + /// Initializes a new instance of . + /// Telemetry type. Types not defined in enum will get replaced with a 'Unknown' type. + /// An array of document streaming ids. Each id identifies a flow of documents customized by UX customers. + /// Collection of custom properties. + /// Keeps track of any properties unknown to the library. + /// Trace message. + internal Trace(DocumentType documentType, IList documentStreamIds, IList properties, IDictionary serializedAdditionalRawData, string message) : base(documentType, documentStreamIds, properties, serializedAdditionalRawData) + { + Message = message; + } + + /// Trace message. + public string Message { get; set; } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/UnknownDocumentIngress.Serialization.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/UnknownDocumentIngress.Serialization.cs new file mode 100644 index 000000000000..ff190b1e9b43 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/UnknownDocumentIngress.Serialization.cs @@ -0,0 +1,186 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure; +using Azure.Core; + +namespace LiveMetrics +{ + internal partial class UnknownDocumentIngress : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DocumentIngress)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("DocumentType"u8); + writer.WriteStringValue(DocumentType.ToString()); + if (Optional.IsCollectionDefined(DocumentStreamIds)) + { + writer.WritePropertyName("DocumentStreamIds"u8); + writer.WriteStartArray(); + foreach (var item in DocumentStreamIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("Properties"u8); + writer.WriteStartArray(); + foreach (var item in Properties) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + DocumentIngress IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DocumentIngress)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDocumentIngress(document.RootElement, options); + } + + internal static UnknownDocumentIngress DeserializeUnknownDocumentIngress(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DocumentType documentType = "AutoRest.CSharp.Output.Models.Types.EnumTypeValue"; + IList documentStreamIds = default; + IList properties = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("DocumentType"u8)) + { + documentType = new DocumentType(property.Value.GetString()); + continue; + } + if (property.NameEquals("DocumentStreamIds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + documentStreamIds = array; + continue; + } + if (property.NameEquals("Properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(KeyValuePairStringString.DeserializeKeyValuePairStringString(item, options)); + } + properties = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownDocumentIngress(documentType, documentStreamIds ?? new ChangeTrackingList(), properties ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(DocumentIngress)} does not support writing '{options.Format}' format."); + } + } + + DocumentIngress IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeDocumentIngress(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DocumentIngress)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownDocumentIngress FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUnknownDocumentIngress(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/UnknownDocumentIngress.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/UnknownDocumentIngress.cs new file mode 100644 index 000000000000..6212f92f2bc6 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Generated/UnknownDocumentIngress.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace LiveMetrics +{ + /// Unknown version of DocumentIngress. + internal partial class UnknownDocumentIngress : DocumentIngress + { + /// Initializes a new instance of . + /// Telemetry type. Types not defined in enum will get replaced with a 'Unknown' type. + /// An array of document streaming ids. Each id identifies a flow of documents customized by UX customers. + /// Collection of custom properties. + /// Keeps track of any properties unknown to the library. + internal UnknownDocumentIngress(DocumentType documentType, IList documentStreamIds, IList properties, IDictionary serializedAdditionalRawData) : base(documentType, documentStreamIds, properties, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownDocumentIngress() + { + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/LiveMetrics.csproj b/sdk/applicationinsights.livemetrics/LiveMetrics/src/LiveMetrics.csproj new file mode 100644 index 000000000000..17d89db02593 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/LiveMetrics.csproj @@ -0,0 +1,19 @@ + + + This is the LiveMetrics client library for developing .NET applications with rich experience. + Azure SDK Code Generation LiveMetrics for Azure Data Plane + 1.0.0-beta.1 + LiveMetrics + $(RequiredTargetFrameworks) + true + + + + + + + + + + + diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/src/Properties/AssemblyInfo.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..f3bafe56f482 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/src/Properties/AssemblyInfo.cs @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("LiveMetrics.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/tests/Generated/Samples/Samples_LiveMetricsClient.cs b/sdk/applicationinsights.livemetrics/LiveMetrics/tests/Generated/Samples/Samples_LiveMetricsClient.cs new file mode 100644 index 000000000000..3cdfddbf34f6 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/tests/Generated/Samples/Samples_LiveMetricsClient.cs @@ -0,0 +1,710 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace LiveMetrics.Samples +{ + public partial class Samples_LiveMetricsClient + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_LiveMetrics_IsSubscribed_ShortVersion() + { + TokenCredential credential = new DefaultAzureCredential(); + LiveMetricsClient client = new LiveMetricsClient(credential); + + using RequestContent content = null; + Response response = client.IsSubscribed("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("ETag").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Id").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("TelemetryType").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("FieldName").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Predicate").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Comparand").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Projection").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Aggregation").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("BackEndAggregation").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("Id").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("TelemetryType").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("FieldName").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Predicate").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Comparand").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_LiveMetrics_IsSubscribed_ShortVersion_Async() + { + TokenCredential credential = new DefaultAzureCredential(); + LiveMetricsClient client = new LiveMetricsClient(credential); + + using RequestContent content = null; + Response response = await client.IsSubscribedAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("ETag").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Id").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("TelemetryType").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("FieldName").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Predicate").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Comparand").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Projection").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Aggregation").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("BackEndAggregation").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("Id").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("TelemetryType").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("FieldName").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Predicate").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Comparand").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_LiveMetrics_IsSubscribed_ShortVersion_Convenience() + { + TokenCredential credential = new DefaultAzureCredential(); + LiveMetricsClient client = new LiveMetricsClient(credential); + + Response response = client.IsSubscribed(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_LiveMetrics_IsSubscribed_ShortVersion_Convenience_Async() + { + TokenCredential credential = new DefaultAzureCredential(); + LiveMetricsClient client = new LiveMetricsClient(credential); + + Response response = await client.IsSubscribedAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_LiveMetrics_IsSubscribed_AllParameters() + { + TokenCredential credential = new DefaultAzureCredential(); + LiveMetricsClient client = new LiveMetricsClient(credential); + + using RequestContent content = RequestContent.Create(new + { + Version = "", + InvariantVersion = 1234, + Instance = "", + RoleName = "", + MachineName = "", + StreamId = "", + Timestamp = "2022-05-10T18:57:31.2311892Z", + TransmissionTime = "2022-05-10T18:57:31.2311892Z", + IsWebApp = true, + PerformanceCollectionSupported = true, + Metrics = new object[] + { +new +{ +Name = "", +Value = 123.45, +Weight = 1234, +} + }, + Documents = new object[] + { +new +{ +DocumentType = "Request", +Name = "", +Url = "http://localhost:3000", +ResponseCode = "", +Duration = "", +DocumentStreamIds = new object[] +{ +"" +}, +Properties = new object[] +{ +new +{ +key = "", +value = "", +} +}, +} + }, + TopCpuProcesses = new object[] + { +new +{ +ProcessName = "", +CpuPercentage = 1234, +} + }, + CollectionConfigurationErrors = new object[] + { +new +{ +CollectionConfigurationErrorType = "Unknown", +Message = "", +FullException = "", +Data = new object[] +{ +null +}, +} + }, + }); + Response response = client.IsSubscribed("", content, transmissionTime: 1234L, machineName: "", instanceName: "", streamId: "", roleName: "", invariantVersion: "", configurationEtag: new ETag("")); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("ETag").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Id").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("TelemetryType").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("FieldName").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Predicate").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Comparand").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Projection").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Aggregation").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("BackEndAggregation").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("Id").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("TelemetryType").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("FieldName").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Predicate").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Comparand").ToString()); + Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("InitialQuota").ToString()); + Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("MaxQuota").ToString()); + Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("QuotaAccrualRatePerSec").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_LiveMetrics_IsSubscribed_AllParameters_Async() + { + TokenCredential credential = new DefaultAzureCredential(); + LiveMetricsClient client = new LiveMetricsClient(credential); + + using RequestContent content = RequestContent.Create(new + { + Version = "", + InvariantVersion = 1234, + Instance = "", + RoleName = "", + MachineName = "", + StreamId = "", + Timestamp = "2022-05-10T18:57:31.2311892Z", + TransmissionTime = "2022-05-10T18:57:31.2311892Z", + IsWebApp = true, + PerformanceCollectionSupported = true, + Metrics = new object[] + { +new +{ +Name = "", +Value = 123.45, +Weight = 1234, +} + }, + Documents = new object[] + { +new +{ +DocumentType = "Request", +Name = "", +Url = "http://localhost:3000", +ResponseCode = "", +Duration = "", +DocumentStreamIds = new object[] +{ +"" +}, +Properties = new object[] +{ +new +{ +key = "", +value = "", +} +}, +} + }, + TopCpuProcesses = new object[] + { +new +{ +ProcessName = "", +CpuPercentage = 1234, +} + }, + CollectionConfigurationErrors = new object[] + { +new +{ +CollectionConfigurationErrorType = "Unknown", +Message = "", +FullException = "", +Data = new object[] +{ +null +}, +} + }, + }); + Response response = await client.IsSubscribedAsync("", content, transmissionTime: 1234L, machineName: "", instanceName: "", streamId: "", roleName: "", invariantVersion: "", configurationEtag: new ETag("")); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("ETag").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Id").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("TelemetryType").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("FieldName").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Predicate").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Comparand").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Projection").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Aggregation").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("BackEndAggregation").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("Id").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("TelemetryType").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("FieldName").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Predicate").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Comparand").ToString()); + Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("InitialQuota").ToString()); + Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("MaxQuota").ToString()); + Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("QuotaAccrualRatePerSec").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_LiveMetrics_IsSubscribed_AllParameters_Convenience() + { + TokenCredential credential = new DefaultAzureCredential(); + LiveMetricsClient client = new LiveMetricsClient(credential); + + MonitoringDataPoint monitoringDataPoint = new MonitoringDataPoint( + "", + 1234, + "", + "", + "", + "", + true, + true) + { + Timestamp = DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"), + TransmissionTime = DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"), + Metrics = { new MetricPoint("", 123.45, 1234) }, + Documents = {new Request +{ +Name = "", +Url = new Uri("http://localhost:3000"), +ResponseCode = "", +Duration = "", +DocumentStreamIds = {""}, +Properties = {new KeyValuePairStringString("", "")}, +}}, + TopCpuProcesses = { new ProcessCpuData("", 1234) }, + CollectionConfigurationErrors = {new CollectionConfigurationError(CollectionConfigurationErrorType.Unknown, "", "", new KeyValuePairStringString[] +{ +default +})}, + }; + Response response = client.IsSubscribed("", monitoringDataPoint: monitoringDataPoint, transmissionTime: 1234L, machineName: "", instanceName: "", streamId: "", roleName: "", invariantVersion: "", configurationEtag: new ETag("")); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_LiveMetrics_IsSubscribed_AllParameters_Convenience_Async() + { + TokenCredential credential = new DefaultAzureCredential(); + LiveMetricsClient client = new LiveMetricsClient(credential); + + MonitoringDataPoint monitoringDataPoint = new MonitoringDataPoint( + "", + 1234, + "", + "", + "", + "", + true, + true) + { + Timestamp = DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"), + TransmissionTime = DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"), + Metrics = { new MetricPoint("", 123.45, 1234) }, + Documents = {new Request +{ +Name = "", +Url = new Uri("http://localhost:3000"), +ResponseCode = "", +Duration = "", +DocumentStreamIds = {""}, +Properties = {new KeyValuePairStringString("", "")}, +}}, + TopCpuProcesses = { new ProcessCpuData("", 1234) }, + CollectionConfigurationErrors = {new CollectionConfigurationError(CollectionConfigurationErrorType.Unknown, "", "", new KeyValuePairStringString[] +{ +default +})}, + }; + Response response = await client.IsSubscribedAsync("", monitoringDataPoint: monitoringDataPoint, transmissionTime: 1234L, machineName: "", instanceName: "", streamId: "", roleName: "", invariantVersion: "", configurationEtag: new ETag("")); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_LiveMetrics_Publish_ShortVersion() + { + TokenCredential credential = new DefaultAzureCredential(); + LiveMetricsClient client = new LiveMetricsClient(credential); + + using RequestContent content = null; + Response response = client.Publish("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("ETag").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Id").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("TelemetryType").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("FieldName").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Predicate").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Comparand").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Projection").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Aggregation").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("BackEndAggregation").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("Id").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("TelemetryType").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("FieldName").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Predicate").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Comparand").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_LiveMetrics_Publish_ShortVersion_Async() + { + TokenCredential credential = new DefaultAzureCredential(); + LiveMetricsClient client = new LiveMetricsClient(credential); + + using RequestContent content = null; + Response response = await client.PublishAsync("", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("ETag").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Id").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("TelemetryType").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("FieldName").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Predicate").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Comparand").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Projection").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Aggregation").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("BackEndAggregation").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("Id").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("TelemetryType").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("FieldName").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Predicate").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Comparand").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_LiveMetrics_Publish_ShortVersion_Convenience() + { + TokenCredential credential = new DefaultAzureCredential(); + LiveMetricsClient client = new LiveMetricsClient(credential); + + Response response = client.Publish(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_LiveMetrics_Publish_ShortVersion_Convenience_Async() + { + TokenCredential credential = new DefaultAzureCredential(); + LiveMetricsClient client = new LiveMetricsClient(credential); + + Response response = await client.PublishAsync(""); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_LiveMetrics_Publish_AllParameters() + { + TokenCredential credential = new DefaultAzureCredential(); + LiveMetricsClient client = new LiveMetricsClient(credential); + + using RequestContent content = RequestContent.Create(new object[] + { +new +{ +Version = "", +InvariantVersion = 1234, +Instance = "", +RoleName = "", +MachineName = "", +StreamId = "", +Timestamp = "2022-05-10T18:57:31.2311892Z", +TransmissionTime = "2022-05-10T18:57:31.2311892Z", +IsWebApp = true, +PerformanceCollectionSupported = true, +Metrics = new object[] +{ +new +{ +Name = "", +Value = 123.45, +Weight = 1234, +} +}, +Documents = new object[] +{ +new +{ +DocumentType = "Request", +Name = "", +Url = "http://localhost:3000", +ResponseCode = "", +Duration = "", +DocumentStreamIds = new object[] +{ +"" +}, +Properties = new object[] +{ +new +{ +key = "", +value = "", +} +}, +} +}, +TopCpuProcesses = new object[] +{ +new +{ +ProcessName = "", +CpuPercentage = 1234, +} +}, +CollectionConfigurationErrors = new object[] +{ +new +{ +CollectionConfigurationErrorType = "Unknown", +Message = "", +FullException = "", +Data = new object[] +{ +null +}, +} +}, +} + }); + Response response = client.Publish("", content, configurationEtag: new ETag(""), transmissionTime: 1234L); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("ETag").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Id").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("TelemetryType").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("FieldName").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Predicate").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Comparand").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Projection").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Aggregation").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("BackEndAggregation").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("Id").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("TelemetryType").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("FieldName").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Predicate").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Comparand").ToString()); + Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("InitialQuota").ToString()); + Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("MaxQuota").ToString()); + Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("QuotaAccrualRatePerSec").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_LiveMetrics_Publish_AllParameters_Async() + { + TokenCredential credential = new DefaultAzureCredential(); + LiveMetricsClient client = new LiveMetricsClient(credential); + + using RequestContent content = RequestContent.Create(new object[] + { +new +{ +Version = "", +InvariantVersion = 1234, +Instance = "", +RoleName = "", +MachineName = "", +StreamId = "", +Timestamp = "2022-05-10T18:57:31.2311892Z", +TransmissionTime = "2022-05-10T18:57:31.2311892Z", +IsWebApp = true, +PerformanceCollectionSupported = true, +Metrics = new object[] +{ +new +{ +Name = "", +Value = 123.45, +Weight = 1234, +} +}, +Documents = new object[] +{ +new +{ +DocumentType = "Request", +Name = "", +Url = "http://localhost:3000", +ResponseCode = "", +Duration = "", +DocumentStreamIds = new object[] +{ +"" +}, +Properties = new object[] +{ +new +{ +key = "", +value = "", +} +}, +} +}, +TopCpuProcesses = new object[] +{ +new +{ +ProcessName = "", +CpuPercentage = 1234, +} +}, +CollectionConfigurationErrors = new object[] +{ +new +{ +CollectionConfigurationErrorType = "Unknown", +Message = "", +FullException = "", +Data = new object[] +{ +null +}, +} +}, +} + }); + Response response = await client.PublishAsync("", content, configurationEtag: new ETag(""), transmissionTime: 1234L); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("ETag").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Id").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("TelemetryType").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("FieldName").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Predicate").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("FilterGroups")[0].GetProperty("Filters")[0].GetProperty("Comparand").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Projection").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("Aggregation").ToString()); + Console.WriteLine(result.GetProperty("Metrics")[0].GetProperty("BackEndAggregation").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("Id").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("TelemetryType").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("FieldName").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Predicate").ToString()); + Console.WriteLine(result.GetProperty("DocumentStreams")[0].GetProperty("DocumentFilterGroups")[0].GetProperty("Filters").GetProperty("Filters")[0].GetProperty("Comparand").ToString()); + Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("InitialQuota").ToString()); + Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("MaxQuota").ToString()); + Console.WriteLine(result.GetProperty("QuotaInfo").GetProperty("QuotaAccrualRatePerSec").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_LiveMetrics_Publish_AllParameters_Convenience() + { + TokenCredential credential = new DefaultAzureCredential(); + LiveMetricsClient client = new LiveMetricsClient(credential); + + Response response = client.Publish("", monitoringDataPoints: new MonitoringDataPoint[] + { +new MonitoringDataPoint( + "", + 1234, + "", + "", + "", + "", + true, + true) +{ +Timestamp = DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"), +TransmissionTime = DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"), +Metrics = {new MetricPoint("", 123.45, 1234)}, +Documents = {new Request +{ +Name = "", +Url = new Uri("http://localhost:3000"), +ResponseCode = "", +Duration = "", +DocumentStreamIds = {""}, +Properties = {new KeyValuePairStringString("", "")}, +}}, +TopCpuProcesses = {new ProcessCpuData("", 1234)}, +CollectionConfigurationErrors = {new CollectionConfigurationError(CollectionConfigurationErrorType.Unknown, "", "", new KeyValuePairStringString[] +{ +default +})}, +} + }, configurationEtag: new ETag(""), transmissionTime: 1234L); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_LiveMetrics_Publish_AllParameters_Convenience_Async() + { + TokenCredential credential = new DefaultAzureCredential(); + LiveMetricsClient client = new LiveMetricsClient(credential); + + Response response = await client.PublishAsync("", monitoringDataPoints: new MonitoringDataPoint[] + { +new MonitoringDataPoint( + "", + 1234, + "", + "", + "", + "", + true, + true) +{ +Timestamp = DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"), +TransmissionTime = DateTimeOffset.Parse("2022-05-10T18:57:31.2311892Z"), +Metrics = {new MetricPoint("", 123.45, 1234)}, +Documents = {new Request +{ +Name = "", +Url = new Uri("http://localhost:3000"), +ResponseCode = "", +Duration = "", +DocumentStreamIds = {""}, +Properties = {new KeyValuePairStringString("", "")}, +}}, +TopCpuProcesses = {new ProcessCpuData("", 1234)}, +CollectionConfigurationErrors = {new CollectionConfigurationError(CollectionConfigurationErrorType.Unknown, "", "", new KeyValuePairStringString[] +{ +default +})}, +} + }, configurationEtag: new ETag(""), transmissionTime: 1234L); + } + } +} diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/tests/LiveMetrics.Tests.csproj b/sdk/applicationinsights.livemetrics/LiveMetrics/tests/LiveMetrics.Tests.csproj new file mode 100644 index 000000000000..56fe204affe9 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/tests/LiveMetrics.Tests.csproj @@ -0,0 +1,19 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + + + + + + + + + + + + + diff --git a/sdk/applicationinsights.livemetrics/LiveMetrics/tsp-location.yaml b/sdk/applicationinsights.livemetrics/LiveMetrics/tsp-location.yaml new file mode 100644 index 000000000000..38f1c87b29e0 --- /dev/null +++ b/sdk/applicationinsights.livemetrics/LiveMetrics/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/applicationinsights/ApplicationInsights.LiveMetrics +commit: abdd04c316cd2e71dc4819b4e78eaceb50bae76c +repo: test-repo-billy/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/tsp-location.yaml b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/tsp-location.yaml index b5e602272d0c..b6d505134f54 100644 --- a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/tsp-location.yaml +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/tsp-location.yaml @@ -1,3 +1,4 @@ directory: specification/azurefleet/AzureFleet.Management -commit: c0a15f4623eb11f745f890089f3d46d8a538524f -repo: Azure/azure-rest-api-specs \ No newline at end of file +commit: abdd04c316cd2e71dc4819b4e78eaceb50bae76c +repo: test-repo-billy/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ApiResponseFormat.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ApiResponseFormat.cs new file mode 100644 index 000000000000..8d9eb75c8b73 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ApiResponseFormat.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Possible API response formats. + public readonly partial struct ApiResponseFormat : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ApiResponseFormat(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string TextValue = "text"; + private const string JsonObjectValue = "json_object"; + + /// `text` format should be used for requests involving any sort of ToolCall. + public static ApiResponseFormat Text { get; } = new ApiResponseFormat(TextValue); + /// Using `json_object` format will limit the usage of ToolCall to only functions. + public static ApiResponseFormat JsonObject { get; } = new ApiResponseFormat(JsonObjectValue); + /// Determines if two values are the same. + public static bool operator ==(ApiResponseFormat left, ApiResponseFormat right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ApiResponseFormat left, ApiResponseFormat right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ApiResponseFormat(string value) => new ApiResponseFormat(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ApiResponseFormat other && Equals(other); + /// + public bool Equals(ApiResponseFormat other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.Serialization.cs index 7f7c124b0054..de33b338f1ec 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.Serialization.cs @@ -68,13 +68,52 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions writer.WriteObjectValue(item, options); } writer.WriteEndArray(); - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) + if (ToolResources != null) { - writer.WriteStringValue(item); + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); + } + else + { + writer.WriteNull("tool_resources"); + } + if (Temperature != null) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + else + { + writer.WriteNull("temperature"); + } + if (TopP != null) + { + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(TopP.Value); + } + else + { + writer.WriteNull("top_p"); + } + if (Optional.IsDefined(ResponseFormat)) + { + if (ResponseFormat != null) + { + writer.WritePropertyName("response_format"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ResponseFormat); +#else + using (JsonDocument document = JsonDocument.Parse(ResponseFormat)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else + { + writer.WriteNull("response_format"); + } } - writer.WriteEndArray(); if (Metadata != null && Optional.IsCollectionDefined(Metadata)) { writer.WritePropertyName("metadata"u8); @@ -136,7 +175,10 @@ internal static Assistant DeserializeAssistant(JsonElement element, ModelReaderW string model = default; string instructions = default; IReadOnlyList tools = default; - IReadOnlyList fileIds = default; + ToolResources toolResources = default; + float? temperature = default; + float? topP = default; + BinaryData responseFormat = default; IReadOnlyDictionary metadata = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); @@ -202,14 +244,44 @@ internal static Assistant DeserializeAssistant(JsonElement element, ModelReaderW tools = array; continue; } - if (property.NameEquals("file_ids"u8)) + if (property.NameEquals("tool_resources"u8)) { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + if (property.Value.ValueKind == JsonValueKind.Null) { - array.Add(item.GetString()); + toolResources = null; + continue; + } + toolResources = ToolResources.DeserializeToolResources(property.Value, options); + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + temperature = null; + continue; + } + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("top_p"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + topP = null; + continue; + } + topP = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + responseFormat = null; + continue; } - fileIds = array; + responseFormat = BinaryData.FromString(property.Value.GetRawText()); continue; } if (property.NameEquals("metadata"u8)) @@ -242,7 +314,10 @@ internal static Assistant DeserializeAssistant(JsonElement element, ModelReaderW model, instructions, tools, - fileIds, + toolResources, + temperature, + topP, + responseFormat, metadata, serializedAdditionalRawData); } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.cs index 34402e5480d9..09b938b95c0e 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/Assistant.cs @@ -56,17 +56,29 @@ public partial class Assistant /// /// The collection of tools enabled for the assistant. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . + /// + /// + /// A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` + /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + /// + /// + /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, + /// while lower values like 0.2 will make it more focused and deterministic. + /// + /// + /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. + /// So 0.1 means only the tokens comprising the top 10% probability mass are considered. + /// + /// We generally recommend altering this or temperature but not both. /// - /// A list of attached file IDs, ordered by creation date in ascending order. /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// , , or is null. - internal Assistant(string id, DateTimeOffset createdAt, string name, string description, string model, string instructions, IEnumerable tools, IEnumerable fileIds, IReadOnlyDictionary metadata) + /// , or is null. + internal Assistant(string id, DateTimeOffset createdAt, string name, string description, string model, string instructions, IEnumerable tools, ToolResources toolResources, float? temperature, float? topP, IReadOnlyDictionary metadata) { Argument.AssertNotNull(id, nameof(id)); Argument.AssertNotNull(model, nameof(model)); Argument.AssertNotNull(tools, nameof(tools)); - Argument.AssertNotNull(fileIds, nameof(fileIds)); Id = id; CreatedAt = createdAt; @@ -75,7 +87,9 @@ internal Assistant(string id, DateTimeOffset createdAt, string name, string desc Model = model; Instructions = instructions; Tools = tools.ToList(); - FileIds = fileIds.ToList(); + ToolResources = toolResources; + Temperature = temperature; + TopP = topP; Metadata = metadata; } @@ -90,12 +104,26 @@ internal Assistant(string id, DateTimeOffset createdAt, string name, string desc /// /// The collection of tools enabled for the assistant. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . + /// + /// + /// A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` + /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + /// + /// + /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, + /// while lower values like 0.2 will make it more focused and deterministic. + /// + /// + /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. + /// So 0.1 means only the tokens comprising the top 10% probability mass are considered. + /// + /// We generally recommend altering this or temperature but not both. /// - /// A list of attached file IDs, ordered by creation date in ascending order. + /// The response format of the tool calls used by this assistant. /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// Keeps track of any properties unknown to the library. - internal Assistant(string id, string @object, DateTimeOffset createdAt, string name, string description, string model, string instructions, IReadOnlyList tools, IReadOnlyList fileIds, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + internal Assistant(string id, string @object, DateTimeOffset createdAt, string name, string description, string model, string instructions, IReadOnlyList tools, ToolResources toolResources, float? temperature, float? topP, BinaryData responseFormat, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) { Id = id; Object = @object; @@ -105,7 +133,10 @@ internal Assistant(string id, string @object, DateTimeOffset createdAt, string n Model = model; Instructions = instructions; Tools = tools; - FileIds = fileIds; + ToolResources = toolResources; + Temperature = temperature; + TopP = topP; + ResponseFormat = responseFormat; Metadata = metadata; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -131,11 +162,71 @@ internal Assistant() /// /// The collection of tools enabled for the assistant. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . /// public IReadOnlyList Tools { get; } - /// A list of attached file IDs, ordered by creation date in ascending order. - public IReadOnlyList FileIds { get; } + /// + /// A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` + /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + /// + public ToolResources ToolResources { get; } + /// + /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, + /// while lower values like 0.2 will make it more focused and deterministic. + /// + public float? Temperature { get; } + /// + /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. + /// So 0.1 means only the tokens comprising the top 10% probability mass are considered. + /// + /// We generally recommend altering this or temperature but not both. + /// + public float? TopP { get; } + /// + /// The response format of the tool calls used by this assistant. + /// + /// To assign an object to this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// + /// Supported types: + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData ResponseFormat { get; } /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. public IReadOnlyDictionary Metadata { get; } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.Serialization.cs index 28455a04d327..c906e565aced 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.Serialization.cs @@ -74,15 +74,60 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead } writer.WriteEndArray(); } - if (Optional.IsCollectionDefined(FileIds)) + if (Optional.IsDefined(ToolResources)) { - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) + if (ToolResources != null) { - writer.WriteStringValue(item); + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); + } + else + { + writer.WriteNull("tool_resources"); + } + } + if (Optional.IsDefined(Temperature)) + { + if (Temperature != null) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + else + { + writer.WriteNull("temperature"); + } + } + if (Optional.IsDefined(TopP)) + { + if (TopP != null) + { + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(TopP.Value); + } + else + { + writer.WriteNull("top_p"); + } + } + if (Optional.IsDefined(ResponseFormat)) + { + if (ResponseFormat != null) + { + writer.WritePropertyName("response_format"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ResponseFormat); +#else + using (JsonDocument document = JsonDocument.Parse(ResponseFormat)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else + { + writer.WriteNull("response_format"); } - writer.WriteEndArray(); } if (Optional.IsCollectionDefined(Metadata)) { @@ -145,7 +190,10 @@ internal static AssistantCreationOptions DeserializeAssistantCreationOptions(Jso string description = default; string instructions = default; IList tools = default; - IList fileIds = default; + CreateToolResourcesOptions toolResources = default; + float? temperature = default; + float? topP = default; + BinaryData responseFormat = default; IDictionary metadata = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); @@ -200,18 +248,44 @@ internal static AssistantCreationOptions DeserializeAssistantCreationOptions(Jso tools = array; continue; } - if (property.NameEquals("file_ids"u8)) + if (property.NameEquals("tool_resources"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { + toolResources = null; continue; } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + toolResources = CreateToolResourcesOptions.DeserializeCreateToolResourcesOptions(property.Value, options); + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + temperature = null; + continue; + } + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("top_p"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - array.Add(item.GetString()); + topP = null; + continue; + } + topP = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + responseFormat = null; + continue; } - fileIds = array; + responseFormat = BinaryData.FromString(property.Value.GetRawText()); continue; } if (property.NameEquals("metadata"u8)) @@ -240,7 +314,10 @@ internal static AssistantCreationOptions DeserializeAssistantCreationOptions(Jso description, instructions, tools ?? new ChangeTrackingList(), - fileIds ?? new ChangeTrackingList(), + toolResources, + temperature, + topP, + responseFormat, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.cs index 34372f563399..87275c6b0976 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantCreationOptions.cs @@ -54,7 +54,6 @@ public AssistantCreationOptions(string model) Model = model; Tools = new ChangeTrackingList(); - FileIds = new ChangeTrackingList(); Metadata = new ChangeTrackingDictionary(); } @@ -66,19 +65,36 @@ public AssistantCreationOptions(string model) /// /// The collection of tools to enable for the new assistant. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . /// - /// A list of previously uploaded file IDs to attach to the assistant. + /// + /// A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` + /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + /// + /// + /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, + /// while lower values like 0.2 will make it more focused and deterministic. + /// + /// + /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. + /// So 0.1 means only the tokens comprising the top 10% probability mass are considered. + /// + /// We generally recommend altering this or temperature but not both. + /// + /// The response format of the tool calls used by this assistant. /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// Keeps track of any properties unknown to the library. - internal AssistantCreationOptions(string model, string name, string description, string instructions, IList tools, IList fileIds, IDictionary metadata, IDictionary serializedAdditionalRawData) + internal AssistantCreationOptions(string model, string name, string description, string instructions, IList tools, CreateToolResourcesOptions toolResources, float? temperature, float? topP, BinaryData responseFormat, IDictionary metadata, IDictionary serializedAdditionalRawData) { Model = model; Name = name; Description = description; Instructions = instructions; Tools = tools; - FileIds = fileIds; + ToolResources = toolResources; + Temperature = temperature; + TopP = topP; + ResponseFormat = responseFormat; Metadata = metadata; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -99,11 +115,71 @@ internal AssistantCreationOptions() /// /// The collection of tools to enable for the new assistant. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . /// public IList Tools { get; } - /// A list of previously uploaded file IDs to attach to the assistant. - public IList FileIds { get; } + /// + /// A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` + /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + /// + public CreateToolResourcesOptions ToolResources { get; set; } + /// + /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, + /// while lower values like 0.2 will make it more focused and deterministic. + /// + public float? Temperature { get; set; } + /// + /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. + /// So 0.1 means only the tokens comprising the top 10% probability mass are considered. + /// + /// We generally recommend altering this or temperature but not both. + /// + public float? TopP { get; set; } + /// + /// The response format of the tool calls used by this assistant. + /// + /// To assign an object to this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// + /// Supported types: + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData ResponseFormat { get; set; } /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. public IDictionary Metadata { get; set; } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantStreamEvent.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantStreamEvent.cs new file mode 100644 index 000000000000..6c8ddaee9b65 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantStreamEvent.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// + /// Each event in a server-sent events stream has an `event` and `data` property: + /// + /// ``` + /// event: thread.created + /// data: {"id": "thread_123", "object": "thread", ...} + /// ``` + /// + /// We emit events whenever a new object is created, transitions to a new state, or is being + /// streamed in parts (deltas). For example, we emit `thread.run.created` when a new run + /// is created, `thread.run.completed` when a run completes, and so on. When an Assistant chooses + /// to create a message during a run, we emit a `thread.message.created event`, a + /// `thread.message.in_progress` event, many `thread.message.delta` events, and finally a + /// `thread.message.completed` event. + /// + /// We may add additional events over time, so we recommend handling unknown events gracefully + /// in your code. + /// + public readonly partial struct AssistantStreamEvent : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AssistantStreamEvent(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadCreatedValue = "thread.created"; + private const string ThreadRunCreatedValue = "thread.run.created"; + private const string ThreadRunQueuedValue = "thread.run.queued"; + private const string ThreadRunInProgressValue = "thread.run.in_progress"; + private const string ThreadRunRequiresActionValue = "thread.run.requires_action"; + private const string ThreadRunCompletedValue = "thread.run.completed"; + private const string ThreadRunFailedValue = "thread.run.failed"; + private const string ThreadRunCancellingValue = "thread.run.cancelling"; + private const string ThreadRunCancelledValue = "thread.run.cancelled"; + private const string ThreadRunExpiredValue = "thread.run.expired"; + private const string ThreadRunStepCreatedValue = "thread.run.step.created"; + private const string ThreadRunStepInProgressValue = "thread.run.step.in_progress"; + private const string ThreadRunStepDeltaValue = "thread.run.step.delta"; + private const string ThreadRunStepCompletedValue = "thread.run.step.completed"; + private const string ThreadRunStepFailedValue = "thread.run.step.failed"; + private const string ThreadRunStepCancelledValue = "thread.run.step.cancelled"; + private const string ThreadRunStepExpiredValue = "thread.run.step.expired"; + private const string ThreadMessageCreatedValue = "thread.message.created"; + private const string ThreadMessageInProgressValue = "thread.message.in_progress"; + private const string ThreadMessageDeltaValue = "thread.message.delta"; + private const string ThreadMessageCompletedValue = "thread.message.completed"; + private const string ThreadMessageIncompleteValue = "thread.message.incomplete"; + private const string ErrorValue = "error"; + private const string DoneValue = "done"; + + /// Event sent when a new thread is created. The data of this event is of type AssistantThread. + public static AssistantStreamEvent ThreadCreated { get; } = new AssistantStreamEvent(ThreadCreatedValue); + /// Event sent when a new run is created. The data of this event is of type ThreadRun. + public static AssistantStreamEvent ThreadRunCreated { get; } = new AssistantStreamEvent(ThreadRunCreatedValue); + /// Event sent when a run moves to `queued` status. The data of this event is of type ThreadRun. + public static AssistantStreamEvent ThreadRunQueued { get; } = new AssistantStreamEvent(ThreadRunQueuedValue); + /// Event sent when a run moves to `in_progress` status. The data of this event is of type ThreadRun. + public static AssistantStreamEvent ThreadRunInProgress { get; } = new AssistantStreamEvent(ThreadRunInProgressValue); + /// Event sent when a run moves to `requires_action` status. The data of this event is of type ThreadRun. + public static AssistantStreamEvent ThreadRunRequiresAction { get; } = new AssistantStreamEvent(ThreadRunRequiresActionValue); + /// Event sent when a run is completed. The data of this event is of type ThreadRun. + public static AssistantStreamEvent ThreadRunCompleted { get; } = new AssistantStreamEvent(ThreadRunCompletedValue); + /// Event sent when a run fails. The data of this event is of type ThreadRun. + public static AssistantStreamEvent ThreadRunFailed { get; } = new AssistantStreamEvent(ThreadRunFailedValue); + /// Event sent when a run moves to `cancelling` status. The data of this event is of type ThreadRun. + public static AssistantStreamEvent ThreadRunCancelling { get; } = new AssistantStreamEvent(ThreadRunCancellingValue); + /// Event sent when a run is cancelled. The data of this event is of type ThreadRun. + public static AssistantStreamEvent ThreadRunCancelled { get; } = new AssistantStreamEvent(ThreadRunCancelledValue); + /// Event sent when a run is expired. The data of this event is of type ThreadRun. + public static AssistantStreamEvent ThreadRunExpired { get; } = new AssistantStreamEvent(ThreadRunExpiredValue); + /// Event sent when a new thread run step is created. The data of this event is of type RunStep. + public static AssistantStreamEvent ThreadRunStepCreated { get; } = new AssistantStreamEvent(ThreadRunStepCreatedValue); + /// Event sent when a run step moves to `in_progress` status. The data of this event is of type RunStep. + public static AssistantStreamEvent ThreadRunStepInProgress { get; } = new AssistantStreamEvent(ThreadRunStepInProgressValue); + /// Event sent when a run stepis being streamed. The data of this event is of type RunStepDeltaChunk. + public static AssistantStreamEvent ThreadRunStepDelta { get; } = new AssistantStreamEvent(ThreadRunStepDeltaValue); + /// Event sent when a run step is completed. The data of this event is of type RunStep. + public static AssistantStreamEvent ThreadRunStepCompleted { get; } = new AssistantStreamEvent(ThreadRunStepCompletedValue); + /// Event sent when a run step fails. The data of this event is of type RunStep. + public static AssistantStreamEvent ThreadRunStepFailed { get; } = new AssistantStreamEvent(ThreadRunStepFailedValue); + /// Event sent when a run step is cancelled. The data of this event is of type RunStep. + public static AssistantStreamEvent ThreadRunStepCancelled { get; } = new AssistantStreamEvent(ThreadRunStepCancelledValue); + /// Event sent when a run step is expired. The data of this event is of type RunStep. + public static AssistantStreamEvent ThreadRunStepExpired { get; } = new AssistantStreamEvent(ThreadRunStepExpiredValue); + /// Event sent when a new message is created. The data of this event is of type ThreadMessage. + public static AssistantStreamEvent ThreadMessageCreated { get; } = new AssistantStreamEvent(ThreadMessageCreatedValue); + /// Event sent when a message moves to `in_progress` status. The data of this event is of type ThreadMessage. + public static AssistantStreamEvent ThreadMessageInProgress { get; } = new AssistantStreamEvent(ThreadMessageInProgressValue); + /// Event sent when a message is being streamed. The data of this event is of type MessageDeltaChunk. + public static AssistantStreamEvent ThreadMessageDelta { get; } = new AssistantStreamEvent(ThreadMessageDeltaValue); + /// Event sent when a message is completed. The data of this event is of type ThreadMessage. + public static AssistantStreamEvent ThreadMessageCompleted { get; } = new AssistantStreamEvent(ThreadMessageCompletedValue); + /// Event sent before a message is completed. The data of this event is of type ThreadMessage. + public static AssistantStreamEvent ThreadMessageIncomplete { get; } = new AssistantStreamEvent(ThreadMessageIncompleteValue); + /// Event sent when an error occurs, such as an internal server error or a timeout. + public static AssistantStreamEvent Error { get; } = new AssistantStreamEvent(ErrorValue); + /// Event sent when the stream is done. + public static AssistantStreamEvent Done { get; } = new AssistantStreamEvent(DoneValue); + /// Determines if two values are the same. + public static bool operator ==(AssistantStreamEvent left, AssistantStreamEvent right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AssistantStreamEvent left, AssistantStreamEvent right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator AssistantStreamEvent(string value) => new AssistantStreamEvent(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AssistantStreamEvent other && Equals(other); + /// + public bool Equals(AssistantStreamEvent other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.Serialization.cs index 72793c7f2950..550ab46b2be4 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.Serialization.cs @@ -32,6 +32,15 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO writer.WriteStringValue(Object); writer.WritePropertyName("created_at"u8); writer.WriteNumberValue(CreatedAt, "U"); + if (ToolResources != null) + { + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); + } + else + { + writer.WriteNull("tool_resources"); + } if (Metadata != null && Optional.IsCollectionDefined(Metadata)) { writer.WritePropertyName("metadata"u8); @@ -88,6 +97,7 @@ internal static AssistantThread DeserializeAssistantThread(JsonElement element, string id = default; string @object = default; DateTimeOffset createdAt = default; + ToolResources toolResources = default; IReadOnlyDictionary metadata = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); @@ -108,6 +118,16 @@ internal static AssistantThread DeserializeAssistantThread(JsonElement element, createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); continue; } + if (property.NameEquals("tool_resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + toolResources = null; + continue; + } + toolResources = ToolResources.DeserializeToolResources(property.Value, options); + continue; + } if (property.NameEquals("metadata"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -129,7 +149,13 @@ internal static AssistantThread DeserializeAssistantThread(JsonElement element, } } serializedAdditionalRawData = rawDataDictionary; - return new AssistantThread(id, @object, createdAt, metadata, serializedAdditionalRawData); + return new AssistantThread( + id, + @object, + createdAt, + toolResources, + metadata, + serializedAdditionalRawData); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.cs index 55fb2ac9a88e..11820b0ed0b6 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThread.cs @@ -48,14 +48,20 @@ public partial class AssistantThread /// Initializes a new instance of . /// The identifier, which can be referenced in API endpoints. /// The Unix timestamp, in seconds, representing when this object was created. + /// + /// A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type + /// of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list + /// of vector store IDs. + /// /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// is null. - internal AssistantThread(string id, DateTimeOffset createdAt, IReadOnlyDictionary metadata) + internal AssistantThread(string id, DateTimeOffset createdAt, ToolResources toolResources, IReadOnlyDictionary metadata) { Argument.AssertNotNull(id, nameof(id)); Id = id; CreatedAt = createdAt; + ToolResources = toolResources; Metadata = metadata; } @@ -63,13 +69,19 @@ internal AssistantThread(string id, DateTimeOffset createdAt, IReadOnlyDictionar /// The identifier, which can be referenced in API endpoints. /// The object type, which is always 'thread'. /// The Unix timestamp, in seconds, representing when this object was created. + /// + /// A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type + /// of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list + /// of vector store IDs. + /// /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// Keeps track of any properties unknown to the library. - internal AssistantThread(string id, string @object, DateTimeOffset createdAt, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + internal AssistantThread(string id, string @object, DateTimeOffset createdAt, ToolResources toolResources, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) { Id = id; Object = @object; CreatedAt = createdAt; + ToolResources = toolResources; Metadata = metadata; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -84,6 +96,12 @@ internal AssistantThread() /// The Unix timestamp, in seconds, representing when this object was created. public DateTimeOffset CreatedAt { get; } + /// + /// A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the type + /// of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list + /// of vector store IDs. + /// + public ToolResources ToolResources { get; } /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. public IReadOnlyDictionary Metadata { get; } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.Serialization.cs index ffd998161e30..873de1490d7f 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.Serialization.cs @@ -36,6 +36,18 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mod } writer.WriteEndArray(); } + if (Optional.IsDefined(ToolResources)) + { + if (ToolResources != null) + { + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); + } + else + { + writer.WriteNull("tool_resources"); + } + } if (Optional.IsCollectionDefined(Metadata)) { if (Metadata != null) @@ -92,7 +104,8 @@ internal static AssistantThreadCreationOptions DeserializeAssistantThreadCreatio { return null; } - IList messages = default; + IList messages = default; + CreateToolResourcesOptions toolResources = default; IDictionary metadata = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); @@ -104,14 +117,24 @@ internal static AssistantThreadCreationOptions DeserializeAssistantThreadCreatio { continue; } - List array = new List(); + List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(ThreadInitializationMessage.DeserializeThreadInitializationMessage(item, options)); + array.Add(ThreadMessageOptions.DeserializeThreadMessageOptions(item, options)); } messages = array; continue; } + if (property.NameEquals("tool_resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + toolResources = null; + continue; + } + toolResources = CreateToolResourcesOptions.DeserializeCreateToolResourcesOptions(property.Value, options); + continue; + } if (property.NameEquals("metadata"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -132,7 +155,7 @@ internal static AssistantThreadCreationOptions DeserializeAssistantThreadCreatio } } serializedAdditionalRawData = rawDataDictionary; - return new AssistantThreadCreationOptions(messages ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + return new AssistantThreadCreationOptions(messages ?? new ChangeTrackingList(), toolResources, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.cs index 2df216a2c7e8..086af4d9dc8a 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantThreadCreationOptions.cs @@ -48,23 +48,35 @@ public partial class AssistantThreadCreationOptions /// Initializes a new instance of . public AssistantThreadCreationOptions() { - Messages = new ChangeTrackingList(); + Messages = new ChangeTrackingList(); Metadata = new ChangeTrackingDictionary(); } /// Initializes a new instance of . /// The initial messages to associate with the new thread. + /// + /// A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the + /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires + /// a list of vector store IDs. + /// /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// Keeps track of any properties unknown to the library. - internal AssistantThreadCreationOptions(IList messages, IDictionary metadata, IDictionary serializedAdditionalRawData) + internal AssistantThreadCreationOptions(IList messages, CreateToolResourcesOptions toolResources, IDictionary metadata, IDictionary serializedAdditionalRawData) { Messages = messages; + ToolResources = toolResources; Metadata = metadata; _serializedAdditionalRawData = serializedAdditionalRawData; } /// The initial messages to associate with the new thread. - public IList Messages { get; } + public IList Messages { get; } + /// + /// A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the + /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires + /// a list of vector store IDs. + /// + public CreateToolResourcesOptions ToolResources { get; set; } /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. public IDictionary Metadata { get; set; } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormat.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormat.Serialization.cs new file mode 100644 index 000000000000..c1cc832cf7b1 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormat.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class AssistantsApiResponseFormat : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AssistantsApiResponseFormat)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + AssistantsApiResponseFormat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AssistantsApiResponseFormat)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssistantsApiResponseFormat(document.RootElement, options); + } + + internal static AssistantsApiResponseFormat DeserializeAssistantsApiResponseFormat(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + ApiResponseFormat? type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + type = new ApiResponseFormat(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AssistantsApiResponseFormat(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AssistantsApiResponseFormat)} does not support writing '{options.Format}' format."); + } + } + + AssistantsApiResponseFormat IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAssistantsApiResponseFormat(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssistantsApiResponseFormat)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static AssistantsApiResponseFormat FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAssistantsApiResponseFormat(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormat.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormat.cs new file mode 100644 index 000000000000..02f2e275e525 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormat.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// + /// An object describing the expected output of the model. If `json_object` only `function` type `tools` are allowed to be passed to the Run. + /// If `text` the model can return text or any value needed. + /// + public partial class AssistantsApiResponseFormat + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public AssistantsApiResponseFormat() + { + } + + /// Initializes a new instance of . + /// Must be one of `text` or `json_object`. + /// Keeps track of any properties unknown to the library. + internal AssistantsApiResponseFormat(ApiResponseFormat? type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Must be one of `text` or `json_object`. + public ApiResponseFormat? Type { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatMode.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatMode.cs new file mode 100644 index 000000000000..09a50720f79b --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiResponseFormatMode.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents the mode in which the model will handle the return format of a tool call. + public readonly partial struct AssistantsApiResponseFormatMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AssistantsApiResponseFormatMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AutoValue = "auto"; + private const string NoneValue = "none"; + + /// Default value. Let the model handle the return format. + public static AssistantsApiResponseFormatMode Auto { get; } = new AssistantsApiResponseFormatMode(AutoValue); + /// Setting the value to `none`, will result in a 400 Bad request. + public static AssistantsApiResponseFormatMode None { get; } = new AssistantsApiResponseFormatMode(NoneValue); + /// Determines if two values are the same. + public static bool operator ==(AssistantsApiResponseFormatMode left, AssistantsApiResponseFormatMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AssistantsApiResponseFormatMode left, AssistantsApiResponseFormatMode right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator AssistantsApiResponseFormatMode(string value) => new AssistantsApiResponseFormatMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AssistantsApiResponseFormatMode other && Equals(other); + /// + public bool Equals(AssistantsApiResponseFormatMode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiToolChoiceOptionMode.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiToolChoiceOptionMode.cs new file mode 100644 index 000000000000..a8b3a6667f2e --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsApiToolChoiceOptionMode.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Specifies how the tool choice will be used. + public readonly partial struct AssistantsApiToolChoiceOptionMode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AssistantsApiToolChoiceOptionMode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string NoneValue = "none"; + private const string AutoValue = "auto"; + + /// The model will not call a function and instead generates a message. + public static AssistantsApiToolChoiceOptionMode None { get; } = new AssistantsApiToolChoiceOptionMode(NoneValue); + /// The model can pick between generating a message or calling a function. + public static AssistantsApiToolChoiceOptionMode Auto { get; } = new AssistantsApiToolChoiceOptionMode(AutoValue); + /// Determines if two values are the same. + public static bool operator ==(AssistantsApiToolChoiceOptionMode left, AssistantsApiToolChoiceOptionMode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AssistantsApiToolChoiceOptionMode left, AssistantsApiToolChoiceOptionMode right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator AssistantsApiToolChoiceOptionMode(string value) => new AssistantsApiToolChoiceOptionMode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AssistantsApiToolChoiceOptionMode other && Equals(other); + /// + public bool Equals(AssistantsApiToolChoiceOptionMode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClient.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClient.cs index c85db38a83b6..996e52afcb6e 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClient.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClient.cs @@ -39,7 +39,7 @@ protected AssistantsClient() } /// Creates a new assistant. - /// Body parameter. + /// The request details to use when creating a new assistant. /// The cancellation token to use. /// is null. public virtual async Task> CreateAssistantAsync(AssistantCreationOptions body, CancellationToken cancellationToken = default) @@ -53,7 +53,7 @@ public virtual async Task> CreateAssistantAsync(AssistantCre } /// Creates a new assistant. - /// Body parameter. + /// The request details to use when creating a new assistant. /// The cancellation token to use. /// is null. public virtual Response CreateAssistant(AssistantCreationOptions body, CancellationToken cancellationToken = default) @@ -332,7 +332,7 @@ internal virtual Response GetAssistant(string assistantId, RequestContext contex /// Modifies an existing assistant. /// The ID of the assistant to modify. - /// Body parameter. + /// The request details to use when modifying an existing assistant. /// The cancellation token to use. /// or is null. /// is an empty string, and was expected to be non-empty. @@ -349,7 +349,7 @@ public virtual async Task> UpdateAssistantAsync(string assis /// Modifies an existing assistant. /// The ID of the assistant to modify. - /// Body parameter. + /// The request details to use when modifying an existing assistant. /// The cancellation token to use. /// or is null. /// is an empty string, and was expected to be non-empty. @@ -542,42 +542,36 @@ internal virtual Response InternalDeleteAssistant(string assistantId, RequestCon } } - /// Attaches a previously uploaded file to an assistant for use by tools that can read files. - /// The ID of the assistant to attach the file to. - /// The ID of the previously uploaded file to attach. + /// Creates a new thread. Threads contain messages and can be run by assistants. + /// The details used to create a new assistant thread. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> LinkAssistantFileAsync(string assistantId, string fileId, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task> CreateThreadAsync(AssistantThreadCreationOptions body, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - Argument.AssertNotNull(fileId, nameof(fileId)); + Argument.AssertNotNull(body, nameof(body)); - CreateAssistantFileRequest createAssistantFileRequest = new CreateAssistantFileRequest(fileId, null); + using RequestContent content = body.ToRequestContent(); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await LinkAssistantFileAsync(assistantId, createAssistantFileRequest.ToRequestContent(), context).ConfigureAwait(false); - return Response.FromValue(AssistantFile.FromResponse(response), response); + Response response = await CreateThreadAsync(content, context).ConfigureAwait(false); + return Response.FromValue(AssistantThread.FromResponse(response), response); } - /// Attaches a previously uploaded file to an assistant for use by tools that can read files. - /// The ID of the assistant to attach the file to. - /// The ID of the previously uploaded file to attach. + /// Creates a new thread. Threads contain messages and can be run by assistants. + /// The details used to create a new assistant thread. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response LinkAssistantFile(string assistantId, string fileId, CancellationToken cancellationToken = default) + /// is null. + public virtual Response CreateThread(AssistantThreadCreationOptions body, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - Argument.AssertNotNull(fileId, nameof(fileId)); + Argument.AssertNotNull(body, nameof(body)); - CreateAssistantFileRequest createAssistantFileRequest = new CreateAssistantFileRequest(fileId, null); + using RequestContent content = body.ToRequestContent(); RequestContext context = FromCancellationToken(cancellationToken); - Response response = LinkAssistantFile(assistantId, createAssistantFileRequest.ToRequestContent(), context); - return Response.FromValue(AssistantFile.FromResponse(response), response); + Response response = CreateThread(content, context); + return Response.FromValue(AssistantThread.FromResponse(response), response); } /// - /// [Protocol Method] Attaches a previously uploaded file to an assistant for use by tools that can read files. + /// [Protocol Method] Creates a new thread. Threads contain messages and can be run by assistants. /// /// /// @@ -586,23 +580,20 @@ public virtual Response LinkAssistantFile(string assistantId, str /// /// /// - /// The ID of the assistant to attach the file to. /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. + /// is null. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task LinkAssistantFileAsync(string assistantId, RequestContent content, RequestContext context = null) + internal virtual async Task CreateThreadAsync(RequestContent content, RequestContext context = null) { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.LinkAssistantFile"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateThread"); scope.Start(); try { - using HttpMessage message = CreateLinkAssistantFileRequest(assistantId, content, context); + using HttpMessage message = CreateCreateThreadRequest(content, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -613,7 +604,7 @@ internal virtual async Task LinkAssistantFileAsync(string assistantId, } /// - /// [Protocol Method] Attaches a previously uploaded file to an assistant for use by tools that can read files. + /// [Protocol Method] Creates a new thread. Threads contain messages and can be run by assistants. /// /// /// @@ -622,23 +613,20 @@ internal virtual async Task LinkAssistantFileAsync(string assistantId, /// /// /// - /// The ID of the assistant to attach the file to. /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. + /// is null. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response LinkAssistantFile(string assistantId, RequestContent content, RequestContext context = null) + internal virtual Response CreateThread(RequestContent content, RequestContext context = null) { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.LinkAssistantFile"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateThread"); scope.Start(); try { - using HttpMessage message = CreateLinkAssistantFileRequest(assistantId, content, context); + using HttpMessage message = CreateCreateThreadRequest(content, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -648,76 +636,59 @@ internal virtual Response LinkAssistantFile(string assistantId, RequestContent c } } - /// Gets a list of files attached to a specific assistant, as used by tools that can read files. - /// The ID of the assistant to retrieve the list of attached files for. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + /// Gets information about an existing thread. + /// The ID of the thread to retrieve information about. /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - internal virtual async Task> InternalGetAssistantFilesAsync(string assistantId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetThreadAsync(string threadId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await InternalGetAssistantFilesAsync(assistantId, limit, order?.ToString(), after, before, context).ConfigureAwait(false); - return Response.FromValue(InternalOpenAIPageableListOfAssistantFile.FromResponse(response), response); + Response response = await GetThreadAsync(threadId, context).ConfigureAwait(false); + return Response.FromValue(AssistantThread.FromResponse(response), response); } - /// Gets a list of files attached to a specific assistant, as used by tools that can read files. - /// The ID of the assistant to retrieve the list of attached files for. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + /// Gets information about an existing thread. + /// The ID of the thread to retrieve information about. /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - internal virtual Response InternalGetAssistantFiles(string assistantId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetThread(string threadId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = InternalGetAssistantFiles(assistantId, limit, order?.ToString(), after, before, context); - return Response.FromValue(InternalOpenAIPageableListOfAssistantFile.FromResponse(response), response); + Response response = GetThread(threadId, context); + return Response.FromValue(AssistantThread.FromResponse(response), response); } /// - /// [Protocol Method] Gets a list of files attached to a specific assistant, as used by tools that can read files. + /// [Protocol Method] Gets information about an existing thread. /// /// /// /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// /// /// - /// The ID of the assistant to retrieve the list of attached files for. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + /// The ID of the thread to retrieve information about. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task InternalGetAssistantFilesAsync(string assistantId, int? limit, string order, string after, string before, RequestContext context) + internal virtual async Task GetThreadAsync(string threadId, RequestContext context) { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetAssistantFiles"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetThread"); scope.Start(); try { - using HttpMessage message = CreateInternalGetAssistantFilesRequest(assistantId, limit, order, after, before, context); + using HttpMessage message = CreateGetThreadRequest(threadId, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -728,39 +699,30 @@ internal virtual async Task InternalGetAssistantFilesAsync(string assi } /// - /// [Protocol Method] Gets a list of files attached to a specific assistant, as used by tools that can read files. + /// [Protocol Method] Gets information about an existing thread. /// /// /// /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// /// /// - /// The ID of the assistant to retrieve the list of attached files for. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + /// The ID of the thread to retrieve information about. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response InternalGetAssistantFiles(string assistantId, int? limit, string order, string after, string before, RequestContext context) + internal virtual Response GetThread(string threadId, RequestContext context) { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetAssistantFiles"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetThread"); scope.Start(); try { - using HttpMessage message = CreateInternalGetAssistantFilesRequest(assistantId, limit, order, after, before, context); + using HttpMessage message = CreateGetThreadRequest(threadId, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -770,40 +732,42 @@ internal virtual Response InternalGetAssistantFiles(string assistantId, int? lim } } - /// Retrieves a file attached to an assistant. - /// The ID of the assistant associated with the attached file. - /// The ID of the file to retrieve. + /// Modifies an existing thread. + /// The ID of the thread to modify. + /// The details used to update an existing assistant thread. /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual async Task> GetAssistantFileAsync(string assistantId, string fileId, CancellationToken cancellationToken = default) + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> UpdateThreadAsync(string threadId, UpdateAssistantThreadOptions body, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNull(body, nameof(body)); + using RequestContent content = body.ToRequestContent(); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetAssistantFileAsync(assistantId, fileId, context).ConfigureAwait(false); - return Response.FromValue(AssistantFile.FromResponse(response), response); + Response response = await UpdateThreadAsync(threadId, content, context).ConfigureAwait(false); + return Response.FromValue(AssistantThread.FromResponse(response), response); } - /// Retrieves a file attached to an assistant. - /// The ID of the assistant associated with the attached file. - /// The ID of the file to retrieve. + /// Modifies an existing thread. + /// The ID of the thread to modify. + /// The details used to update an existing assistant thread. /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual Response GetAssistantFile(string assistantId, string fileId, CancellationToken cancellationToken = default) + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response UpdateThread(string threadId, UpdateAssistantThreadOptions body, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNull(body, nameof(body)); + using RequestContent content = body.ToRequestContent(); RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetAssistantFile(assistantId, fileId, context); - return Response.FromValue(AssistantFile.FromResponse(response), response); + Response response = UpdateThread(threadId, content, context); + return Response.FromValue(AssistantThread.FromResponse(response), response); } /// - /// [Protocol Method] Retrieves a file attached to an assistant. + /// [Protocol Method] Modifies an existing thread. /// /// /// @@ -812,23 +776,23 @@ public virtual Response GetAssistantFile(string assistantId, stri /// /// /// - /// The ID of the assistant associated with the attached file. - /// The ID of the file to retrieve. + /// The ID of the thread to modify. + /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. + /// or is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task GetAssistantFileAsync(string assistantId, string fileId, RequestContext context) + internal virtual async Task UpdateThreadAsync(string threadId, RequestContent content, RequestContext context = null) { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetAssistantFile"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateThread"); scope.Start(); try { - using HttpMessage message = CreateGetAssistantFileRequest(assistantId, fileId, context); + using HttpMessage message = CreateUpdateThreadRequest(threadId, content, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -839,7 +803,7 @@ internal virtual async Task GetAssistantFileAsync(string assistantId, } /// - /// [Protocol Method] Retrieves a file attached to an assistant. + /// [Protocol Method] Modifies an existing thread. /// /// /// @@ -848,23 +812,23 @@ internal virtual async Task GetAssistantFileAsync(string assistantId, /// /// /// - /// The ID of the assistant associated with the attached file. - /// The ID of the file to retrieve. + /// The ID of the thread to modify. + /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. + /// or is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response GetAssistantFile(string assistantId, string fileId, RequestContext context) + internal virtual Response UpdateThread(string threadId, RequestContent content, RequestContext context = null) { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetAssistantFile"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateThread"); scope.Start(); try { - using HttpMessage message = CreateGetAssistantFileRequest(assistantId, fileId, context); + using HttpMessage message = CreateUpdateThreadRequest(threadId, content, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -874,47 +838,36 @@ internal virtual Response GetAssistantFile(string assistantId, string fileId, Re } } - /// - /// Unlinks a previously attached file from an assistant, rendering it unavailable for use by tools that can read - /// files. - /// - /// The ID of the assistant from which the specified file should be unlinked. - /// The ID of the file to unlink from the specified assistant. + /// Deletes an existing thread. + /// The ID of the thread to delete. /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - internal virtual async Task> InternalUnlinkAssistantFileAsync(string assistantId, string fileId, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual async Task> InternalDeleteThreadAsync(string threadId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await InternalUnlinkAssistantFileAsync(assistantId, fileId, context).ConfigureAwait(false); - return Response.FromValue(InternalAssistantFileDeletionStatus.FromResponse(response), response); + Response response = await InternalDeleteThreadAsync(threadId, context).ConfigureAwait(false); + return Response.FromValue(ThreadDeletionStatus.FromResponse(response), response); } - /// - /// Unlinks a previously attached file from an assistant, rendering it unavailable for use by tools that can read - /// files. - /// - /// The ID of the assistant from which the specified file should be unlinked. - /// The ID of the file to unlink from the specified assistant. + /// Deletes an existing thread. + /// The ID of the thread to delete. /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - internal virtual Response InternalUnlinkAssistantFile(string assistantId, string fileId, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual Response InternalDeleteThread(string threadId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = InternalUnlinkAssistantFile(assistantId, fileId, context); - return Response.FromValue(InternalAssistantFileDeletionStatus.FromResponse(response), response); + Response response = InternalDeleteThread(threadId, context); + return Response.FromValue(ThreadDeletionStatus.FromResponse(response), response); } /// - /// [Protocol Method] Unlinks a previously attached file from an assistant, rendering it unavailable for use by tools that can read - /// files. + /// [Protocol Method] Deletes an existing thread. /// /// /// @@ -923,28 +876,26 @@ internal virtual Response InternalUnlinkAss /// /// /// - /// Please try the simpler convenience overload with strongly typed models first. + /// Please try the simpler convenience overload with strongly typed models first. /// /// /// /// - /// The ID of the assistant from which the specified file should be unlinked. - /// The ID of the file to unlink from the specified assistant. + /// The ID of the thread to delete. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task InternalUnlinkAssistantFileAsync(string assistantId, string fileId, RequestContext context) + internal virtual async Task InternalDeleteThreadAsync(string threadId, RequestContext context) { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalUnlinkAssistantFile"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalDeleteThread"); scope.Start(); try { - using HttpMessage message = CreateInternalUnlinkAssistantFileRequest(assistantId, fileId, context); + using HttpMessage message = CreateInternalDeleteThreadRequest(threadId, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -955,8 +906,7 @@ internal virtual async Task InternalUnlinkAssistantFileAsync(string as } /// - /// [Protocol Method] Unlinks a previously attached file from an assistant, rendering it unavailable for use by tools that can read - /// files. + /// [Protocol Method] Deletes an existing thread. /// /// /// @@ -965,28 +915,26 @@ internal virtual async Task InternalUnlinkAssistantFileAsync(string as /// /// /// - /// Please try the simpler convenience overload with strongly typed models first. + /// Please try the simpler convenience overload with strongly typed models first. /// /// /// /// - /// The ID of the assistant from which the specified file should be unlinked. - /// The ID of the file to unlink from the specified assistant. + /// The ID of the thread to delete. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response InternalUnlinkAssistantFile(string assistantId, string fileId, RequestContext context) + internal virtual Response InternalDeleteThread(string threadId, RequestContext context) { - Argument.AssertNotNullOrEmpty(assistantId, nameof(assistantId)); - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalUnlinkAssistantFile"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalDeleteThread"); scope.Start(); try { - using HttpMessage message = CreateInternalUnlinkAssistantFileRequest(assistantId, fileId, context); + using HttpMessage message = CreateInternalDeleteThreadRequest(threadId, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -996,36 +944,42 @@ internal virtual Response InternalUnlinkAssistantFile(string assistantId, string } } - /// Creates a new thread. Threads contain messages and can be run by assistants. - /// Body parameter. + /// Creates a new message on a specified thread. + /// The ID of the thread to create the new message on. + /// A single message within an assistant thread, as provided during that thread's creation for its initial state. /// The cancellation token to use. - /// is null. - public virtual async Task> CreateThreadAsync(AssistantThreadCreationOptions body, CancellationToken cancellationToken = default) + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateMessageAsync(string threadId, ThreadMessageOptions body, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); Argument.AssertNotNull(body, nameof(body)); using RequestContent content = body.ToRequestContent(); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await CreateThreadAsync(content, context).ConfigureAwait(false); - return Response.FromValue(AssistantThread.FromResponse(response), response); + Response response = await CreateMessageAsync(threadId, content, context).ConfigureAwait(false); + return Response.FromValue(ThreadMessage.FromResponse(response), response); } - /// Creates a new thread. Threads contain messages and can be run by assistants. - /// Body parameter. + /// Creates a new message on a specified thread. + /// The ID of the thread to create the new message on. + /// A single message within an assistant thread, as provided during that thread's creation for its initial state. /// The cancellation token to use. - /// is null. - public virtual Response CreateThread(AssistantThreadCreationOptions body, CancellationToken cancellationToken = default) + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response CreateMessage(string threadId, ThreadMessageOptions body, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); Argument.AssertNotNull(body, nameof(body)); using RequestContent content = body.ToRequestContent(); RequestContext context = FromCancellationToken(cancellationToken); - Response response = CreateThread(content, context); - return Response.FromValue(AssistantThread.FromResponse(response), response); + Response response = CreateMessage(threadId, content, context); + return Response.FromValue(ThreadMessage.FromResponse(response), response); } /// - /// [Protocol Method] Creates a new thread. Threads contain messages and can be run by assistants. + /// [Protocol Method] Creates a new message on a specified thread. /// /// /// @@ -1034,20 +988,23 @@ public virtual Response CreateThread(AssistantThreadCreationOpt /// /// /// + /// The ID of the thread to create the new message on. /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. + /// or is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task CreateThreadAsync(RequestContent content, RequestContext context = null) + internal virtual async Task CreateMessageAsync(string threadId, RequestContent content, RequestContext context = null) { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateThread"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateMessage"); scope.Start(); try { - using HttpMessage message = CreateCreateThreadRequest(content, context); + using HttpMessage message = CreateCreateMessageRequest(threadId, content, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -1058,7 +1015,7 @@ internal virtual async Task CreateThreadAsync(RequestContent content, } /// - /// [Protocol Method] Creates a new thread. Threads contain messages and can be run by assistants. + /// [Protocol Method] Creates a new message on a specified thread. /// /// /// @@ -1067,20 +1024,23 @@ internal virtual async Task CreateThreadAsync(RequestContent content, /// /// /// + /// The ID of the thread to create the new message on. /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. + /// or is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response CreateThread(RequestContent content, RequestContext context = null) + internal virtual Response CreateMessage(string threadId, RequestContent content, RequestContext context = null) { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateThread"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateMessage"); scope.Start(); try { - using HttpMessage message = CreateCreateThreadRequest(content, context); + using HttpMessage message = CreateCreateMessageRequest(threadId, content, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -1090,59 +1050,79 @@ internal virtual Response CreateThread(RequestContent content, RequestContext co } } - /// Gets information about an existing thread. - /// The ID of the thread to retrieve information about. + /// Gets a list of messages that exist on a thread. + /// The ID of the thread to list messages from. + /// Filter messages by the run ID that generated them. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. /// The cancellation token to use. /// is null. /// is an empty string, and was expected to be non-empty. - public virtual async Task> GetThreadAsync(string threadId, CancellationToken cancellationToken = default) + internal virtual async Task> InternalGetMessagesAsync(string threadId, string runId = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetThreadAsync(threadId, context).ConfigureAwait(false); - return Response.FromValue(AssistantThread.FromResponse(response), response); + Response response = await InternalGetMessagesAsync(threadId, runId, limit, order?.ToString(), after, before, context).ConfigureAwait(false); + return Response.FromValue(InternalOpenAIPageableListOfThreadMessage.FromResponse(response), response); } - /// Gets information about an existing thread. - /// The ID of the thread to retrieve information about. + /// Gets a list of messages that exist on a thread. + /// The ID of the thread to list messages from. + /// Filter messages by the run ID that generated them. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. /// The cancellation token to use. /// is null. /// is an empty string, and was expected to be non-empty. - public virtual Response GetThread(string threadId, CancellationToken cancellationToken = default) + internal virtual Response InternalGetMessages(string threadId, string runId = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetThread(threadId, context); - return Response.FromValue(AssistantThread.FromResponse(response), response); + Response response = InternalGetMessages(threadId, runId, limit, order?.ToString(), after, before, context); + return Response.FromValue(InternalOpenAIPageableListOfThreadMessage.FromResponse(response), response); } /// - /// [Protocol Method] Gets information about an existing thread. + /// [Protocol Method] Gets a list of messages that exist on a thread. /// /// /// /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The ID of the thread to retrieve information about. + /// The ID of the thread to list messages from. + /// Filter messages by the run ID that generated them. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task GetThreadAsync(string threadId, RequestContext context) + internal virtual async Task InternalGetMessagesAsync(string threadId, string runId, int? limit, string order, string after, string before, RequestContext context) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetThread"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetMessages"); scope.Start(); try { - using HttpMessage message = CreateGetThreadRequest(threadId, context); + using HttpMessage message = CreateInternalGetMessagesRequest(threadId, runId, limit, order, after, before, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -1153,30 +1133,40 @@ internal virtual async Task GetThreadAsync(string threadId, RequestCon } /// - /// [Protocol Method] Gets information about an existing thread. + /// [Protocol Method] Gets a list of messages that exist on a thread. /// /// /// /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// /// /// - /// The ID of the thread to retrieve information about. + /// The ID of the thread to list messages from. + /// Filter messages by the run ID that generated them. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response GetThread(string threadId, RequestContext context) + internal virtual Response InternalGetMessages(string threadId, string runId, int? limit, string order, string after, string before, RequestContext context) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetThread"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetMessages"); scope.Start(); try { - using HttpMessage message = CreateGetThreadRequest(threadId, context); + using HttpMessage message = CreateInternalGetMessagesRequest(threadId, runId, limit, order, after, before, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -1186,40 +1176,40 @@ internal virtual Response GetThread(string threadId, RequestContext context) } } - /// Modifies an existing thread. - /// The ID of the thread to modify. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Gets an existing message from an existing thread. + /// The ID of the thread to retrieve the specified message from. + /// The ID of the message to retrieve from the specified thread. /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> UpdateThreadAsync(string threadId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> GetMessageAsync(string threadId, string messageId, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); - UpdateThreadRequest updateThreadRequest = new UpdateThreadRequest(metadata ?? new ChangeTrackingDictionary(), null); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await UpdateThreadAsync(threadId, updateThreadRequest.ToRequestContent(), context).ConfigureAwait(false); - return Response.FromValue(AssistantThread.FromResponse(response), response); + Response response = await GetMessageAsync(threadId, messageId, context).ConfigureAwait(false); + return Response.FromValue(ThreadMessage.FromResponse(response), response); } - /// Modifies an existing thread. - /// The ID of the thread to modify. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Gets an existing message from an existing thread. + /// The ID of the thread to retrieve the specified message from. + /// The ID of the message to retrieve from the specified thread. /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response UpdateThread(string threadId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response GetMessage(string threadId, string messageId, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); - UpdateThreadRequest updateThreadRequest = new UpdateThreadRequest(metadata ?? new ChangeTrackingDictionary(), null); RequestContext context = FromCancellationToken(cancellationToken); - Response response = UpdateThread(threadId, updateThreadRequest.ToRequestContent(), context); - return Response.FromValue(AssistantThread.FromResponse(response), response); + Response response = GetMessage(threadId, messageId, context); + return Response.FromValue(ThreadMessage.FromResponse(response), response); } /// - /// [Protocol Method] Modifies an existing thread. + /// [Protocol Method] Gets an existing message from an existing thread. /// /// /// @@ -1228,23 +1218,23 @@ public virtual Response UpdateThread(string threadId, IReadOnly /// /// /// - /// The ID of the thread to modify. - /// The content to send as the body of the request. + /// The ID of the thread to retrieve the specified message from. + /// The ID of the message to retrieve from the specified thread. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. + /// or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task UpdateThreadAsync(string threadId, RequestContent content, RequestContext context = null) + internal virtual async Task GetMessageAsync(string threadId, string messageId, RequestContext context) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateThread"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetMessage"); scope.Start(); try { - using HttpMessage message = CreateUpdateThreadRequest(threadId, content, context); + using HttpMessage message = CreateGetMessageRequest(threadId, messageId, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -1255,7 +1245,7 @@ internal virtual async Task UpdateThreadAsync(string threadId, Request } /// - /// [Protocol Method] Modifies an existing thread. + /// [Protocol Method] Gets an existing message from an existing thread. /// /// /// @@ -1264,23 +1254,23 @@ internal virtual async Task UpdateThreadAsync(string threadId, Request /// /// /// - /// The ID of the thread to modify. - /// The content to send as the body of the request. + /// The ID of the thread to retrieve the specified message from. + /// The ID of the message to retrieve from the specified thread. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. + /// or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response UpdateThread(string threadId, RequestContent content, RequestContext context = null) + internal virtual Response GetMessage(string threadId, string messageId, RequestContext context) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateThread"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetMessage"); scope.Start(); try { - using HttpMessage message = CreateUpdateThreadRequest(threadId, content, context); + using HttpMessage message = CreateGetMessageRequest(threadId, messageId, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -1290,64 +1280,71 @@ internal virtual Response UpdateThread(string threadId, RequestContent content, } } - /// Deletes an existing thread. - /// The ID of the thread to delete. + /// Modifies an existing message on an existing thread. + /// The ID of the thread containing the specified message to modify. + /// The ID of the message to modify on the specified thread. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - internal virtual async Task> InternalDeleteThreadAsync(string threadId, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> UpdateMessageAsync(string threadId, string messageId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + UpdateMessageRequest updateMessageRequest = new UpdateMessageRequest(metadata ?? new ChangeTrackingDictionary(), null); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await InternalDeleteThreadAsync(threadId, context).ConfigureAwait(false); - return Response.FromValue(ThreadDeletionStatus.FromResponse(response), response); + Response response = await UpdateMessageAsync(threadId, messageId, updateMessageRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(ThreadMessage.FromResponse(response), response); } - /// Deletes an existing thread. - /// The ID of the thread to delete. + /// Modifies an existing message on an existing thread. + /// The ID of the thread containing the specified message to modify. + /// The ID of the message to modify on the specified thread. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - internal virtual Response InternalDeleteThread(string threadId, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response UpdateMessage(string threadId, string messageId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + UpdateMessageRequest updateMessageRequest = new UpdateMessageRequest(metadata ?? new ChangeTrackingDictionary(), null); RequestContext context = FromCancellationToken(cancellationToken); - Response response = InternalDeleteThread(threadId, context); - return Response.FromValue(ThreadDeletionStatus.FromResponse(response), response); + Response response = UpdateMessage(threadId, messageId, updateMessageRequest.ToRequestContent(), context); + return Response.FromValue(ThreadMessage.FromResponse(response), response); } /// - /// [Protocol Method] Deletes an existing thread. + /// [Protocol Method] Modifies an existing message on an existing thread. /// /// /// /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// /// /// - /// The ID of the thread to delete. + /// The ID of the thread containing the specified message to modify. + /// The ID of the message to modify on the specified thread. + /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task InternalDeleteThreadAsync(string threadId, RequestContext context) + internal virtual async Task UpdateMessageAsync(string threadId, string messageId, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalDeleteThread"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateMessage"); scope.Start(); try { - using HttpMessage message = CreateInternalDeleteThreadRequest(threadId, context); + using HttpMessage message = CreateUpdateMessageRequest(threadId, messageId, content, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -1358,35 +1355,34 @@ internal virtual async Task InternalDeleteThreadAsync(string threadId, } /// - /// [Protocol Method] Deletes an existing thread. + /// [Protocol Method] Modifies an existing message on an existing thread. /// /// /// /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// /// /// - /// The ID of the thread to delete. + /// The ID of the thread containing the specified message to modify. + /// The ID of the message to modify on the specified thread. + /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response InternalDeleteThread(string threadId, RequestContext context) + internal virtual Response UpdateMessage(string threadId, string messageId, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalDeleteThread"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateMessage"); scope.Start(); try { - using HttpMessage message = CreateInternalDeleteThreadRequest(threadId, context); + using HttpMessage message = CreateUpdateMessageRequest(threadId, messageId, content, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -1396,48 +1392,42 @@ internal virtual Response InternalDeleteThread(string threadId, RequestContext c } } - /// Creates a new message on a specified thread. - /// The ID of the thread to create the new message on. - /// The role to associate with the new message. - /// The textual content for the new message. - /// A list of up to 10 file IDs to associate with the message, as used by tools like 'code_interpreter' or 'retrieval' that can read files. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Creates a new run for an assistant thread. + /// The ID of the thread to run. + /// The details used when creating a new run of an assistant thread. /// The cancellation token to use. - /// or is null. + /// or is null. /// is an empty string, and was expected to be non-empty. - public virtual async Task> CreateMessageAsync(string threadId, MessageRole role, string content, IEnumerable fileIds = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + public virtual async Task> CreateRunAsync(string threadId, CreateRunOptions body, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(body, nameof(body)); - CreateMessageRequest createMessageRequest = new CreateMessageRequest(role, content, fileIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), null); + using RequestContent content = body.ToRequestContent(); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await CreateMessageAsync(threadId, createMessageRequest.ToRequestContent(), context).ConfigureAwait(false); - return Response.FromValue(ThreadMessage.FromResponse(response), response); + Response response = await CreateRunAsync(threadId, content, context).ConfigureAwait(false); + return Response.FromValue(ThreadRun.FromResponse(response), response); } - /// Creates a new message on a specified thread. - /// The ID of the thread to create the new message on. - /// The role to associate with the new message. - /// The textual content for the new message. - /// A list of up to 10 file IDs to associate with the message, as used by tools like 'code_interpreter' or 'retrieval' that can read files. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Creates a new run for an assistant thread. + /// The ID of the thread to run. + /// The details used when creating a new run of an assistant thread. /// The cancellation token to use. - /// or is null. + /// or is null. /// is an empty string, and was expected to be non-empty. - public virtual Response CreateMessage(string threadId, MessageRole role, string content, IEnumerable fileIds = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + public virtual Response CreateRun(string threadId, CreateRunOptions body, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNull(body, nameof(body)); - CreateMessageRequest createMessageRequest = new CreateMessageRequest(role, content, fileIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), null); + using RequestContent content = body.ToRequestContent(); RequestContext context = FromCancellationToken(cancellationToken); - Response response = CreateMessage(threadId, createMessageRequest.ToRequestContent(), context); - return Response.FromValue(ThreadMessage.FromResponse(response), response); + Response response = CreateRun(threadId, content, context); + return Response.FromValue(ThreadRun.FromResponse(response), response); } /// - /// [Protocol Method] Creates a new message on a specified thread. + /// [Protocol Method] Creates a new run for an assistant thread. /// /// /// @@ -1446,23 +1436,23 @@ public virtual Response CreateMessage(string threadId, MessageRol /// /// /// - /// The ID of the thread to create the new message on. + /// The ID of the thread to run. /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// or is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task CreateMessageAsync(string threadId, RequestContent content, RequestContext context = null) + internal virtual async Task CreateRunAsync(string threadId, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateMessage"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateRun"); scope.Start(); try { - using HttpMessage message = CreateCreateMessageRequest(threadId, content, context); + using HttpMessage message = CreateCreateRunRequest(threadId, content, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -1473,7 +1463,7 @@ internal virtual async Task CreateMessageAsync(string threadId, Reques } /// - /// [Protocol Method] Creates a new message on a specified thread. + /// [Protocol Method] Creates a new run for an assistant thread. /// /// /// @@ -1482,23 +1472,23 @@ internal virtual async Task CreateMessageAsync(string threadId, Reques /// /// /// - /// The ID of the thread to create the new message on. + /// The ID of the thread to run. /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. /// or is null. /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response CreateMessage(string threadId, RequestContent content, RequestContext context = null) + internal virtual Response CreateRun(string threadId, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateMessage"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateRun"); scope.Start(); try { - using HttpMessage message = CreateCreateMessageRequest(threadId, content, context); + using HttpMessage message = CreateCreateRunRequest(threadId, content, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -1508,8 +1498,8 @@ internal virtual Response CreateMessage(string threadId, RequestContent content, } } - /// Gets a list of messages that exist on a thread. - /// The ID of the thread to list messages from. + /// Gets a list of runs for a specified thread. + /// The ID of the thread to list runs from. /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. @@ -1517,17 +1507,17 @@ internal virtual Response CreateMessage(string threadId, RequestContent content, /// The cancellation token to use. /// is null. /// is an empty string, and was expected to be non-empty. - internal virtual async Task> InternalGetMessagesAsync(string threadId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + internal virtual async Task> InternalGetRunsAsync(string threadId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await InternalGetMessagesAsync(threadId, limit, order?.ToString(), after, before, context).ConfigureAwait(false); - return Response.FromValue(InternalOpenAIPageableListOfThreadMessage.FromResponse(response), response); + Response response = await InternalGetRunsAsync(threadId, limit, order?.ToString(), after, before, context).ConfigureAwait(false); + return Response.FromValue(InternalOpenAIPageableListOfThreadRun.FromResponse(response), response); } - /// Gets a list of messages that exist on a thread. - /// The ID of the thread to list messages from. + /// Gets a list of runs for a specified thread. + /// The ID of the thread to list runs from. /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. @@ -1535,17 +1525,17 @@ internal virtual async Task> /// The cancellation token to use. /// is null. /// is an empty string, and was expected to be non-empty. - internal virtual Response InternalGetMessages(string threadId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + internal virtual Response InternalGetRuns(string threadId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = InternalGetMessages(threadId, limit, order?.ToString(), after, before, context); - return Response.FromValue(InternalOpenAIPageableListOfThreadMessage.FromResponse(response), response); + Response response = InternalGetRuns(threadId, limit, order?.ToString(), after, before, context); + return Response.FromValue(InternalOpenAIPageableListOfThreadRun.FromResponse(response), response); } /// - /// [Protocol Method] Gets a list of messages that exist on a thread. + /// [Protocol Method] Gets a list of runs for a specified thread. /// /// /// @@ -1554,12 +1544,12 @@ internal virtual Response InternalGet /// /// /// - /// Please try the simpler convenience overload with strongly typed models first. + /// Please try the simpler convenience overload with strongly typed models first. /// /// /// /// - /// The ID of the thread to list messages from. + /// The ID of the thread to list runs from. /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. @@ -1569,15 +1559,15 @@ internal virtual Response InternalGet /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task InternalGetMessagesAsync(string threadId, int? limit, string order, string after, string before, RequestContext context) + internal virtual async Task InternalGetRunsAsync(string threadId, int? limit, string order, string after, string before, RequestContext context) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetMessages"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetRuns"); scope.Start(); try { - using HttpMessage message = CreateInternalGetMessagesRequest(threadId, limit, order, after, before, context); + using HttpMessage message = CreateInternalGetRunsRequest(threadId, limit, order, after, before, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -1588,7 +1578,7 @@ internal virtual async Task InternalGetMessagesAsync(string threadId, } /// - /// [Protocol Method] Gets a list of messages that exist on a thread. + /// [Protocol Method] Gets a list of runs for a specified thread. /// /// /// @@ -1597,12 +1587,12 @@ internal virtual async Task InternalGetMessagesAsync(string threadId, /// /// /// - /// Please try the simpler convenience overload with strongly typed models first. + /// Please try the simpler convenience overload with strongly typed models first. /// /// /// /// - /// The ID of the thread to list messages from. + /// The ID of the thread to list runs from. /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. @@ -1612,15 +1602,15 @@ internal virtual async Task InternalGetMessagesAsync(string threadId, /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response InternalGetMessages(string threadId, int? limit, string order, string after, string before, RequestContext context) + internal virtual Response InternalGetRuns(string threadId, int? limit, string order, string after, string before, RequestContext context) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetMessages"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetRuns"); scope.Start(); try { - using HttpMessage message = CreateInternalGetMessagesRequest(threadId, limit, order, after, before, context); + using HttpMessage message = CreateInternalGetRunsRequest(threadId, limit, order, after, before, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -1630,40 +1620,40 @@ internal virtual Response InternalGetMessages(string threadId, int? limit, strin } } - /// Gets an existing message from an existing thread. - /// The ID of the thread to retrieve the specified message from. - /// The ID of the message to retrieve from the specified thread. + /// Gets an existing run from an existing thread. + /// The ID of the thread to retrieve run information from. + /// The ID of the thread to retrieve information about. /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual async Task> GetMessageAsync(string threadId, string messageId, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> GetRunAsync(string threadId, string runId, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetMessageAsync(threadId, messageId, context).ConfigureAwait(false); - return Response.FromValue(ThreadMessage.FromResponse(response), response); + Response response = await GetRunAsync(threadId, runId, context).ConfigureAwait(false); + return Response.FromValue(ThreadRun.FromResponse(response), response); } - /// Gets an existing message from an existing thread. - /// The ID of the thread to retrieve the specified message from. - /// The ID of the message to retrieve from the specified thread. + /// Gets an existing run from an existing thread. + /// The ID of the thread to retrieve run information from. + /// The ID of the thread to retrieve information about. /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual Response GetMessage(string threadId, string messageId, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response GetRun(string threadId, string runId, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetMessage(threadId, messageId, context); - return Response.FromValue(ThreadMessage.FromResponse(response), response); + Response response = GetRun(threadId, runId, context); + return Response.FromValue(ThreadRun.FromResponse(response), response); } /// - /// [Protocol Method] Gets an existing message from an existing thread. + /// [Protocol Method] Gets an existing run from an existing thread. /// /// /// @@ -1672,23 +1662,23 @@ public virtual Response GetMessage(string threadId, string messag /// /// /// - /// The ID of the thread to retrieve the specified message from. - /// The ID of the message to retrieve from the specified thread. + /// The ID of the thread to retrieve run information from. + /// The ID of the thread to retrieve information about. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. + /// or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task GetMessageAsync(string threadId, string messageId, RequestContext context) + internal virtual async Task GetRunAsync(string threadId, string runId, RequestContext context) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetMessage"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetRun"); scope.Start(); try { - using HttpMessage message = CreateGetMessageRequest(threadId, messageId, context); + using HttpMessage message = CreateGetRunRequest(threadId, runId, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -1699,7 +1689,7 @@ internal virtual async Task GetMessageAsync(string threadId, string me } /// - /// [Protocol Method] Gets an existing message from an existing thread. + /// [Protocol Method] Gets an existing run from an existing thread. /// /// /// @@ -1708,23 +1698,23 @@ internal virtual async Task GetMessageAsync(string threadId, string me /// /// /// - /// The ID of the thread to retrieve the specified message from. - /// The ID of the message to retrieve from the specified thread. + /// The ID of the thread to retrieve run information from. + /// The ID of the thread to retrieve information about. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. + /// or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response GetMessage(string threadId, string messageId, RequestContext context) + internal virtual Response GetRun(string threadId, string runId, RequestContext context) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetMessage"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetRun"); scope.Start(); try { - using HttpMessage message = CreateGetMessageRequest(threadId, messageId, context); + using HttpMessage message = CreateGetRunRequest(threadId, runId, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -1734,44 +1724,44 @@ internal virtual Response GetMessage(string threadId, string messageId, RequestC } } - /// Modifies an existing message on an existing thread. - /// The ID of the thread containing the specified message to modify. - /// The ID of the message to modify on the specified thread. + /// Modifies an existing thread run. + /// The ID of the thread associated with the specified run. + /// The ID of the run to modify. /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual async Task> UpdateMessageAsync(string threadId, string messageId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> UpdateRunAsync(string threadId, string runId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - UpdateMessageRequest updateMessageRequest = new UpdateMessageRequest(metadata ?? new ChangeTrackingDictionary(), null); + UpdateRunRequest updateRunRequest = new UpdateRunRequest(metadata ?? new ChangeTrackingDictionary(), null); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await UpdateMessageAsync(threadId, messageId, updateMessageRequest.ToRequestContent(), context).ConfigureAwait(false); - return Response.FromValue(ThreadMessage.FromResponse(response), response); + Response response = await UpdateRunAsync(threadId, runId, updateRunRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(ThreadRun.FromResponse(response), response); } - /// Modifies an existing message on an existing thread. - /// The ID of the thread containing the specified message to modify. - /// The ID of the message to modify on the specified thread. + /// Modifies an existing thread run. + /// The ID of the thread associated with the specified run. + /// The ID of the run to modify. /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual Response UpdateMessage(string threadId, string messageId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response UpdateRun(string threadId, string runId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - UpdateMessageRequest updateMessageRequest = new UpdateMessageRequest(metadata ?? new ChangeTrackingDictionary(), null); + UpdateRunRequest updateRunRequest = new UpdateRunRequest(metadata ?? new ChangeTrackingDictionary(), null); RequestContext context = FromCancellationToken(cancellationToken); - Response response = UpdateMessage(threadId, messageId, updateMessageRequest.ToRequestContent(), context); - return Response.FromValue(ThreadMessage.FromResponse(response), response); + Response response = UpdateRun(threadId, runId, updateRunRequest.ToRequestContent(), context); + return Response.FromValue(ThreadRun.FromResponse(response), response); } /// - /// [Protocol Method] Modifies an existing message on an existing thread. + /// [Protocol Method] Modifies an existing thread run. /// /// /// @@ -1780,25 +1770,25 @@ public virtual Response UpdateMessage(string threadId, string mes /// /// /// - /// The ID of the thread containing the specified message to modify. - /// The ID of the message to modify on the specified thread. + /// The ID of the thread associated with the specified run. + /// The ID of the run to modify. /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task UpdateMessageAsync(string threadId, string messageId, RequestContent content, RequestContext context = null) + internal virtual async Task UpdateRunAsync(string threadId, string runId, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateMessage"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateRun"); scope.Start(); try { - using HttpMessage message = CreateUpdateMessageRequest(threadId, messageId, content, context); + using HttpMessage message = CreateUpdateRunRequest(threadId, runId, content, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -1809,7 +1799,7 @@ internal virtual async Task UpdateMessageAsync(string threadId, string } /// - /// [Protocol Method] Modifies an existing message on an existing thread. + /// [Protocol Method] Modifies an existing thread run. /// /// /// @@ -1818,25 +1808,25 @@ internal virtual async Task UpdateMessageAsync(string threadId, string /// /// /// - /// The ID of the thread containing the specified message to modify. - /// The ID of the message to modify on the specified thread. + /// The ID of the thread associated with the specified run. + /// The ID of the run to modify. /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response UpdateMessage(string threadId, string messageId, RequestContent content, RequestContext context = null) + internal virtual Response UpdateRun(string threadId, string runId, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateMessage"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateRun"); scope.Start(); try { - using HttpMessage message = CreateUpdateMessageRequest(threadId, messageId, content, context); + using HttpMessage message = CreateUpdateRunRequest(threadId, runId, content, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -1846,82 +1836,812 @@ internal virtual Response UpdateMessage(string threadId, string messageId, Reque } } - /// Gets a list of previously uploaded files associated with a message from a thread. - /// The ID of the thread containing the message to list files from. - /// The ID of the message to list files from. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + /// Submits outputs from tools as requested by tool calls in a run. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'. + /// The ID of the thread that was run. + /// The ID of the run that requires tool outputs. + /// A list of tools for which the outputs are being submitted. + /// If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message. /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - internal virtual async Task> InternalGetMessageFilesAsync(string threadId, string messageId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> SubmitToolOutputsToRunAsync(string threadId, string runId, IEnumerable toolOutputs, bool? stream = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNull(toolOutputs, nameof(toolOutputs)); + SubmitToolOutputsToRunRequest submitToolOutputsToRunRequest = new SubmitToolOutputsToRunRequest(toolOutputs.ToList(), stream, null); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await InternalGetMessageFilesAsync(threadId, messageId, limit, order?.ToString(), after, before, context).ConfigureAwait(false); - return Response.FromValue(InternalOpenAIPageableListOfMessageFile.FromResponse(response), response); + Response response = await SubmitToolOutputsToRunAsync(threadId, runId, submitToolOutputsToRunRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(ThreadRun.FromResponse(response), response); } - /// Gets a list of previously uploaded files associated with a message from a thread. - /// The ID of the thread containing the message to list files from. - /// The ID of the message to list files from. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + /// Submits outputs from tools as requested by tool calls in a run. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'. + /// The ID of the thread that was run. + /// The ID of the run that requires tool outputs. + /// A list of tools for which the outputs are being submitted. + /// If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message. /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - internal virtual Response InternalGetMessageFiles(string threadId, string messageId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response SubmitToolOutputsToRun(string threadId, string runId, IEnumerable toolOutputs, bool? stream = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNull(toolOutputs, nameof(toolOutputs)); + SubmitToolOutputsToRunRequest submitToolOutputsToRunRequest = new SubmitToolOutputsToRunRequest(toolOutputs.ToList(), stream, null); RequestContext context = FromCancellationToken(cancellationToken); - Response response = InternalGetMessageFiles(threadId, messageId, limit, order?.ToString(), after, before, context); - return Response.FromValue(InternalOpenAIPageableListOfMessageFile.FromResponse(response), response); + Response response = SubmitToolOutputsToRun(threadId, runId, submitToolOutputsToRunRequest.ToRequestContent(), context); + return Response.FromValue(ThreadRun.FromResponse(response), response); } /// - /// [Protocol Method] Gets a list of previously uploaded files associated with a message from a thread. + /// [Protocol Method] Submits outputs from tools as requested by tool calls in a run. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'. /// /// /// /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// + /// + /// + /// The ID of the thread that was run. + /// The ID of the run that requires tool outputs. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual async Task SubmitToolOutputsToRunAsync(string threadId, string runId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.SubmitToolOutputsToRun"); + scope.Start(); + try + { + using HttpMessage message = CreateSubmitToolOutputsToRunRequest(threadId, runId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Submits outputs from tools as requested by tool calls in a run. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'. + /// /// /// - /// Please try the simpler convenience overload with strongly typed models first. + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// /// /// - /// The ID of the thread containing the message to list files from. - /// The ID of the message to list files from. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + /// The ID of the thread that was run. + /// The ID of the run that requires tool outputs. + /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task InternalGetMessageFilesAsync(string threadId, string messageId, int? limit, string order, string after, string before, RequestContext context) + internal virtual Response SubmitToolOutputsToRun(string threadId, string runId, RequestContent content, RequestContext context = null) { Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetMessageFiles"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.SubmitToolOutputsToRun"); scope.Start(); try { - using HttpMessage message = CreateInternalGetMessageFilesRequest(threadId, messageId, limit, order, after, before, context); + using HttpMessage message = CreateSubmitToolOutputsToRunRequest(threadId, runId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Cancels a run of an in progress thread. + /// The ID of the thread being run. + /// The ID of the run to cancel. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> CancelRunAsync(string threadId, string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CancelRunAsync(threadId, runId, context).ConfigureAwait(false); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// Cancels a run of an in progress thread. + /// The ID of the thread being run. + /// The ID of the run to cancel. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response CancelRun(string threadId, string runId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = CancelRun(threadId, runId, context); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// + /// [Protocol Method] Cancels a run of an in progress thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the thread being run. + /// The ID of the run to cancel. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual async Task CancelRunAsync(string threadId, string runId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CancelRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCancelRunRequest(threadId, runId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Cancels a run of an in progress thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the thread being run. + /// The ID of the run to cancel. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual Response CancelRun(string threadId, string runId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CancelRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCancelRunRequest(threadId, runId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Creates a new assistant thread and immediately starts a run using that new thread. + /// The details used when creating and immediately running a new assistant thread. + /// The cancellation token to use. + /// is null. + public virtual async Task> CreateThreadAndRunAsync(CreateAndRunThreadOptions body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CreateThreadAndRunAsync(content, context).ConfigureAwait(false); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// Creates a new assistant thread and immediately starts a run using that new thread. + /// The details used when creating and immediately running a new assistant thread. + /// The cancellation token to use. + /// is null. + public virtual Response CreateThreadAndRun(CreateAndRunThreadOptions body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + using RequestContent content = body.ToRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = CreateThreadAndRun(content, context); + return Response.FromValue(ThreadRun.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates a new assistant thread and immediately starts a run using that new thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual async Task CreateThreadAndRunAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateThreadAndRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateThreadAndRunRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates a new assistant thread and immediately starts a run using that new thread. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual Response CreateThreadAndRun(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateThreadAndRun"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateThreadAndRunRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a single run step from a thread run. + /// The ID of the thread that was run. + /// The ID of the specific run to retrieve the step from. + /// The ID of the step to retrieve information about. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public virtual async Task> GetRunStepAsync(string threadId, string runId, string stepId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(stepId, nameof(stepId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetRunStepAsync(threadId, runId, stepId, context).ConfigureAwait(false); + return Response.FromValue(RunStep.FromResponse(response), response); + } + + /// Gets a single run step from a thread run. + /// The ID of the thread that was run. + /// The ID of the specific run to retrieve the step from. + /// The ID of the step to retrieve information about. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + public virtual Response GetRunStep(string threadId, string runId, string stepId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(stepId, nameof(stepId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetRunStep(threadId, runId, stepId, context); + return Response.FromValue(RunStep.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets a single run step from a thread run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the thread that was run. + /// The ID of the specific run to retrieve the step from. + /// The ID of the step to retrieve information about. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual async Task GetRunStepAsync(string threadId, string runId, string stepId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(stepId, nameof(stepId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetRunStep"); + scope.Start(); + try + { + using HttpMessage message = CreateGetRunStepRequest(threadId, runId, stepId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets a single run step from a thread run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The ID of the thread that was run. + /// The ID of the specific run to retrieve the step from. + /// The ID of the step to retrieve information about. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual Response GetRunStep(string threadId, string runId, string stepId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(stepId, nameof(stepId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetRunStep"); + scope.Start(); + try + { + using HttpMessage message = CreateGetRunStepRequest(threadId, runId, stepId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a list of run steps from a thread run. + /// The ID of the thread that was run. + /// The ID of the run to list steps from. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + internal virtual async Task> InternalGetRunStepsAsync(string threadId, string runId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await InternalGetRunStepsAsync(threadId, runId, limit, order?.ToString(), after, before, context).ConfigureAwait(false); + return Response.FromValue(InternalOpenAIPageableListOfRunStep.FromResponse(response), response); + } + + /// Gets a list of run steps from a thread run. + /// The ID of the thread that was run. + /// The ID of the run to list steps from. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + internal virtual Response InternalGetRunSteps(string threadId, string runId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = InternalGetRunSteps(threadId, runId, limit, order?.ToString(), after, before, context); + return Response.FromValue(InternalOpenAIPageableListOfRunStep.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets a list of run steps from a thread run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The ID of the thread that was run. + /// The ID of the run to list steps from. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual async Task InternalGetRunStepsAsync(string threadId, string runId, int? limit, string order, string after, string before, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetRunSteps"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetRunStepsRequest(threadId, runId, limit, order, after, before, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets a list of run steps from a thread run. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The ID of the thread that was run. + /// The ID of the run to list steps from. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual Response InternalGetRunSteps(string threadId, string runId, int? limit, string order, string after, string before, RequestContext context) + { + Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); + Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetRunSteps"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalGetRunStepsRequest(threadId, runId, limit, order, after, before, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a list of previously uploaded files. + /// A value that, when provided, limits list results to files matching the corresponding purpose. + /// The cancellation token to use. + internal virtual async Task> InternalListFilesAsync(OpenAIFilePurpose? purpose = null, CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await InternalListFilesAsync(purpose?.ToString(), context).ConfigureAwait(false); + return Response.FromValue(InternalFileListResponse.FromResponse(response), response); + } + + /// Gets a list of previously uploaded files. + /// A value that, when provided, limits list results to files matching the corresponding purpose. + /// The cancellation token to use. + internal virtual Response InternalListFiles(OpenAIFilePurpose? purpose = null, CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = InternalListFiles(purpose?.ToString(), context); + return Response.FromValue(InternalFileListResponse.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets a list of previously uploaded files. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// A value that, when provided, limits list results to files matching the corresponding purpose. Allowed values: "fine-tune" | "fine-tune-results" | "assistants" | "assistants_output" | "batch" | "batch_output" | "vision". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual async Task InternalListFilesAsync(string purpose, RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalListFiles"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalListFilesRequest(purpose, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets a list of previously uploaded files. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// A value that, when provided, limits list results to files matching the corresponding purpose. Allowed values: "fine-tune" | "fine-tune-results" | "assistants" | "assistants_output" | "batch" | "batch_output" | "vision". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual Response InternalListFiles(string purpose, RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalListFiles"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalListFilesRequest(purpose, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Uploads a file for use by other operations. + /// The file data (not filename) to upload. + /// The intended purpose of the file. + /// A filename to associate with the uploaded data. + /// The cancellation token to use. + /// is null. + public virtual async Task> UploadFileAsync(Stream data, OpenAIFilePurpose purpose, string filename = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + UploadFileRequest uploadFileRequest = new UploadFileRequest(data, purpose, filename, null); + using MultipartFormDataRequestContent content = uploadFileRequest.ToMultipartRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await UploadFileAsync(content, content.ContentType, context).ConfigureAwait(false); + return Response.FromValue(OpenAIFile.FromResponse(response), response); + } + + /// Uploads a file for use by other operations. + /// The file data (not filename) to upload. + /// The intended purpose of the file. + /// A filename to associate with the uploaded data. + /// The cancellation token to use. + /// is null. + public virtual Response UploadFile(Stream data, OpenAIFilePurpose purpose, string filename = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(data, nameof(data)); + + UploadFileRequest uploadFileRequest = new UploadFileRequest(data, purpose, filename, null); + using MultipartFormDataRequestContent content = uploadFileRequest.ToMultipartRequestContent(); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = UploadFile(content, content.ContentType, context); + return Response.FromValue(OpenAIFile.FromResponse(response), response); + } + + /// + /// [Protocol Method] Uploads a file for use by other operations. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The 'content-type' header value, always 'multipart/format-data' for this operation. Allowed values: "multipart/form-data". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual async Task UploadFileAsync(RequestContent content, string contentType, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UploadFile"); + scope.Start(); + try + { + using HttpMessage message = CreateUploadFileRequest(content, contentType, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Uploads a file for use by other operations. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The 'content-type' header value, always 'multipart/format-data' for this operation. Allowed values: "multipart/form-data". + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual Response UploadFile(RequestContent content, string contentType, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UploadFile"); + scope.Start(); + try + { + using HttpMessage message = CreateUploadFileRequest(content, contentType, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Delete a previously uploaded file. + /// The ID of the file to delete. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual async Task> InternalDeleteFileAsync(string fileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await InternalDeleteFileAsync(fileId, context).ConfigureAwait(false); + return Response.FromValue(InternalFileDeletionStatus.FromResponse(response), response); + } + + /// Delete a previously uploaded file. + /// The ID of the file to delete. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + internal virtual Response InternalDeleteFile(string fileId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = InternalDeleteFile(fileId, context); + return Response.FromValue(InternalFileDeletionStatus.FromResponse(response), response); + } + + /// + /// [Protocol Method] Delete a previously uploaded file. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The ID of the file to delete. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + internal virtual async Task InternalDeleteFileAsync(string fileId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalDeleteFile"); + scope.Start(); + try + { + using HttpMessage message = CreateInternalDeleteFileRequest(fileId, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -1932,7 +2652,7 @@ internal virtual async Task InternalGetMessageFilesAsync(string thread } /// - /// [Protocol Method] Gets a list of previously uploaded files associated with a message from a thread. + /// [Protocol Method] Delete a previously uploaded file. /// /// /// @@ -1941,32 +2661,26 @@ internal virtual async Task InternalGetMessageFilesAsync(string thread /// /// /// - /// Please try the simpler convenience overload with strongly typed models first. + /// Please try the simpler convenience overload with strongly typed models first. /// /// /// /// - /// The ID of the thread containing the message to list files from. - /// The ID of the message to list files from. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + /// The ID of the file to delete. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response InternalGetMessageFiles(string threadId, string messageId, int? limit, string order, string after, string before, RequestContext context) + internal virtual Response InternalDeleteFile(string fileId, RequestContext context) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetMessageFiles"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalDeleteFile"); scope.Start(); try { - using HttpMessage message = CreateInternalGetMessageFilesRequest(threadId, messageId, limit, order, after, before, context); + using HttpMessage message = CreateInternalDeleteFileRequest(fileId, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -1976,44 +2690,36 @@ internal virtual Response InternalGetMessageFiles(string threadId, string messag } } - /// Gets information about a file attachment to a message within a thread. - /// The ID of the thread containing the message to get information from. - /// The ID of the message to get information from. - /// The ID of the file to get information about. + /// Returns information about a specific file. Does not retrieve file content. + /// The ID of the file to retrieve. /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public virtual async Task> GetMessageFileAsync(string threadId, string messageId, string fileId, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetFileAsync(string fileId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetMessageFileAsync(threadId, messageId, fileId, context).ConfigureAwait(false); - return Response.FromValue(MessageFile.FromResponse(response), response); + Response response = await GetFileAsync(fileId, context).ConfigureAwait(false); + return Response.FromValue(OpenAIFile.FromResponse(response), response); } - /// Gets information about a file attachment to a message within a thread. - /// The ID of the thread containing the message to get information from. - /// The ID of the message to get information from. - /// The ID of the file to get information about. + /// Returns information about a specific file. Does not retrieve file content. + /// The ID of the file to retrieve. /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public virtual Response GetMessageFile(string threadId, string messageId, string fileId, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetFile(string fileId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetMessageFile(threadId, messageId, fileId, context); - return Response.FromValue(MessageFile.FromResponse(response), response); + Response response = GetFile(fileId, context); + return Response.FromValue(OpenAIFile.FromResponse(response), response); } /// - /// [Protocol Method] Gets information about a file attachment to a message within a thread. + /// [Protocol Method] Returns information about a specific file. Does not retrieve file content. /// /// /// @@ -2022,25 +2728,21 @@ public virtual Response GetMessageFile(string threadId, string mess /// /// /// - /// The ID of the thread containing the message to get information from. - /// The ID of the message to get information from. - /// The ID of the file to get information about. + /// The ID of the file to retrieve. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task GetMessageFileAsync(string threadId, string messageId, string fileId, RequestContext context) + internal virtual async Task GetFileAsync(string fileId, RequestContext context) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetMessageFile"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetFile"); scope.Start(); try { - using HttpMessage message = CreateGetMessageFileRequest(threadId, messageId, fileId, context); + using HttpMessage message = CreateGetFileRequest(fileId, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -2051,7 +2753,7 @@ internal virtual async Task GetMessageFileAsync(string threadId, strin } /// - /// [Protocol Method] Gets information about a file attachment to a message within a thread. + /// [Protocol Method] Returns information about a specific file. Does not retrieve file content. /// /// /// @@ -2060,25 +2762,21 @@ internal virtual async Task GetMessageFileAsync(string threadId, strin /// /// /// - /// The ID of the thread containing the message to get information from. - /// The ID of the message to get information from. - /// The ID of the file to get information about. + /// The ID of the file to retrieve. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response GetMessageFile(string threadId, string messageId, string fileId, RequestContext context) + internal virtual Response GetFile(string fileId, RequestContext context) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(messageId, nameof(messageId)); Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetMessageFile"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetFile"); scope.Start(); try { - using HttpMessage message = CreateGetMessageFileRequest(threadId, messageId, fileId, context); + using HttpMessage message = CreateGetFileRequest(fileId, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -2088,42 +2786,36 @@ internal virtual Response GetMessageFile(string threadId, string messageId, stri } } - /// Creates a new run for an assistant thread. - /// The ID of the thread to run. - /// The details for the run to create. + /// Returns information about a specific file. Does not retrieve file content. + /// The ID of the file to retrieve. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> CreateRunAsync(string threadId, CreateRunOptions createRunOptions, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetFileContentAsync(string fileId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNull(createRunOptions, nameof(createRunOptions)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - using RequestContent content = createRunOptions.ToRequestContent(); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await CreateRunAsync(threadId, content, context).ConfigureAwait(false); - return Response.FromValue(ThreadRun.FromResponse(response), response); + Response response = await GetFileContentAsync(fileId, context).ConfigureAwait(false); + return Response.FromValue(response.Content, response); } - /// Creates a new run for an assistant thread. - /// The ID of the thread to run. - /// The details for the run to create. + /// Returns information about a specific file. Does not retrieve file content. + /// The ID of the file to retrieve. /// The cancellation token to use. - /// or is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response CreateRun(string threadId, CreateRunOptions createRunOptions, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetFileContent(string fileId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNull(createRunOptions, nameof(createRunOptions)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - using RequestContent content = createRunOptions.ToRequestContent(); RequestContext context = FromCancellationToken(cancellationToken); - Response response = CreateRun(threadId, content, context); - return Response.FromValue(ThreadRun.FromResponse(response), response); + Response response = GetFileContent(fileId, context); + return Response.FromValue(response.Content, response); } /// - /// [Protocol Method] Creates a new run for an assistant thread. + /// [Protocol Method] Returns information about a specific file. Does not retrieve file content. /// /// /// @@ -2132,23 +2824,21 @@ public virtual Response CreateRun(string threadId, CreateRunOptions c /// /// /// - /// The ID of the thread to run. - /// The content to send as the body of the request. + /// The ID of the file to retrieve. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task CreateRunAsync(string threadId, RequestContent content, RequestContext context = null) + internal virtual async Task GetFileContentAsync(string fileId, RequestContext context) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateRun"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetFileContent"); scope.Start(); try { - using HttpMessage message = CreateCreateRunRequest(threadId, content, context); + using HttpMessage message = CreateGetFileContentRequest(fileId, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -2159,7 +2849,7 @@ internal virtual async Task CreateRunAsync(string threadId, RequestCon } /// - /// [Protocol Method] Creates a new run for an assistant thread. + /// [Protocol Method] Returns information about a specific file. Does not retrieve file content. /// /// /// @@ -2168,23 +2858,21 @@ internal virtual async Task CreateRunAsync(string threadId, RequestCon /// /// /// - /// The ID of the thread to run. - /// The content to send as the body of the request. + /// The ID of the file to retrieve. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// is an empty string, and was expected to be non-empty. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response CreateRun(string threadId, RequestContent content, RequestContext context = null) + internal virtual Response GetFileContent(string fileId, RequestContext context) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateRun"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetFileContent"); scope.Start(); try { - using HttpMessage message = CreateCreateRunRequest(threadId, content, context); + using HttpMessage message = CreateGetFileContentRequest(fileId, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -2194,76 +2882,56 @@ internal virtual Response CreateRun(string threadId, RequestContent content, Req } } - /// Gets a list of runs for a specified thread. - /// The ID of the thread to list runs from. + /// Returns a list of vector stores. /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - internal virtual async Task> InternalGetRunsAsync(string threadId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + public virtual async Task> GetVectorStoresAsync(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await InternalGetRunsAsync(threadId, limit, order?.ToString(), after, before, context).ConfigureAwait(false); - return Response.FromValue(InternalOpenAIPageableListOfThreadRun.FromResponse(response), response); + Response response = await GetVectorStoresAsync(limit, order?.ToString(), after, before, context).ConfigureAwait(false); + return Response.FromValue(OpenAIPageableListOfVectorStore.FromResponse(response), response); } - /// Gets a list of runs for a specified thread. - /// The ID of the thread to list runs from. + /// Returns a list of vector stores. /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - internal virtual Response InternalGetRuns(string threadId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + public virtual Response GetVectorStores(int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = InternalGetRuns(threadId, limit, order?.ToString(), after, before, context); - return Response.FromValue(InternalOpenAIPageableListOfThreadRun.FromResponse(response), response); + Response response = GetVectorStores(limit, order?.ToString(), after, before, context); + return Response.FromValue(OpenAIPageableListOfVectorStore.FromResponse(response), response); } /// - /// [Protocol Method] Gets a list of runs for a specified thread. + /// [Protocol Method] Returns a list of vector stores. /// /// /// /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// /// /// - /// The ID of the thread to list runs from. /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task InternalGetRunsAsync(string threadId, int? limit, string order, string after, string before, RequestContext context) + internal virtual async Task GetVectorStoresAsync(int? limit, string order, string after, string before, RequestContext context) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetRuns"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetVectorStores"); scope.Start(); try { - using HttpMessage message = CreateInternalGetRunsRequest(threadId, limit, order, after, before, context); + using HttpMessage message = CreateGetVectorStoresRequest(limit, order, after, before, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -2274,39 +2942,29 @@ internal virtual async Task InternalGetRunsAsync(string threadId, int? } /// - /// [Protocol Method] Gets a list of runs for a specified thread. + /// [Protocol Method] Returns a list of vector stores. /// /// /// /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// /// /// - /// The ID of the thread to list runs from. /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response InternalGetRuns(string threadId, int? limit, string order, string after, string before, RequestContext context) + internal virtual Response GetVectorStores(int? limit, string order, string after, string before, RequestContext context) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetRuns"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetVectorStores"); scope.Start(); try { - using HttpMessage message = CreateInternalGetRunsRequest(threadId, limit, order, after, before, context); + using HttpMessage message = CreateGetVectorStoresRequest(limit, order, after, before, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -2316,40 +2974,36 @@ internal virtual Response InternalGetRuns(string threadId, int? limit, string or } } - /// Gets an existing run from an existing thread. - /// The ID of the thread to retrieve run information from. - /// The ID of the thread to retrieve information about. + /// Creates a vector store. + /// Request object for creating a vector store. /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual async Task> GetRunAsync(string threadId, string runId, CancellationToken cancellationToken = default) + /// is null. + public virtual async Task> CreateVectorStoreAsync(VectorStoreOptions body, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNull(body, nameof(body)); + using RequestContent content = body.ToRequestContent(); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetRunAsync(threadId, runId, context).ConfigureAwait(false); - return Response.FromValue(ThreadRun.FromResponse(response), response); + Response response = await CreateVectorStoreAsync(content, context).ConfigureAwait(false); + return Response.FromValue(VectorStore.FromResponse(response), response); } - /// Gets an existing run from an existing thread. - /// The ID of the thread to retrieve run information from. - /// The ID of the thread to retrieve information about. + /// Creates a vector store. + /// Request object for creating a vector store. /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual Response GetRun(string threadId, string runId, CancellationToken cancellationToken = default) + /// is null. + public virtual Response CreateVectorStore(VectorStoreOptions body, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNull(body, nameof(body)); + using RequestContent content = body.ToRequestContent(); RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetRun(threadId, runId, context); - return Response.FromValue(ThreadRun.FromResponse(response), response); + Response response = CreateVectorStore(content, context); + return Response.FromValue(VectorStore.FromResponse(response), response); } /// - /// [Protocol Method] Gets an existing run from an existing thread. + /// [Protocol Method] Creates a vector store. /// /// /// @@ -2358,23 +3012,20 @@ public virtual Response GetRun(string threadId, string runId, Cancell /// /// /// - /// The ID of the thread to retrieve run information from. - /// The ID of the thread to retrieve information about. + /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. + /// is null. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task GetRunAsync(string threadId, string runId, RequestContext context) + internal virtual async Task CreateVectorStoreAsync(RequestContent content, RequestContext context = null) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetRun"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateVectorStore"); scope.Start(); try { - using HttpMessage message = CreateGetRunRequest(threadId, runId, context); + using HttpMessage message = CreateCreateVectorStoreRequest(content, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -2385,7 +3036,7 @@ internal virtual async Task GetRunAsync(string threadId, string runId, } /// - /// [Protocol Method] Gets an existing run from an existing thread. + /// [Protocol Method] Creates a vector store. /// /// /// @@ -2394,23 +3045,20 @@ internal virtual async Task GetRunAsync(string threadId, string runId, /// /// /// - /// The ID of the thread to retrieve run information from. - /// The ID of the thread to retrieve information about. + /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. + /// is null. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response GetRun(string threadId, string runId, RequestContext context) + internal virtual Response CreateVectorStore(RequestContent content, RequestContext context = null) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetRun"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateVectorStore"); scope.Start(); try { - using HttpMessage message = CreateGetRunRequest(threadId, runId, context); + using HttpMessage message = CreateCreateVectorStoreRequest(content, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -2420,44 +3068,36 @@ internal virtual Response GetRun(string threadId, string runId, RequestContext c } } - /// Modifies an existing thread run. - /// The ID of the thread associated with the specified run. - /// The ID of the run to modify. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Returns the vector store object matching the specified ID. + /// The ID of the vector store to retrieve. /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual async Task> UpdateRunAsync(string threadId, string runId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetVectorStoreAsync(string vectorStoreId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - UpdateRunRequest updateRunRequest = new UpdateRunRequest(metadata ?? new ChangeTrackingDictionary(), null); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await UpdateRunAsync(threadId, runId, updateRunRequest.ToRequestContent(), context).ConfigureAwait(false); - return Response.FromValue(ThreadRun.FromResponse(response), response); + Response response = await GetVectorStoreAsync(vectorStoreId, context).ConfigureAwait(false); + return Response.FromValue(VectorStore.FromResponse(response), response); } - /// Modifies an existing thread run. - /// The ID of the thread associated with the specified run. - /// The ID of the run to modify. - /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Returns the vector store object matching the specified ID. + /// The ID of the vector store to retrieve. /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual Response UpdateRun(string threadId, string runId, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetVectorStore(string vectorStoreId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - UpdateRunRequest updateRunRequest = new UpdateRunRequest(metadata ?? new ChangeTrackingDictionary(), null); RequestContext context = FromCancellationToken(cancellationToken); - Response response = UpdateRun(threadId, runId, updateRunRequest.ToRequestContent(), context); - return Response.FromValue(ThreadRun.FromResponse(response), response); + Response response = GetVectorStore(vectorStoreId, context); + return Response.FromValue(VectorStore.FromResponse(response), response); } /// - /// [Protocol Method] Modifies an existing thread run. + /// [Protocol Method] Returns the vector store object matching the specified ID. /// /// /// @@ -2466,25 +3106,21 @@ public virtual Response UpdateRun(string threadId, string runId, IRea /// /// /// - /// The ID of the thread associated with the specified run. - /// The ID of the run to modify. - /// The content to send as the body of the request. + /// The ID of the vector store to retrieve. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task UpdateRunAsync(string threadId, string runId, RequestContent content, RequestContext context = null) + internal virtual async Task GetVectorStoreAsync(string vectorStoreId, RequestContext context) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateRun"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetVectorStore"); scope.Start(); try { - using HttpMessage message = CreateUpdateRunRequest(threadId, runId, content, context); + using HttpMessage message = CreateGetVectorStoreRequest(vectorStoreId, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -2495,7 +3131,7 @@ internal virtual async Task UpdateRunAsync(string threadId, string run } /// - /// [Protocol Method] Modifies an existing thread run. + /// [Protocol Method] Returns the vector store object matching the specified ID. /// /// /// @@ -2503,26 +3139,22 @@ internal virtual async Task UpdateRunAsync(string threadId, string run /// /// /// - /// - /// The ID of the thread associated with the specified run. - /// The ID of the run to modify. - /// The content to send as the body of the request. + /// + /// The ID of the vector store to retrieve. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response UpdateRun(string threadId, string runId, RequestContent content, RequestContext context = null) + internal virtual Response GetVectorStore(string vectorStoreId, RequestContext context) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UpdateRun"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetVectorStore"); scope.Start(); try { - using HttpMessage message = CreateUpdateRunRequest(threadId, runId, content, context); + using HttpMessage message = CreateGetVectorStoreRequest(vectorStoreId, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -2532,46 +3164,42 @@ internal virtual Response UpdateRun(string threadId, string runId, RequestConten } } - /// Submits outputs from tools as requested by tool calls in a run. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'. - /// The ID of the thread that was run. - /// The ID of the run that requires tool outputs. - /// The list of tool outputs requested by tool calls from the specified run. + /// The ID of the vector store to modify. + /// The ID of the vector store to modify. + /// Request object for updating a vector store. /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual async Task> SubmitToolOutputsToRunAsync(string threadId, string runId, IEnumerable toolOutputs, CancellationToken cancellationToken = default) + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> ModifyVectorStoreAsync(string vectorStoreId, VectorStoreUpdateOptions body, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - Argument.AssertNotNull(toolOutputs, nameof(toolOutputs)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(body, nameof(body)); - SubmitToolOutputsToRunRequest submitToolOutputsToRunRequest = new SubmitToolOutputsToRunRequest(toolOutputs.ToList(), null); + using RequestContent content = body.ToRequestContent(); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await SubmitToolOutputsToRunAsync(threadId, runId, submitToolOutputsToRunRequest.ToRequestContent(), context).ConfigureAwait(false); - return Response.FromValue(ThreadRun.FromResponse(response), response); + Response response = await ModifyVectorStoreAsync(vectorStoreId, content, context).ConfigureAwait(false); + return Response.FromValue(VectorStore.FromResponse(response), response); } - /// Submits outputs from tools as requested by tool calls in a run. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'. - /// The ID of the thread that was run. - /// The ID of the run that requires tool outputs. - /// The list of tool outputs requested by tool calls from the specified run. + /// The ID of the vector store to modify. + /// The ID of the vector store to modify. + /// Request object for updating a vector store. /// The cancellation token to use. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual Response SubmitToolOutputsToRun(string threadId, string runId, IEnumerable toolOutputs, CancellationToken cancellationToken = default) + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response ModifyVectorStore(string vectorStoreId, VectorStoreUpdateOptions body, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - Argument.AssertNotNull(toolOutputs, nameof(toolOutputs)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(body, nameof(body)); - SubmitToolOutputsToRunRequest submitToolOutputsToRunRequest = new SubmitToolOutputsToRunRequest(toolOutputs.ToList(), null); + using RequestContent content = body.ToRequestContent(); RequestContext context = FromCancellationToken(cancellationToken); - Response response = SubmitToolOutputsToRun(threadId, runId, submitToolOutputsToRunRequest.ToRequestContent(), context); - return Response.FromValue(ThreadRun.FromResponse(response), response); + Response response = ModifyVectorStore(vectorStoreId, content, context); + return Response.FromValue(VectorStore.FromResponse(response), response); } /// - /// [Protocol Method] Submits outputs from tools as requested by tool calls in a run. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'. + /// [Protocol Method] The ID of the vector store to modify. /// /// /// @@ -2580,25 +3208,23 @@ public virtual Response SubmitToolOutputsToRun(string threadId, strin /// /// /// - /// The ID of the thread that was run. - /// The ID of the run that requires tool outputs. + /// The ID of the vector store to modify. /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. + /// or is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task SubmitToolOutputsToRunAsync(string threadId, string runId, RequestContent content, RequestContext context = null) + internal virtual async Task ModifyVectorStoreAsync(string vectorStoreId, RequestContent content, RequestContext context = null) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.SubmitToolOutputsToRun"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.ModifyVectorStore"); scope.Start(); try { - using HttpMessage message = CreateSubmitToolOutputsToRunRequest(threadId, runId, content, context); + using HttpMessage message = CreateModifyVectorStoreRequest(vectorStoreId, content, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -2609,7 +3235,7 @@ internal virtual async Task SubmitToolOutputsToRunAsync(string threadI } /// - /// [Protocol Method] Submits outputs from tools as requested by tool calls in a run. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'. + /// [Protocol Method] The ID of the vector store to modify. /// /// /// @@ -2618,25 +3244,23 @@ internal virtual async Task SubmitToolOutputsToRunAsync(string threadI /// /// /// - /// The ID of the thread that was run. - /// The ID of the run that requires tool outputs. + /// The ID of the vector store to modify. /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// , or is null. - /// or is an empty string, and was expected to be non-empty. + /// or is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response SubmitToolOutputsToRun(string threadId, string runId, RequestContent content, RequestContext context = null) + internal virtual Response ModifyVectorStore(string vectorStoreId, RequestContent content, RequestContext context = null) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.SubmitToolOutputsToRun"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.ModifyVectorStore"); scope.Start(); try { - using HttpMessage message = CreateSubmitToolOutputsToRunRequest(threadId, runId, content, context); + using HttpMessage message = CreateModifyVectorStoreRequest(vectorStoreId, content, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -2646,40 +3270,36 @@ internal virtual Response SubmitToolOutputsToRun(string threadId, string runId, } } - /// Cancels a run of an in progress thread. - /// The ID of the thread being run. - /// The ID of the run to cancel. + /// Deletes the vector store object matching the specified ID. + /// The ID of the vector store to delete. /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual async Task> CancelRunAsync(string threadId, string runId, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> DeleteVectorStoreAsync(string vectorStoreId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await CancelRunAsync(threadId, runId, context).ConfigureAwait(false); - return Response.FromValue(ThreadRun.FromResponse(response), response); + Response response = await DeleteVectorStoreAsync(vectorStoreId, context).ConfigureAwait(false); + return Response.FromValue(VectorStoreDeletionStatus.FromResponse(response), response); } - /// Cancels a run of an in progress thread. - /// The ID of the thread being run. - /// The ID of the run to cancel. + /// Deletes the vector store object matching the specified ID. + /// The ID of the vector store to delete. /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - public virtual Response CancelRun(string threadId, string runId, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response DeleteVectorStore(string vectorStoreId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = CancelRun(threadId, runId, context); - return Response.FromValue(ThreadRun.FromResponse(response), response); + Response response = DeleteVectorStore(vectorStoreId, context); + return Response.FromValue(VectorStoreDeletionStatus.FromResponse(response), response); } /// - /// [Protocol Method] Cancels a run of an in progress thread. + /// [Protocol Method] Deletes the vector store object matching the specified ID. /// /// /// @@ -2688,23 +3308,21 @@ public virtual Response CancelRun(string threadId, string runId, Canc /// /// /// - /// The ID of the thread being run. - /// The ID of the run to cancel. + /// The ID of the vector store to delete. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task CancelRunAsync(string threadId, string runId, RequestContext context) + internal virtual async Task DeleteVectorStoreAsync(string vectorStoreId, RequestContext context) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CancelRun"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.DeleteVectorStore"); scope.Start(); try { - using HttpMessage message = CreateCancelRunRequest(threadId, runId, context); + using HttpMessage message = CreateDeleteVectorStoreRequest(vectorStoreId, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -2715,7 +3333,7 @@ internal virtual async Task CancelRunAsync(string threadId, string run } /// - /// [Protocol Method] Cancels a run of an in progress thread. + /// [Protocol Method] Deletes the vector store object matching the specified ID. /// /// /// @@ -2724,23 +3342,21 @@ internal virtual async Task CancelRunAsync(string threadId, string run /// /// /// - /// The ID of the thread being run. - /// The ID of the run to cancel. + /// The ID of the vector store to delete. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response CancelRun(string threadId, string runId, RequestContext context) + internal virtual Response DeleteVectorStore(string vectorStoreId, RequestContext context) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CancelRun"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.DeleteVectorStore"); scope.Start(); try { - using HttpMessage message = CreateCancelRunRequest(threadId, runId, context); + using HttpMessage message = CreateDeleteVectorStoreRequest(vectorStoreId, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -2750,36 +3366,46 @@ internal virtual Response CancelRun(string threadId, string runId, RequestContex } } - /// Creates a new assistant thread and immediately starts a run using that new thread. - /// Body parameter. + /// Returns a list of vector store files. + /// The ID of the vector store that the files belong to. + /// Filter by file status. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. /// The cancellation token to use. - /// is null. - public virtual async Task> CreateThreadAndRunAsync(CreateAndRunThreadOptions body, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> GetVectorStoreFilesAsync(string vectorStoreId, VectorStoreFileStatusFilter? filter = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(body, nameof(body)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - using RequestContent content = body.ToRequestContent(); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await CreateThreadAndRunAsync(content, context).ConfigureAwait(false); - return Response.FromValue(ThreadRun.FromResponse(response), response); + Response response = await GetVectorStoreFilesAsync(vectorStoreId, filter?.ToString(), limit, order?.ToString(), after, before, context).ConfigureAwait(false); + return Response.FromValue(OpenAIPageableListOfVectorStoreFile.FromResponse(response), response); } - /// Creates a new assistant thread and immediately starts a run using that new thread. - /// Body parameter. + /// Returns a list of vector store files. + /// The ID of the vector store that the files belong to. + /// Filter by file status. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. /// The cancellation token to use. - /// is null. - public virtual Response CreateThreadAndRun(CreateAndRunThreadOptions body, CancellationToken cancellationToken = default) + /// is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response GetVectorStoreFiles(string vectorStoreId, VectorStoreFileStatusFilter? filter = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(body, nameof(body)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - using RequestContent content = body.ToRequestContent(); RequestContext context = FromCancellationToken(cancellationToken); - Response response = CreateThreadAndRun(content, context); - return Response.FromValue(ThreadRun.FromResponse(response), response); + Response response = GetVectorStoreFiles(vectorStoreId, filter?.ToString(), limit, order?.ToString(), after, before, context); + return Response.FromValue(OpenAIPageableListOfVectorStoreFile.FromResponse(response), response); } /// - /// [Protocol Method] Creates a new assistant thread and immediately starts a run using that new thread. + /// [Protocol Method] Returns a list of vector store files. /// /// /// @@ -2788,20 +3414,26 @@ public virtual Response CreateThreadAndRun(CreateAndRunThreadOptions /// /// /// - /// The content to send as the body of the request. + /// The ID of the vector store that the files belong to. + /// Filter by file status. Allowed values: "in_progress" | "completed" | "failed" | "cancelled". + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task CreateThreadAndRunAsync(RequestContent content, RequestContext context = null) + internal virtual async Task GetVectorStoreFilesAsync(string vectorStoreId, string filter, int? limit, string order, string after, string before, RequestContext context) { - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateThreadAndRun"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetVectorStoreFiles"); scope.Start(); try { - using HttpMessage message = CreateCreateThreadAndRunRequest(content, context); + using HttpMessage message = CreateGetVectorStoreFilesRequest(vectorStoreId, filter, limit, order, after, before, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -2812,7 +3444,7 @@ internal virtual async Task CreateThreadAndRunAsync(RequestContent con } /// - /// [Protocol Method] Creates a new assistant thread and immediately starts a run using that new thread. + /// [Protocol Method] Returns a list of vector store files. /// /// /// @@ -2821,20 +3453,26 @@ internal virtual async Task CreateThreadAndRunAsync(RequestContent con /// /// /// - /// The content to send as the body of the request. + /// The ID of the vector store that the files belong to. + /// Filter by file status. Allowed values: "in_progress" | "completed" | "failed" | "cancelled". + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. + /// is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response CreateThreadAndRun(RequestContent content, RequestContext context = null) + internal virtual Response GetVectorStoreFiles(string vectorStoreId, string filter, int? limit, string order, string after, string before, RequestContext context) { - Argument.AssertNotNull(content, nameof(content)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateThreadAndRun"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetVectorStoreFiles"); scope.Start(); try { - using HttpMessage message = CreateCreateThreadAndRunRequest(content, context); + using HttpMessage message = CreateGetVectorStoreFilesRequest(vectorStoreId, filter, limit, order, after, before, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -2844,44 +3482,44 @@ internal virtual Response CreateThreadAndRun(RequestContent content, RequestCont } } - /// Gets a single run step from a thread run. - /// The ID of the thread that was run. - /// The ID of the specific run to retrieve the step from. - /// The ID of the step to retrieve information about. + /// Create a vector store file by attaching a file to a vector store. + /// The ID of the vector store for which to create a File. + /// A File ID that the vector store should use. Useful for tools like `file_search` that can access files. + /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public virtual async Task> GetRunStepAsync(string threadId, string runId, string stepId, CancellationToken cancellationToken = default) + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateVectorStoreFileAsync(string vectorStoreId, string fileId, VectorStoreChunkingStrategyRequest chunkingStrategy = null, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - Argument.AssertNotNullOrEmpty(stepId, nameof(stepId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(fileId, nameof(fileId)); + CreateVectorStoreFileRequest createVectorStoreFileRequest = new CreateVectorStoreFileRequest(fileId, chunkingStrategy, null); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetRunStepAsync(threadId, runId, stepId, context).ConfigureAwait(false); - return Response.FromValue(RunStep.FromResponse(response), response); + Response response = await CreateVectorStoreFileAsync(vectorStoreId, createVectorStoreFileRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(VectorStoreFile.FromResponse(response), response); } - /// Gets a single run step from a thread run. - /// The ID of the thread that was run. - /// The ID of the specific run to retrieve the step from. - /// The ID of the step to retrieve information about. + /// Create a vector store file by attaching a file to a vector store. + /// The ID of the vector store for which to create a File. + /// A File ID that the vector store should use. Useful for tools like `file_search` that can access files. + /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. /// The cancellation token to use. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. - public virtual Response GetRunStep(string threadId, string runId, string stepId, CancellationToken cancellationToken = default) + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response CreateVectorStoreFile(string vectorStoreId, string fileId, VectorStoreChunkingStrategyRequest chunkingStrategy = null, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - Argument.AssertNotNullOrEmpty(stepId, nameof(stepId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(fileId, nameof(fileId)); + CreateVectorStoreFileRequest createVectorStoreFileRequest = new CreateVectorStoreFileRequest(fileId, chunkingStrategy, null); RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetRunStep(threadId, runId, stepId, context); - return Response.FromValue(RunStep.FromResponse(response), response); + Response response = CreateVectorStoreFile(vectorStoreId, createVectorStoreFileRequest.ToRequestContent(), context); + return Response.FromValue(VectorStoreFile.FromResponse(response), response); } /// - /// [Protocol Method] Gets a single run step from a thread run. + /// [Protocol Method] Create a vector store file by attaching a file to a vector store. /// /// /// @@ -2890,25 +3528,23 @@ public virtual Response GetRunStep(string threadId, string runId, strin /// /// /// - /// The ID of the thread that was run. - /// The ID of the specific run to retrieve the step from. - /// The ID of the step to retrieve information about. + /// The ID of the vector store for which to create a File. + /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. + /// or is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task GetRunStepAsync(string threadId, string runId, string stepId, RequestContext context) + internal virtual async Task CreateVectorStoreFileAsync(string vectorStoreId, RequestContent content, RequestContext context = null) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - Argument.AssertNotNullOrEmpty(stepId, nameof(stepId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetRunStep"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateVectorStoreFile"); scope.Start(); try { - using HttpMessage message = CreateGetRunStepRequest(threadId, runId, stepId, context); + using HttpMessage message = CreateCreateVectorStoreFileRequest(vectorStoreId, content, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -2919,7 +3555,7 @@ internal virtual async Task GetRunStepAsync(string threadId, string ru } /// - /// [Protocol Method] Gets a single run step from a thread run. + /// [Protocol Method] Create a vector store file by attaching a file to a vector store. /// /// /// @@ -2928,25 +3564,23 @@ internal virtual async Task GetRunStepAsync(string threadId, string ru /// /// /// - /// The ID of the thread that was run. - /// The ID of the specific run to retrieve the step from. - /// The ID of the step to retrieve information about. + /// The ID of the vector store for which to create a File. + /// The content to send as the body of the request. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// , or is null. - /// , or is an empty string, and was expected to be non-empty. + /// or is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response GetRunStep(string threadId, string runId, string stepId, RequestContext context) + internal virtual Response CreateVectorStoreFile(string vectorStoreId, RequestContent content, RequestContext context = null) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); - Argument.AssertNotNullOrEmpty(stepId, nameof(stepId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetRunStep"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateVectorStoreFile"); scope.Start(); try { - using HttpMessage message = CreateGetRunStepRequest(threadId, runId, stepId, context); + using HttpMessage message = CreateCreateVectorStoreFileRequest(vectorStoreId, content, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -2956,82 +3590,65 @@ internal virtual Response GetRunStep(string threadId, string runId, string stepI } } - /// Gets a list of run steps from a thread run. - /// The ID of the thread that was run. - /// The ID of the run to list steps from. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + /// Retrieves a vector store file. + /// The ID of the vector store that the file belongs to. + /// The ID of the file being retrieved. /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - internal virtual async Task> InternalGetRunStepsAsync(string threadId, string runId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> GetVectorStoreFileAsync(string vectorStoreId, string fileId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await InternalGetRunStepsAsync(threadId, runId, limit, order?.ToString(), after, before, context).ConfigureAwait(false); - return Response.FromValue(InternalOpenAIPageableListOfRunStep.FromResponse(response), response); + Response response = await GetVectorStoreFileAsync(vectorStoreId, fileId, context).ConfigureAwait(false); + return Response.FromValue(VectorStoreFile.FromResponse(response), response); } - /// Gets a list of run steps from a thread run. - /// The ID of the thread that was run. - /// The ID of the run to list steps from. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + /// Retrieves a vector store file. + /// The ID of the vector store that the file belongs to. + /// The ID of the file being retrieved. /// The cancellation token to use. - /// or is null. - /// or is an empty string, and was expected to be non-empty. - internal virtual Response InternalGetRunSteps(string threadId, string runId, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response GetVectorStoreFile(string vectorStoreId, string fileId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = InternalGetRunSteps(threadId, runId, limit, order?.ToString(), after, before, context); - return Response.FromValue(InternalOpenAIPageableListOfRunStep.FromResponse(response), response); + Response response = GetVectorStoreFile(vectorStoreId, fileId, context); + return Response.FromValue(VectorStoreFile.FromResponse(response), response); } /// - /// [Protocol Method] Gets a list of run steps from a thread run. + /// [Protocol Method] Retrieves a vector store file. /// /// /// /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// /// /// - /// The ID of the thread that was run. - /// The ID of the run to list steps from. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + /// The ID of the vector store that the file belongs to. + /// The ID of the file being retrieved. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. + /// or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task InternalGetRunStepsAsync(string threadId, string runId, int? limit, string order, string after, string before, RequestContext context) + internal virtual async Task GetVectorStoreFileAsync(string vectorStoreId, string fileId, RequestContext context) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetRunSteps"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetVectorStoreFile"); scope.Start(); try { - using HttpMessage message = CreateInternalGetRunStepsRequest(threadId, runId, limit, order, after, before, context); + using HttpMessage message = CreateGetVectorStoreFileRequest(vectorStoreId, fileId, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -3042,41 +3659,32 @@ internal virtual async Task InternalGetRunStepsAsync(string threadId, } /// - /// [Protocol Method] Gets a list of run steps from a thread run. + /// [Protocol Method] Retrieves a vector store file. /// /// /// /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// /// /// - /// The ID of the thread that was run. - /// The ID of the run to list steps from. - /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". - /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. - /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. + /// The ID of the vector store that the file belongs to. + /// The ID of the file being retrieved. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// or is null. - /// or is an empty string, and was expected to be non-empty. + /// or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response InternalGetRunSteps(string threadId, string runId, int? limit, string order, string after, string before, RequestContext context) + internal virtual Response GetVectorStoreFile(string vectorStoreId, string fileId, RequestContext context) { - Argument.AssertNotNullOrEmpty(threadId, nameof(threadId)); - Argument.AssertNotNullOrEmpty(runId, nameof(runId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalGetRunSteps"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetVectorStoreFile"); scope.Start(); try { - using HttpMessage message = CreateInternalGetRunStepsRequest(threadId, runId, limit, order, after, before, context); + using HttpMessage message = CreateGetVectorStoreFileRequest(vectorStoreId, fileId, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -3086,52 +3694,72 @@ internal virtual Response InternalGetRunSteps(string threadId, string runId, int } } - /// Gets a list of previously uploaded files. - /// A value that, when provided, limits list results to files matching the corresponding purpose. + /// + /// Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. + /// To delete the file, use the delete file endpoint. + /// + /// The ID of the vector store that the file belongs to. + /// The ID of the file to delete its relationship to the vector store. /// The cancellation token to use. - internal virtual async Task> InternalListFilesAsync(OpenAIFilePurpose? purpose = null, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> DeleteVectorStoreFileAsync(string vectorStoreId, string fileId, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + RequestContext context = FromCancellationToken(cancellationToken); - Response response = await InternalListFilesAsync(purpose?.ToString(), context).ConfigureAwait(false); - return Response.FromValue(InternalFileListResponse.FromResponse(response), response); + Response response = await DeleteVectorStoreFileAsync(vectorStoreId, fileId, context).ConfigureAwait(false); + return Response.FromValue(VectorStoreFileDeletionStatus.FromResponse(response), response); } - /// Gets a list of previously uploaded files. - /// A value that, when provided, limits list results to files matching the corresponding purpose. + /// + /// Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. + /// To delete the file, use the delete file endpoint. + /// + /// The ID of the vector store that the file belongs to. + /// The ID of the file to delete its relationship to the vector store. /// The cancellation token to use. - internal virtual Response InternalListFiles(OpenAIFilePurpose? purpose = null, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response DeleteVectorStoreFile(string vectorStoreId, string fileId, CancellationToken cancellationToken = default) { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + RequestContext context = FromCancellationToken(cancellationToken); - Response response = InternalListFiles(purpose?.ToString(), context); - return Response.FromValue(InternalFileListResponse.FromResponse(response), response); + Response response = DeleteVectorStoreFile(vectorStoreId, fileId, context); + return Response.FromValue(VectorStoreFileDeletionStatus.FromResponse(response), response); } /// - /// [Protocol Method] Gets a list of previously uploaded files. + /// [Protocol Method] Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. + /// To delete the file, use the delete file endpoint. /// /// /// /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// /// /// - /// A value that, when provided, limits list results to files matching the corresponding purpose. Allowed values: "fine-tune" | "fine-tune-results" | "assistants" | "assistants_output". + /// The ID of the vector store that the file belongs to. + /// The ID of the file to delete its relationship to the vector store. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task InternalListFilesAsync(string purpose, RequestContext context) + internal virtual async Task DeleteVectorStoreFileAsync(string vectorStoreId, string fileId, RequestContext context) { - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalListFiles"); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.DeleteVectorStoreFile"); scope.Start(); try { - using HttpMessage message = CreateInternalListFilesRequest(purpose, context); + using HttpMessage message = CreateDeleteVectorStoreFileRequest(vectorStoreId, fileId, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -3142,31 +3770,33 @@ internal virtual async Task InternalListFilesAsync(string purpose, Req } /// - /// [Protocol Method] Gets a list of previously uploaded files. + /// [Protocol Method] Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. + /// To delete the file, use the delete file endpoint. /// /// /// /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// /// /// - /// A value that, when provided, limits list results to files matching the corresponding purpose. Allowed values: "fine-tune" | "fine-tune-results" | "assistants" | "assistants_output". + /// The ID of the vector store that the file belongs to. + /// The ID of the file to delete its relationship to the vector store. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response InternalListFiles(string purpose, RequestContext context) + internal virtual Response DeleteVectorStoreFile(string vectorStoreId, string fileId, RequestContext context) { - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalListFiles"); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.DeleteVectorStoreFile"); scope.Start(); try { - using HttpMessage message = CreateInternalListFilesRequest(purpose, context); + using HttpMessage message = CreateDeleteVectorStoreFileRequest(vectorStoreId, fileId, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -3176,42 +3806,44 @@ internal virtual Response InternalListFiles(string purpose, RequestContext conte } } - /// Uploads a file for use by other operations. - /// The file data (not filename) to upload. - /// The intended purpose of the file. - /// A filename to associate with the uploaded data. + /// Create a vector store file batch. + /// The ID of the vector store for which to create a File Batch. + /// A list of File IDs that the vector store should use. Useful for tools like `file_search` that can access files. + /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. /// The cancellation token to use. - /// is null. - public virtual async Task> UploadFileAsync(Stream data, OpenAIFilePurpose purpose, string filename = null, CancellationToken cancellationToken = default) + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual async Task> CreateVectorStoreFileBatchAsync(string vectorStoreId, IEnumerable fileIds, VectorStoreChunkingStrategyRequest chunkingStrategy = null, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(fileIds, nameof(fileIds)); - UploadFileRequest uploadFileRequest = new UploadFileRequest(data, purpose, filename, null); - using MultipartFormDataRequestContent content = uploadFileRequest.ToMultipartRequestContent(); + CreateVectorStoreFileBatchRequest createVectorStoreFileBatchRequest = new CreateVectorStoreFileBatchRequest(fileIds.ToList(), chunkingStrategy, null); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await UploadFileAsync(content, content.ContentType, context).ConfigureAwait(false); - return Response.FromValue(OpenAIFile.FromResponse(response), response); + Response response = await CreateVectorStoreFileBatchAsync(vectorStoreId, createVectorStoreFileBatchRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response); } - /// Uploads a file for use by other operations. - /// The file data (not filename) to upload. - /// The intended purpose of the file. - /// A filename to associate with the uploaded data. + /// Create a vector store file batch. + /// The ID of the vector store for which to create a File Batch. + /// A list of File IDs that the vector store should use. Useful for tools like `file_search` that can access files. + /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. /// The cancellation token to use. - /// is null. - public virtual Response UploadFile(Stream data, OpenAIFilePurpose purpose, string filename = null, CancellationToken cancellationToken = default) + /// or is null. + /// is an empty string, and was expected to be non-empty. + public virtual Response CreateVectorStoreFileBatch(string vectorStoreId, IEnumerable fileIds, VectorStoreChunkingStrategyRequest chunkingStrategy = null, CancellationToken cancellationToken = default) { - Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(fileIds, nameof(fileIds)); - UploadFileRequest uploadFileRequest = new UploadFileRequest(data, purpose, filename, null); - using MultipartFormDataRequestContent content = uploadFileRequest.ToMultipartRequestContent(); + CreateVectorStoreFileBatchRequest createVectorStoreFileBatchRequest = new CreateVectorStoreFileBatchRequest(fileIds.ToList(), chunkingStrategy, null); RequestContext context = FromCancellationToken(cancellationToken); - Response response = UploadFile(content, content.ContentType, context); - return Response.FromValue(OpenAIFile.FromResponse(response), response); + Response response = CreateVectorStoreFileBatch(vectorStoreId, createVectorStoreFileBatchRequest.ToRequestContent(), context); + return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response); } /// - /// [Protocol Method] Uploads a file for use by other operations. + /// [Protocol Method] Create a vector store file batch. /// /// /// @@ -3220,21 +3852,23 @@ public virtual Response UploadFile(Stream data, OpenAIFilePurpose pu /// /// /// + /// The ID of the vector store for which to create a File Batch. /// The content to send as the body of the request. - /// The 'content-type' header value, always 'multipart/format-data' for this operation. Allowed values: "multipart/form-data". /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. + /// or is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task UploadFileAsync(RequestContent content, string contentType, RequestContext context = null) + internal virtual async Task CreateVectorStoreFileBatchAsync(string vectorStoreId, RequestContent content, RequestContext context = null) { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UploadFile"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateVectorStoreFileBatch"); scope.Start(); try { - using HttpMessage message = CreateUploadFileRequest(content, contentType, context); + using HttpMessage message = CreateCreateVectorStoreFileBatchRequest(vectorStoreId, content, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -3245,7 +3879,7 @@ internal virtual async Task UploadFileAsync(RequestContent content, st } /// - /// [Protocol Method] Uploads a file for use by other operations. + /// [Protocol Method] Create a vector store file batch. /// /// /// @@ -3254,21 +3888,23 @@ internal virtual async Task UploadFileAsync(RequestContent content, st /// /// /// + /// The ID of the vector store for which to create a File Batch. /// The content to send as the body of the request. - /// The 'content-type' header value, always 'multipart/format-data' for this operation. Allowed values: "multipart/form-data". /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. + /// or is null. + /// is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response UploadFile(RequestContent content, string contentType, RequestContext context = null) + internal virtual Response CreateVectorStoreFileBatch(string vectorStoreId, RequestContent content, RequestContext context = null) { + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); Argument.AssertNotNull(content, nameof(content)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.UploadFile"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CreateVectorStoreFileBatch"); scope.Start(); try { - using HttpMessage message = CreateUploadFileRequest(content, contentType, context); + using HttpMessage message = CreateCreateVectorStoreFileBatchRequest(vectorStoreId, content, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -3278,64 +3914,65 @@ internal virtual Response UploadFile(RequestContent content, string contentType, } } - /// Delete a previously uploaded file. - /// The ID of the file to delete. + /// Retrieve a vector store file batch. + /// The ID of the vector store that the file batch belongs to. + /// The ID of the file batch being retrieved. /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - internal virtual async Task> InternalDeleteFileAsync(string fileId, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> GetVectorStoreFileBatchAsync(string vectorStoreId, string batchId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await InternalDeleteFileAsync(fileId, context).ConfigureAwait(false); - return Response.FromValue(InternalFileDeletionStatus.FromResponse(response), response); + Response response = await GetVectorStoreFileBatchAsync(vectorStoreId, batchId, context).ConfigureAwait(false); + return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response); } - /// Delete a previously uploaded file. - /// The ID of the file to delete. + /// Retrieve a vector store file batch. + /// The ID of the vector store that the file batch belongs to. + /// The ID of the file batch being retrieved. /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - internal virtual Response InternalDeleteFile(string fileId, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response GetVectorStoreFileBatch(string vectorStoreId, string batchId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = InternalDeleteFile(fileId, context); - return Response.FromValue(InternalFileDeletionStatus.FromResponse(response), response); + Response response = GetVectorStoreFileBatch(vectorStoreId, batchId, context); + return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response); } /// - /// [Protocol Method] Delete a previously uploaded file. + /// [Protocol Method] Retrieve a vector store file batch. /// /// /// /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// /// /// - /// The ID of the file to delete. + /// The ID of the vector store that the file batch belongs to. + /// The ID of the file batch being retrieved. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. + /// or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task InternalDeleteFileAsync(string fileId, RequestContext context) + internal virtual async Task GetVectorStoreFileBatchAsync(string vectorStoreId, string batchId, RequestContext context) { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalDeleteFile"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetVectorStoreFileBatch"); scope.Start(); try { - using HttpMessage message = CreateInternalDeleteFileRequest(fileId, context); + using HttpMessage message = CreateGetVectorStoreFileBatchRequest(vectorStoreId, batchId, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -3346,35 +3983,32 @@ internal virtual async Task InternalDeleteFileAsync(string fileId, Req } /// - /// [Protocol Method] Delete a previously uploaded file. + /// [Protocol Method] Retrieve a vector store file batch. /// /// /// /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. /// /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// /// /// - /// The ID of the file to delete. + /// The ID of the vector store that the file batch belongs to. + /// The ID of the file batch being retrieved. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. + /// or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response InternalDeleteFile(string fileId, RequestContext context) + internal virtual Response GetVectorStoreFileBatch(string vectorStoreId, string batchId, RequestContext context) { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.InternalDeleteFile"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetVectorStoreFileBatch"); scope.Start(); try { - using HttpMessage message = CreateInternalDeleteFileRequest(fileId, context); + using HttpMessage message = CreateGetVectorStoreFileBatchRequest(vectorStoreId, batchId, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -3384,36 +4018,40 @@ internal virtual Response InternalDeleteFile(string fileId, RequestContext conte } } - /// Returns information about a specific file. Does not retrieve file content. - /// The ID of the file to retrieve. + /// Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. + /// The ID of the vector store that the file batch belongs to. + /// The ID of the file batch to cancel. /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> GetFileAsync(string fileId, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> CancelVectorStoreFileBatchAsync(string vectorStoreId, string batchId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetFileAsync(fileId, context).ConfigureAwait(false); - return Response.FromValue(OpenAIFile.FromResponse(response), response); + Response response = await CancelVectorStoreFileBatchAsync(vectorStoreId, batchId, context).ConfigureAwait(false); + return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response); } - /// Returns information about a specific file. Does not retrieve file content. - /// The ID of the file to retrieve. + /// Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. + /// The ID of the vector store that the file batch belongs to. + /// The ID of the file batch to cancel. /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response GetFile(string fileId, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response CancelVectorStoreFileBatch(string vectorStoreId, string batchId, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetFile(fileId, context); - return Response.FromValue(OpenAIFile.FromResponse(response), response); + Response response = CancelVectorStoreFileBatch(vectorStoreId, batchId, context); + return Response.FromValue(VectorStoreFileBatch.FromResponse(response), response); } /// - /// [Protocol Method] Returns information about a specific file. Does not retrieve file content. + /// [Protocol Method] Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. /// /// /// @@ -3422,21 +4060,23 @@ public virtual Response GetFile(string fileId, CancellationToken can /// /// /// - /// The ID of the file to retrieve. + /// The ID of the vector store that the file batch belongs to. + /// The ID of the file batch to cancel. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. + /// or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task GetFileAsync(string fileId, RequestContext context) + internal virtual async Task CancelVectorStoreFileBatchAsync(string vectorStoreId, string batchId, RequestContext context) { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetFile"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CancelVectorStoreFileBatch"); scope.Start(); try { - using HttpMessage message = CreateGetFileRequest(fileId, context); + using HttpMessage message = CreateCancelVectorStoreFileBatchRequest(vectorStoreId, batchId, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -3447,7 +4087,7 @@ internal virtual async Task GetFileAsync(string fileId, RequestContext } /// - /// [Protocol Method] Returns information about a specific file. Does not retrieve file content. + /// [Protocol Method] Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. /// /// /// @@ -3456,21 +4096,23 @@ internal virtual async Task GetFileAsync(string fileId, RequestContext /// /// /// - /// The ID of the file to retrieve. + /// The ID of the vector store that the file batch belongs to. + /// The ID of the file batch to cancel. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. + /// or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response GetFile(string fileId, RequestContext context) + internal virtual Response CancelVectorStoreFileBatch(string vectorStoreId, string batchId, RequestContext context) { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetFile"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.CancelVectorStoreFileBatch"); scope.Start(); try { - using HttpMessage message = CreateGetFileRequest(fileId, context); + using HttpMessage message = CreateCancelVectorStoreFileBatchRequest(vectorStoreId, batchId, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -3480,36 +4122,50 @@ internal virtual Response GetFile(string fileId, RequestContext context) } } - /// Returns information about a specific file. Does not retrieve file content. - /// The ID of the file to retrieve. + /// Returns a list of vector store files in a batch. + /// The ID of the vector store that the file batch belongs to. + /// The ID of the file batch that the files belong to. + /// Filter by file status. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual async Task> GetFileContentAsync(string fileId, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual async Task> GetVectorStoreFileBatchFilesAsync(string vectorStoreId, string batchId, VectorStoreFileStatusFilter? filter = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetFileContentAsync(fileId, context).ConfigureAwait(false); - return Response.FromValue(response.Content, response); + Response response = await GetVectorStoreFileBatchFilesAsync(vectorStoreId, batchId, filter?.ToString(), limit, order?.ToString(), after, before, context).ConfigureAwait(false); + return Response.FromValue(OpenAIPageableListOfVectorStoreFile.FromResponse(response), response); } - /// Returns information about a specific file. Does not retrieve file content. - /// The ID of the file to retrieve. + /// Returns a list of vector store files in a batch. + /// The ID of the vector store that the file batch belongs to. + /// The ID of the file batch that the files belong to. + /// Filter by file status. + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. /// The cancellation token to use. - /// is null. - /// is an empty string, and was expected to be non-empty. - public virtual Response GetFileContent(string fileId, CancellationToken cancellationToken = default) + /// or is null. + /// or is an empty string, and was expected to be non-empty. + public virtual Response GetVectorStoreFileBatchFiles(string vectorStoreId, string batchId, VectorStoreFileStatusFilter? filter = null, int? limit = null, ListSortOrder? order = null, string after = null, string before = null, CancellationToken cancellationToken = default) { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetFileContent(fileId, context); - return Response.FromValue(response.Content, response); + Response response = GetVectorStoreFileBatchFiles(vectorStoreId, batchId, filter?.ToString(), limit, order?.ToString(), after, before, context); + return Response.FromValue(OpenAIPageableListOfVectorStoreFile.FromResponse(response), response); } /// - /// [Protocol Method] Returns information about a specific file. Does not retrieve file content. + /// [Protocol Method] Returns a list of vector store files in a batch. /// /// /// @@ -3518,21 +4174,28 @@ public virtual Response GetFileContent(string fileId, CancellationTo /// /// /// - /// The ID of the file to retrieve. + /// The ID of the vector store that the file batch belongs to. + /// The ID of the file batch that the files belong to. + /// Filter by file status. Allowed values: "in_progress" | "completed" | "failed" | "cancelled". + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. + /// or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual async Task GetFileContentAsync(string fileId, RequestContext context) + internal virtual async Task GetVectorStoreFileBatchFilesAsync(string vectorStoreId, string batchId, string filter, int? limit, string order, string after, string before, RequestContext context) { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetFileContent"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetVectorStoreFileBatchFiles"); scope.Start(); try { - using HttpMessage message = CreateGetFileContentRequest(fileId, context); + using HttpMessage message = CreateGetVectorStoreFileBatchFilesRequest(vectorStoreId, batchId, filter, limit, order, after, before, context); return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); } catch (Exception e) @@ -3543,7 +4206,7 @@ internal virtual async Task GetFileContentAsync(string fileId, Request } /// - /// [Protocol Method] Returns information about a specific file. Does not retrieve file content. + /// [Protocol Method] Returns a list of vector store files in a batch. /// /// /// @@ -3552,21 +4215,28 @@ internal virtual async Task GetFileContentAsync(string fileId, Request /// /// /// - /// The ID of the file to retrieve. + /// The ID of the vector store that the file batch belongs to. + /// The ID of the file batch that the files belong to. + /// Filter by file status. Allowed values: "in_progress" | "completed" | "failed" | "cancelled". + /// A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. + /// Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. Allowed values: "asc" | "desc". + /// A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. + /// A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// is an empty string, and was expected to be non-empty. + /// or is null. + /// or is an empty string, and was expected to be non-empty. /// Service returned a non-success status code. /// The response returned from the service. - internal virtual Response GetFileContent(string fileId, RequestContext context) + internal virtual Response GetVectorStoreFileBatchFiles(string vectorStoreId, string batchId, string filter, int? limit, string order, string after, string before, RequestContext context) { - Argument.AssertNotNullOrEmpty(fileId, nameof(fileId)); + Argument.AssertNotNullOrEmpty(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNullOrEmpty(batchId, nameof(batchId)); - using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetFileContent"); + using var scope = ClientDiagnostics.CreateScope("AssistantsClient.GetVectorStoreFileBatchFiles"); scope.Start(); try { - using HttpMessage message = CreateGetFileContentRequest(fileId, context); + using HttpMessage message = CreateGetVectorStoreFileBatchFilesRequest(vectorStoreId, batchId, filter, limit, order, after, before, context); return _pipeline.ProcessMessage(message, context); } catch (Exception e) @@ -3576,6 +4246,300 @@ internal virtual Response GetFileContent(string fileId, RequestContext context) } } + internal HttpMessage CreateInternalGetMessagesRequest(string threadId, string runId, int? limit, string order, string after, string before, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/threads/", false); + uri.AppendPath(threadId, true); + uri.AppendPath("/messages", false); + if (runId != null) + { + uri.AppendQuery("runId", runId, true); + } + if (limit != null) + { + uri.AppendQuery("limit", limit.Value, true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetVectorStoresRequest(int? limit, string order, string after, string before, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores", false); + if (limit != null) + { + uri.AppendQuery("limit", limit.Value, true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateVectorStoreRequest(RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores", false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetVectorStoreRequest(string vectorStoreId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateModifyVectorStoreRequest(string vectorStoreId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteVectorStoreRequest(string vectorStoreId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetVectorStoreFilesRequest(string vectorStoreId, string filter, int? limit, string order, string after, string before, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/files", false); + if (filter != null) + { + uri.AppendQuery("filter", filter, true); + } + if (limit != null) + { + uri.AppendQuery("limit", limit.Value, true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateVectorStoreFileRequest(string vectorStoreId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/files", false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetVectorStoreFileRequest(string vectorStoreId, string fileId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/files/", false); + uri.AppendPath(fileId, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateDeleteVectorStoreFileRequest(string vectorStoreId, string fileId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/files/", false); + uri.AppendPath(fileId, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateVectorStoreFileBatchRequest(string vectorStoreId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/file_batches", false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetVectorStoreFileBatchRequest(string vectorStoreId, string batchId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/file_batches/", false); + uri.AppendPath(batchId, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCancelVectorStoreFileBatchRequest(string vectorStoreId, string batchId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/file_batches/", false); + uri.AppendPath(batchId, true); + uri.AppendPath("/cancel", false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetVectorStoreFileBatchFilesRequest(string vectorStoreId, string batchId, string filter, int? limit, string order, string after, string before, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/vector_stores/", false); + uri.AppendPath(vectorStoreId, true); + uri.AppendPath("/file_batches/", false); + uri.AppendPath(batchId, true); + uri.AppendPath("/files", false); + if (filter != null) + { + uri.AppendQuery("filter", filter, true); + } + if (limit != null) + { + uri.AppendQuery("limit", limit.Value, true); + } + if (order != null) + { + uri.AppendQuery("order", order, true); + } + if (after != null) + { + uri.AppendQuery("after", after, true); + } + if (before != null) + { + uri.AppendQuery("before", before, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + private static RequestContext DefaultRequestContext = new RequestContext(); internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) { diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClientOptions.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClientOptions.cs index a847db2052bd..c1e990e8d816 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClientOptions.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsClientOptions.cs @@ -13,13 +13,17 @@ namespace Azure.AI.OpenAI.Assistants /// Client options for AssistantsClient. public partial class AssistantsClientOptions : ClientOptions { - private const ServiceVersion LatestVersion = ServiceVersion.V2024_02_15_Preview; + private const ServiceVersion LatestVersion = ServiceVersion.V2024_07_01_Preview; /// The version of the service to use. public enum ServiceVersion { /// Service version "2024-02-15-preview". V2024_02_15_Preview = 1, + /// Service version "2024-05-01-preview". + V2024_05_01_Preview = 2, + /// Service version "2024-07-01-preview". + V2024_07_01_Preview = 3, } internal string Version { get; } @@ -30,6 +34,8 @@ public AssistantsClientOptions(ServiceVersion version = LatestVersion) Version = version switch { ServiceVersion.V2024_02_15_Preview => "2024-02-15-preview", + ServiceVersion.V2024_05_01_Preview => "2024-05-01-preview", + ServiceVersion.V2024_07_01_Preview => "2024-07-01-preview", _ => throw new NotSupportedException() }; } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsModelFactory.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsModelFactory.cs index 8b4620e1331e..d98912fc5b4f 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsModelFactory.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsModelFactory.cs @@ -5,6 +5,7 @@ #nullable disable +using System; using System.Collections.Generic; using System.Linq; @@ -21,15 +22,28 @@ public static partial class AssistantsModelFactory /// /// The collection of tools to enable for the new assistant. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . /// - /// A list of previously uploaded file IDs to attach to the assistant. + /// + /// A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, the `code_interpreter` + /// tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + /// + /// + /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, + /// while lower values like 0.2 will make it more focused and deterministic. + /// + /// + /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. + /// So 0.1 means only the tokens comprising the top 10% probability mass are considered. + /// + /// We generally recommend altering this or temperature but not both. + /// + /// The response format of the tool calls used by this assistant. /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// A new instance for mocking. - public static AssistantCreationOptions AssistantCreationOptions(string model = null, string name = null, string description = null, string instructions = null, IEnumerable tools = null, IEnumerable fileIds = null, IDictionary metadata = null) + public static AssistantCreationOptions AssistantCreationOptions(string model = null, string name = null, string description = null, string instructions = null, IEnumerable tools = null, CreateToolResourcesOptions toolResources = null, float? temperature = null, float? topP = null, BinaryData responseFormat = null, IDictionary metadata = null) { tools ??= new List(); - fileIds ??= new List(); metadata ??= new Dictionary(); return new AssistantCreationOptions( @@ -38,37 +52,94 @@ public static AssistantCreationOptions AssistantCreationOptions(string model = n description, instructions, tools?.ToList(), - fileIds?.ToList(), + toolResources, + temperature, + topP, + responseFormat, metadata, serializedAdditionalRawData: null); } - /// Initializes a new instance of . - /// The role associated with the assistant thread message. Currently, only 'user' is supported when providing initial messages to a new thread. - /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via a separate call to the create message API. - /// - /// A list of file IDs that the assistant should use. Useful for tools like retrieval and code_interpreter that can - /// access files. + /// Initializes a new instance of . + /// A list of file IDs to add to the vector store. There can be a maximum of 10000 files in a vector store. + /// + /// The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . /// /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// A new instance for mocking. - public static ThreadInitializationMessage ThreadInitializationMessage(MessageRole role = default, string content = null, IEnumerable fileIds = null, IDictionary metadata = null) + /// A new instance for mocking. + public static CreateFileSearchToolResourceVectorStoreOptions CreateFileSearchToolResourceVectorStoreOptions(IEnumerable fileIds = null, VectorStoreChunkingStrategyRequest chunkingStrategy = null, IDictionary metadata = null) { fileIds ??= new List(); metadata ??= new Dictionary(); - return new ThreadInitializationMessage(role, content, fileIds?.ToList(), metadata, serializedAdditionalRawData: null); + return new CreateFileSearchToolResourceVectorStoreOptions(fileIds?.ToList(), chunkingStrategy, metadata, serializedAdditionalRawData: null); } - /// Initializes a new instance of . - /// The object type. - /// The textual content associated with this text annotation item. - /// The first text index associated with this text annotation. - /// The last text index associated with this text annotation. - /// A new instance for mocking. - public static MessageTextAnnotation MessageTextAnnotation(string type = null, string text = null, int startIndex = default, int endIndex = default) + /// Initializes a new instance of . + /// The options for the static chunking strategy. + /// A new instance for mocking. + public static VectorStoreStaticChunkingStrategyRequest VectorStoreStaticChunkingStrategyRequest(VectorStoreStaticChunkingStrategyOptions @static = null) + { + return new VectorStoreStaticChunkingStrategyRequest(VectorStoreChunkingStrategyRequestType.Static, serializedAdditionalRawData: null, @static); + } + + /// Initializes a new instance of . + /// Resources to be used by the `code_interpreter tool` consisting of file IDs. + /// Resources to be used by the `file_search` tool consisting of vector store IDs. + /// A new instance for mocking. + public static ToolResources ToolResources(CodeInterpreterToolResource codeInterpreter = null, FileSearchToolResource fileSearch = null) + { + return new ToolResources(codeInterpreter, fileSearch, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files + /// associated with the tool. + /// + /// A new instance for mocking. + public static CodeInterpreterToolResource CodeInterpreterToolResource(IEnumerable fileIds = null) + { + fileIds ??= new List(); + + return new CodeInterpreterToolResource(fileIds?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// The ID of the vector store attached to this assistant. There can be a maximum of 1 vector + /// store attached to the assistant. + /// + /// A new instance for mocking. + public static FileSearchToolResource FileSearchToolResource(IEnumerable vectorStoreIds = null) + { + vectorStoreIds ??= new List(); + + return new FileSearchToolResource(vectorStoreIds?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// The role of the entity that is creating the message. Allowed values include: + /// - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages. + /// - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into + /// the conversation. + /// + /// + /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via + /// a separate call to the create message API. + /// + /// A list of files attached to the message, and the tools they should be added to. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// A new instance for mocking. + public static ThreadMessageOptions ThreadMessageOptions(MessageRole role = default, string content = null, IEnumerable attachments = null, IDictionary metadata = null) { - return new UnknownMessageTextAnnotation(type, text, startIndex, endIndex, serializedAdditionalRawData: null); + attachments ??= new List(); + metadata ??= new Dictionary(); + + return new ThreadMessageOptions(role, content, attachments?.ToList(), metadata, serializedAdditionalRawData: null); } /// Initializes a new instance of . @@ -79,15 +150,45 @@ public static MessageTextAnnotation MessageTextAnnotation(string type = null, st /// Additional instructions to append at the end of the instructions for the run. This is useful for modifying the behavior /// on a per-run basis without overriding other instructions. /// + /// Adds additional messages to the thread before creating the run. /// /// The overridden list of enabled tools that the assistant should use to run the thread. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . /// + /// + /// If `true`, returns a stream of events that happen during the Run as server-sent events, + /// terminating when the Run enters a terminal state with a `data: [DONE]` message. + /// + /// + /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output + /// more random, while lower values like 0.2 will make it more focused and deterministic. + /// + /// + /// An alternative to sampling with temperature, called nucleus sampling, where the model + /// considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + /// comprising the top 10% probability mass are considered. + /// + /// We generally recommend altering this or temperature but not both. + /// + /// + /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, + /// the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + /// + /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort + /// to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of + /// completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + /// The strategy to use for dropping messages as the context windows moves forward. + /// Controls whether or not and which tool is called by the model. + /// Specifies the format that the model must output. /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// A new instance for mocking. - public static CreateRunOptions CreateRunOptions(string assistantId = null, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, IEnumerable overrideTools = null, IDictionary metadata = null) + public static CreateRunOptions CreateRunOptions(string assistantId = null, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, IEnumerable additionalMessages = null, IEnumerable overrideTools = null, bool? stream = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, TruncationObject truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, IDictionary metadata = null) { + additionalMessages ??= new List(); overrideTools ??= new List(); metadata ??= new Dictionary(); @@ -96,7 +197,16 @@ public static CreateRunOptions CreateRunOptions(string assistantId = null, strin overrideModelName, overrideInstructions, additionalInstructions, + additionalMessages?.ToList(), overrideTools?.ToList(), + stream, + temperature, + topP, + maxPromptTokens, + maxCompletionTokens, + truncationStrategy, + toolChoice, + responseFormat, metadata, serializedAdditionalRawData: null); } @@ -119,19 +229,58 @@ public static RunError RunError(string code = null, string message = null) return new RunError(code, message, serializedAdditionalRawData: null); } + /// Initializes a new instance of . + /// Number of completion tokens used over the course of the run. + /// Number of prompt tokens used over the course of the run. + /// Total number of tokens used (prompt + completion). + /// A new instance for mocking. + public static RunCompletionUsage RunCompletionUsage(long completionTokens = default, long promptTokens = default, long totalTokens = default) + { + return new RunCompletionUsage(completionTokens, promptTokens, totalTokens, serializedAdditionalRawData: null); + } + /// Initializes a new instance of . /// The ID of the assistant for which the thread should be created. - /// The details used to create the new thread. + /// The details used to create the new thread. If no thread is provided, an empty one will be created. /// The overridden model that the assistant should use to run the thread. /// The overridden system instructions the assistant should use to run the thread. /// /// The overridden list of enabled tools the assistant should use to run the thread. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . + /// + /// Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. + /// + /// If `true`, returns a stream of events that happen during the Run as server-sent events, + /// terminating when the Run enters a terminal state with a `data: [DONE]` message. + /// + /// + /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output + /// more random, while lower values like 0.2 will make it more focused and deterministic. + /// + /// + /// An alternative to sampling with temperature, called nucleus sampling, where the model + /// considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + /// comprising the top 10% probability mass are considered. + /// + /// We generally recommend altering this or temperature but not both. + /// + /// + /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, + /// the run will end with status `incomplete`. See `incomplete_details` for more info. /// + /// + /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens + /// specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + /// The strategy to use for dropping messages as the context windows moves forward. + /// Controls whether or not and which tool is called by the model. + /// Specifies the format that the model must output. /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// A new instance for mocking. - public static CreateAndRunThreadOptions CreateAndRunThreadOptions(string assistantId = null, AssistantThreadCreationOptions thread = null, string overrideModelName = null, string overrideInstructions = null, IEnumerable overrideTools = null, IDictionary metadata = null) + public static CreateAndRunThreadOptions CreateAndRunThreadOptions(string assistantId = null, AssistantThreadCreationOptions thread = null, string overrideModelName = null, string overrideInstructions = null, IEnumerable overrideTools = null, UpdateToolResourcesOptions toolResources = null, bool? stream = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, TruncationObject truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, IDictionary metadata = null) { overrideTools ??= new List(); metadata ??= new Dictionary(); @@ -142,6 +291,15 @@ public static CreateAndRunThreadOptions CreateAndRunThreadOptions(string assista overrideModelName, overrideInstructions, overrideTools?.ToList(), + toolResources, + stream, + temperature, + topP, + maxPromptTokens, + maxCompletionTokens, + truncationStrategy, + toolChoice, + responseFormat, metadata, serializedAdditionalRawData: null); } @@ -166,7 +324,7 @@ public static RunStepMessageCreationReference RunStepMessageCreationReference(st /// /// A list of tool call details for this run step. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . /// /// A new instance for mocking. public static RunStepToolCallDetails RunStepToolCallDetails(IEnumerable toolCalls = null) @@ -209,15 +367,15 @@ public static RunStepCodeInterpreterImageReference RunStepCodeInterpreterImageRe return new RunStepCodeInterpreterImageReference(fileId, serializedAdditionalRawData: null); } - /// Initializes a new instance of . + /// Initializes a new instance of . /// The ID of the tool call. This ID must be referenced when you submit tool outputs. - /// The key/value pairs produced by the retrieval tool. - /// A new instance for mocking. - public static RunStepRetrievalToolCall RunStepRetrievalToolCall(string id = null, IReadOnlyDictionary retrieval = null) + /// Reserved for future use. + /// A new instance for mocking. + public static RunStepFileSearchToolCall RunStepFileSearchToolCall(string id = null, IReadOnlyDictionary fileSearch = null) { - retrieval ??= new Dictionary(); + fileSearch ??= new Dictionary(); - return new RunStepRetrievalToolCall("retrieval", id, serializedAdditionalRawData: null, retrieval); + return new RunStepFileSearchToolCall("file_search", id, serializedAdditionalRawData: null, fileSearch); } /// Initializes a new instance of . @@ -228,5 +386,488 @@ public static RunStepError RunStepError(RunStepErrorCode code = default, string { return new RunStepError(code, message, serializedAdditionalRawData: null); } + + /// Initializes a new instance of . + /// Number of completion tokens used over the course of the run step. + /// Number of prompt tokens used over the course of the run step. + /// Total number of tokens used (prompt + completion). + /// A new instance for mocking. + public static RunStepCompletionUsage RunStepCompletionUsage(long completionTokens = default, long promptTokens = default, long totalTokens = default) + { + return new RunStepCompletionUsage(completionTokens, promptTokens, totalTokens, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The object type, which is always list. + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// A new instance for mocking. + public static OpenAIPageableListOfVectorStore OpenAIPageableListOfVectorStore(OpenAIPageableListOfVectorStoreObject @object = default, IEnumerable data = null, string firstId = null, string lastId = null, bool hasMore = default) + { + data ??= new List(); + + return new OpenAIPageableListOfVectorStore( + @object, + data?.ToList(), + firstId, + lastId, + hasMore, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always `vector_store`. + /// The Unix timestamp (in seconds) for when the vector store was created. + /// The name of the vector store. + /// The total number of bytes used by the files in the vector store. + /// Files count grouped by status processed or being processed by this vector store. + /// The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use. + /// Details on when this vector store expires. + /// The Unix timestamp (in seconds) for when the vector store will expire. + /// The Unix timestamp (in seconds) for when the vector store was last active. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// A new instance for mocking. + public static VectorStore VectorStore(string id = null, VectorStoreObject @object = default, DateTimeOffset createdAt = default, string name = null, int usageBytes = default, VectorStoreFileCount fileCounts = null, VectorStoreStatus status = default, VectorStoreExpirationPolicy expiresAfter = null, DateTimeOffset? expiresAt = null, DateTimeOffset? lastActiveAt = null, IReadOnlyDictionary metadata = null) + { + metadata ??= new Dictionary(); + + return new VectorStore( + id, + @object, + createdAt, + name, + usageBytes, + fileCounts, + status, + expiresAfter, + expiresAt, + lastActiveAt, + metadata, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The number of files that are currently being processed. + /// The number of files that have been successfully processed. + /// The number of files that have failed to process. + /// The number of files that were cancelled. + /// The total number of files. + /// A new instance for mocking. + public static VectorStoreFileCount VectorStoreFileCount(int inProgress = default, int completed = default, int failed = default, int cancelled = default, int total = default) + { + return new VectorStoreFileCount( + inProgress, + completed, + failed, + cancelled, + total, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The ID of the resource specified for deletion. + /// A value indicating whether deletion was successful. + /// The object type, which is always 'vector_store.deleted'. + /// A new instance for mocking. + public static VectorStoreDeletionStatus VectorStoreDeletionStatus(string id = null, bool deleted = default, VectorStoreDeletionStatusObject @object = default) + { + return new VectorStoreDeletionStatus(id, deleted, @object, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The object type, which is always list. + /// The requested list of items. + /// The first ID represented in this list. + /// The last ID represented in this list. + /// A value indicating whether there are additional values available not captured in this list. + /// A new instance for mocking. + public static OpenAIPageableListOfVectorStoreFile OpenAIPageableListOfVectorStoreFile(OpenAIPageableListOfVectorStoreFileObject @object = default, IEnumerable data = null, string firstId = null, string lastId = null, bool hasMore = default) + { + data ??= new List(); + + return new OpenAIPageableListOfVectorStoreFile( + @object, + data?.ToList(), + firstId, + lastId, + hasMore, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always `vector_store.file`. + /// + /// The total vector store usage in bytes. Note that this may be different from the original file + /// size. + /// + /// The Unix timestamp (in seconds) for when the vector store file was created. + /// The ID of the vector store that the file is attached to. + /// The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use. + /// The last error associated with this vector store file. Will be `null` if there are no errors. + /// + /// The strategy used to chunk the file. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// A new instance for mocking. + public static VectorStoreFile VectorStoreFile(string id = null, VectorStoreFileObject @object = default, int usageBytes = default, DateTimeOffset createdAt = default, string vectorStoreId = null, VectorStoreFileStatus status = default, VectorStoreFileError lastError = null, VectorStoreChunkingStrategyResponse chunkingStrategy = null) + { + return new VectorStoreFile( + id, + @object, + usageBytes, + createdAt, + vectorStoreId, + status, + lastError, + chunkingStrategy, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// One of `server_error` or `rate_limit_exceeded`. + /// A human-readable description of the error. + /// A new instance for mocking. + public static VectorStoreFileError VectorStoreFileError(VectorStoreFileErrorCode code = default, string message = null) + { + return new VectorStoreFileError(code, message, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The options for the static chunking strategy. + /// A new instance for mocking. + public static VectorStoreStaticChunkingStrategyResponse VectorStoreStaticChunkingStrategyResponse(VectorStoreStaticChunkingStrategyOptions @static = null) + { + return new VectorStoreStaticChunkingStrategyResponse(VectorStoreChunkingStrategyResponseType.Static, serializedAdditionalRawData: null, @static); + } + + /// Initializes a new instance of . + /// The ID of the resource specified for deletion. + /// A value indicating whether deletion was successful. + /// The object type, which is always 'vector_store.deleted'. + /// A new instance for mocking. + public static VectorStoreFileDeletionStatus VectorStoreFileDeletionStatus(string id = null, bool deleted = default, VectorStoreFileDeletionStatusObject @object = default) + { + return new VectorStoreFileDeletionStatus(id, deleted, @object, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always `vector_store.file_batch`. + /// The Unix timestamp (in seconds) for when the vector store files batch was created. + /// The ID of the vector store that the file is attached to. + /// The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`. + /// Files count grouped by status processed or being processed by this vector store. + /// A new instance for mocking. + public static VectorStoreFileBatch VectorStoreFileBatch(string id = null, VectorStoreFileBatchObject @object = default, DateTimeOffset createdAt = default, string vectorStoreId = null, VectorStoreFileBatchStatus status = default, VectorStoreFileCount fileCounts = null) + { + return new VectorStoreFileBatch( + id, + @object, + createdAt, + vectorStoreId, + status, + fileCounts, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The identifier of the message, which can be referenced in API endpoints. + /// The object type, which is always `thread.message.delta`. + /// The delta containing the fields that have changed on the Message. + /// A new instance for mocking. + public static MessageDeltaChunk MessageDeltaChunk(string id = null, MessageDeltaChunkObject @object = default, MessageDelta delta = null) + { + return new MessageDeltaChunk(id, @object, delta, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The entity that produced the message. + /// + /// The content of the message as an array of text and/or images. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// A new instance for mocking. + public static MessageDelta MessageDelta(MessageRole role = default, IEnumerable content = null) + { + content ??= new List(); + + return new MessageDelta(role, content?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the content part of the message. + /// The type of content for this content part. + /// A new instance for mocking. + public static MessageDeltaContent MessageDeltaContent(int index = default, string type = null) + { + return new UnknownMessageDeltaContent(index, type, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the content part of the message. + /// The image_file data. + /// A new instance for mocking. + public static MessageDeltaImageFileContent MessageDeltaImageFileContent(int index = default, MessageDeltaImageFileContentObject imageFile = null) + { + return new MessageDeltaImageFileContent(index, "image_file", serializedAdditionalRawData: null, imageFile); + } + + /// Initializes a new instance of . + /// The file ID of the image in the message content. + /// A new instance for mocking. + public static MessageDeltaImageFileContentObject MessageDeltaImageFileContentObject(string fileId = null) + { + return new MessageDeltaImageFileContentObject(fileId, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the content part of the message. + /// The text content details. + /// A new instance for mocking. + public static MessageDeltaTextContentObject MessageDeltaTextContentObject(int index = default, MessageDeltaTextContent text = null) + { + return new MessageDeltaTextContentObject(index, "text", serializedAdditionalRawData: null, text); + } + + /// Initializes a new instance of . + /// The data that makes up the text. + /// + /// Annotations for the text. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// A new instance for mocking. + public static MessageDeltaTextContent MessageDeltaTextContent(string value = null, IEnumerable annotations = null) + { + annotations ??= new List(); + + return new MessageDeltaTextContent(value, annotations?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + /// The type of the text content annotation. + /// A new instance for mocking. + public static MessageDeltaTextAnnotation MessageDeltaTextAnnotation(int index = default, string type = null) + { + return new UnknownMessageDeltaTextAnnotation(index, type, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + /// The file citation information. + /// The text in the message content that needs to be replaced. + /// The start index of this annotation in the content text. + /// The end index of this annotation in the content text. + /// A new instance for mocking. + public static MessageDeltaTextFileCitationAnnotationObject MessageDeltaTextFileCitationAnnotationObject(int index = default, MessageDeltaTextFileCitationAnnotation fileCitation = null, string text = null, int? startIndex = null, int? endIndex = null) + { + return new MessageDeltaTextFileCitationAnnotationObject( + index, + "file_citation", + serializedAdditionalRawData: null, + fileCitation, + text, + startIndex, + endIndex); + } + + /// Initializes a new instance of . + /// The ID of the specific file the citation is from. + /// The specific quote in the cited file. + /// A new instance for mocking. + public static MessageDeltaTextFileCitationAnnotation MessageDeltaTextFileCitationAnnotation(string fileId = null, string quote = null) + { + return new MessageDeltaTextFileCitationAnnotation(fileId, quote, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + /// The file path information. + /// The start index of this annotation in the content text. + /// The end index of this annotation in the content text. + /// The text in the message content that needs to be replaced. + /// A new instance for mocking. + public static MessageDeltaTextFilePathAnnotationObject MessageDeltaTextFilePathAnnotationObject(int index = default, MessageDeltaTextFilePathAnnotation filePath = null, int? startIndex = null, int? endIndex = null, string text = null) + { + return new MessageDeltaTextFilePathAnnotationObject( + index, + "file_path", + serializedAdditionalRawData: null, + filePath, + startIndex, + endIndex, + text); + } + + /// Initializes a new instance of . + /// The file ID for the annotation. + /// A new instance for mocking. + public static MessageDeltaTextFilePathAnnotation MessageDeltaTextFilePathAnnotation(string fileId = null) + { + return new MessageDeltaTextFilePathAnnotation(fileId, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The identifier of the run step, which can be referenced in API endpoints. + /// The object type, which is always `thread.run.step.delta`. + /// The delta containing the fields that have changed on the run step. + /// A new instance for mocking. + public static RunStepDeltaChunk RunStepDeltaChunk(string id = null, RunStepDeltaChunkObject @object = default, RunStepDelta delta = null) + { + return new RunStepDeltaChunk(id, @object, delta, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// The details of the run step. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// A new instance for mocking. + public static RunStepDelta RunStepDelta(RunStepDeltaDetail stepDetails = null) + { + return new RunStepDelta(stepDetails, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The message creation data. + /// A new instance for mocking. + public static RunStepDeltaMessageCreation RunStepDeltaMessageCreation(RunStepDeltaMessageCreationObject messageCreation = null) + { + return new RunStepDeltaMessageCreation("message_creation", serializedAdditionalRawData: null, messageCreation); + } + + /// Initializes a new instance of . + /// The ID of the newly-created message. + /// A new instance for mocking. + public static RunStepDeltaMessageCreationObject RunStepDeltaMessageCreationObject(string messageId = null) + { + return new RunStepDeltaMessageCreationObject(messageId, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// The collection of tool calls for the tool call detail item. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + /// A new instance for mocking. + public static RunStepDeltaToolCallObject RunStepDeltaToolCallObject(IEnumerable toolCalls = null) + { + toolCalls ??= new List(); + + return new RunStepDeltaToolCallObject("tool_calls", serializedAdditionalRawData: null, toolCalls?.ToList()); + } + + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// The type of the tool call detail item in a streaming run step's details. + /// A new instance for mocking. + public static RunStepDeltaToolCall RunStepDeltaToolCall(int index = default, string id = null, string type = null) + { + return new UnknownRunStepDeltaToolCall(index, id, type, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// The function data for the tool call. + /// A new instance for mocking. + public static RunStepDeltaFunctionToolCall RunStepDeltaFunctionToolCall(int index = default, string id = null, RunStepDeltaFunction function = null) + { + return new RunStepDeltaFunctionToolCall(index, id, "function", serializedAdditionalRawData: null, function); + } + + /// Initializes a new instance of . + /// The name of the function. + /// The arguments passed to the function as input. + /// The output of the function, null if outputs have not yet been submitted. + /// A new instance for mocking. + public static RunStepDeltaFunction RunStepDeltaFunction(string name = null, string arguments = null, string output = null) + { + return new RunStepDeltaFunction(name, arguments, output, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// Reserved for future use. + /// A new instance for mocking. + public static RunStepDeltaFileSearchToolCall RunStepDeltaFileSearchToolCall(int index = default, string id = null, IReadOnlyDictionary fileSearch = null) + { + fileSearch ??= new Dictionary(); + + return new RunStepDeltaFileSearchToolCall(index, id, "file_search", serializedAdditionalRawData: null, fileSearch); + } + + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// The Code Interpreter data for the tool call. + /// A new instance for mocking. + public static RunStepDeltaCodeInterpreterToolCall RunStepDeltaCodeInterpreterToolCall(int index = default, string id = null, RunStepDeltaCodeInterpreterDetailItemObject codeInterpreter = null) + { + return new RunStepDeltaCodeInterpreterToolCall(index, id, "code_interpreter", serializedAdditionalRawData: null, codeInterpreter); + } + + /// Initializes a new instance of . + /// The input into the Code Interpreter tool call. + /// + /// The outputs from the Code Interpreter tool call. Code Interpreter can output one or more + /// items, including text (`logs`) or images (`image`). Each of these are represented by a + /// different object type. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// A new instance for mocking. + public static RunStepDeltaCodeInterpreterDetailItemObject RunStepDeltaCodeInterpreterDetailItemObject(string input = null, IEnumerable outputs = null) + { + outputs ??= new List(); + + return new RunStepDeltaCodeInterpreterDetailItemObject(input, outputs?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + /// The type of the streaming run step tool call's Code Interpreter output. + /// A new instance for mocking. + public static RunStepDeltaCodeInterpreterOutput RunStepDeltaCodeInterpreterOutput(int index = default, string type = null) + { + return new UnknownRunStepDeltaCodeInterpreterOutput(index, type, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + /// The text output from the Code Interpreter tool call. + /// A new instance for mocking. + public static RunStepDeltaCodeInterpreterLogOutput RunStepDeltaCodeInterpreterLogOutput(int index = default, string logs = null) + { + return new RunStepDeltaCodeInterpreterLogOutput(index, "logs", serializedAdditionalRawData: null, logs); + } + + /// Initializes a new instance of . + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + /// The image data for the Code Interpreter tool call output. + /// A new instance for mocking. + public static RunStepDeltaCodeInterpreterImageOutput RunStepDeltaCodeInterpreterImageOutput(int index = default, RunStepDeltaCodeInterpreterImageOutputObject image = null) + { + return new RunStepDeltaCodeInterpreterImageOutput(index, "image", serializedAdditionalRawData: null, image); + } + + /// Initializes a new instance of . + /// The file ID for the image. + /// A new instance for mocking. + public static RunStepDeltaCodeInterpreterImageOutputObject RunStepDeltaCodeInterpreterImageOutputObject(string fileId = null) + { + return new RunStepDeltaCodeInterpreterImageOutputObject(fileId, serializedAdditionalRawData: null); + } } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsNamedToolChoice.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsNamedToolChoice.Serialization.cs new file mode 100644 index 000000000000..da652aaf0b45 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsNamedToolChoice.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class AssistantsNamedToolChoice : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AssistantsNamedToolChoice)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (Optional.IsDefined(Function)) + { + writer.WritePropertyName("function"u8); + writer.WriteObjectValue(Function, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + AssistantsNamedToolChoice IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AssistantsNamedToolChoice)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAssistantsNamedToolChoice(document.RootElement, options); + } + + internal static AssistantsNamedToolChoice DeserializeAssistantsNamedToolChoice(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AssistantsNamedToolChoiceType type = default; + FunctionName function = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new AssistantsNamedToolChoiceType(property.Value.GetString()); + continue; + } + if (property.NameEquals("function"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + function = FunctionName.DeserializeFunctionName(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new AssistantsNamedToolChoice(type, function, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AssistantsNamedToolChoice)} does not support writing '{options.Format}' format."); + } + } + + AssistantsNamedToolChoice IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeAssistantsNamedToolChoice(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AssistantsNamedToolChoice)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static AssistantsNamedToolChoice FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeAssistantsNamedToolChoice(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsNamedToolChoice.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsNamedToolChoice.cs new file mode 100644 index 000000000000..b0da555fe4a1 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsNamedToolChoice.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Specifies a tool the model should use. Use to force the model to call a specific tool. + public partial class AssistantsNamedToolChoice + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// the type of tool. If type is `function`, the function name must be set. + public AssistantsNamedToolChoice(AssistantsNamedToolChoiceType type) + { + Type = type; + } + + /// Initializes a new instance of . + /// the type of tool. If type is `function`, the function name must be set. + /// The name of the function to call. + /// Keeps track of any properties unknown to the library. + internal AssistantsNamedToolChoice(AssistantsNamedToolChoiceType type, FunctionName function, IDictionary serializedAdditionalRawData) + { + Type = type; + Function = function; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal AssistantsNamedToolChoice() + { + } + + /// the type of tool. If type is `function`, the function name must be set. + public AssistantsNamedToolChoiceType Type { get; set; } + /// The name of the function to call. + public FunctionName Function { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsNamedToolChoiceType.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsNamedToolChoiceType.cs new file mode 100644 index 000000000000..8df47772b7cd --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantsNamedToolChoiceType.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Available tool types for assistants named tools. + public readonly partial struct AssistantsNamedToolChoiceType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AssistantsNamedToolChoiceType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string FunctionValue = "function"; + private const string CodeInterpreterValue = "code_interpreter"; + private const string FileSearchValue = "file_search"; + + /// Tool type `function`. + public static AssistantsNamedToolChoiceType Function { get; } = new AssistantsNamedToolChoiceType(FunctionValue); + /// Tool type `code_interpreter`. + public static AssistantsNamedToolChoiceType CodeInterpreter { get; } = new AssistantsNamedToolChoiceType(CodeInterpreterValue); + /// Tool type `file_search`. + public static AssistantsNamedToolChoiceType FileSearch { get; } = new AssistantsNamedToolChoiceType(FileSearchValue); + /// Determines if two values are the same. + public static bool operator ==(AssistantsNamedToolChoiceType left, AssistantsNamedToolChoiceType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AssistantsNamedToolChoiceType left, AssistantsNamedToolChoiceType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator AssistantsNamedToolChoiceType(string value) => new AssistantsNamedToolChoiceType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AssistantsNamedToolChoiceType other && Equals(other); + /// + public bool Equals(AssistantsNamedToolChoiceType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CodeInterpreterToolResource.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CodeInterpreterToolResource.Serialization.cs new file mode 100644 index 000000000000..152d0868305a --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CodeInterpreterToolResource.Serialization.cs @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class CodeInterpreterToolResource : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CodeInterpreterToolResource)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CodeInterpreterToolResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CodeInterpreterToolResource)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCodeInterpreterToolResource(document.RootElement, options); + } + + internal static CodeInterpreterToolResource DeserializeCodeInterpreterToolResource(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList fileIds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_ids"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + fileIds = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CodeInterpreterToolResource(fileIds, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CodeInterpreterToolResource)} does not support writing '{options.Format}' format."); + } + } + + CodeInterpreterToolResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCodeInterpreterToolResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CodeInterpreterToolResource)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CodeInterpreterToolResource FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeCodeInterpreterToolResource(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CodeInterpreterToolResource.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CodeInterpreterToolResource.cs new file mode 100644 index 000000000000..a0a185a491bc --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CodeInterpreterToolResource.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.OpenAI.Assistants +{ + /// A set of resources that are used by the `code_interpreter` tool. + public partial class CodeInterpreterToolResource + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// + /// A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files + /// associated with the tool. + /// + /// is null. + internal CodeInterpreterToolResource(IEnumerable fileIds) + { + Argument.AssertNotNull(fileIds, nameof(fileIds)); + + FileIds = fileIds.ToList(); + } + + /// Initializes a new instance of . + /// + /// A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files + /// associated with the tool. + /// + /// Keeps track of any properties unknown to the library. + internal CodeInterpreterToolResource(IReadOnlyList fileIds, IDictionary serializedAdditionalRawData) + { + FileIds = fileIds; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CodeInterpreterToolResource() + { + } + + /// + /// A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files + /// associated with the tool. + /// + public IReadOnlyList FileIds { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateAndRunThreadOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateAndRunThreadOptions.Serialization.cs index e91fb2d48f48..de9c361a863c 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateAndRunThreadOptions.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateAndRunThreadOptions.Serialization.cs @@ -35,23 +35,159 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea } if (Optional.IsDefined(OverrideModelName)) { - writer.WritePropertyName("model"u8); - writer.WriteStringValue(OverrideModelName); + if (OverrideModelName != null) + { + writer.WritePropertyName("model"u8); + writer.WriteStringValue(OverrideModelName); + } + else + { + writer.WriteNull("model"); + } } if (Optional.IsDefined(OverrideInstructions)) { - writer.WritePropertyName("instructions"u8); - writer.WriteStringValue(OverrideInstructions); + if (OverrideInstructions != null) + { + writer.WritePropertyName("instructions"u8); + writer.WriteStringValue(OverrideInstructions); + } + else + { + writer.WriteNull("instructions"); + } } if (Optional.IsCollectionDefined(OverrideTools)) { - writer.WritePropertyName("tools"u8); - writer.WriteStartArray(); - foreach (var item in OverrideTools) + if (OverrideTools != null) + { + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in OverrideTools) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("tools"); + } + } + if (Optional.IsDefined(ToolResources)) + { + if (ToolResources != null) + { + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); + } + else + { + writer.WriteNull("tool_resources"); + } + } + if (Optional.IsDefined(Stream)) + { + writer.WritePropertyName("stream"u8); + writer.WriteBooleanValue(Stream.Value); + } + if (Optional.IsDefined(Temperature)) + { + if (Temperature != null) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + else + { + writer.WriteNull("temperature"); + } + } + if (Optional.IsDefined(TopP)) + { + if (TopP != null) + { + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(TopP.Value); + } + else + { + writer.WriteNull("top_p"); + } + } + if (Optional.IsDefined(MaxPromptTokens)) + { + if (MaxPromptTokens != null) + { + writer.WritePropertyName("max_prompt_tokens"u8); + writer.WriteNumberValue(MaxPromptTokens.Value); + } + else + { + writer.WriteNull("max_prompt_tokens"); + } + } + if (Optional.IsDefined(MaxCompletionTokens)) + { + if (MaxCompletionTokens != null) + { + writer.WritePropertyName("max_completion_tokens"u8); + writer.WriteNumberValue(MaxCompletionTokens.Value); + } + else + { + writer.WriteNull("max_completion_tokens"); + } + } + if (Optional.IsDefined(TruncationStrategy)) + { + if (TruncationStrategy != null) + { + writer.WritePropertyName("truncation_strategy"u8); + writer.WriteObjectValue(TruncationStrategy, options); + } + else + { + writer.WriteNull("truncation_strategy"); + } + } + if (Optional.IsDefined(ToolChoice)) + { + if (ToolChoice != null) + { + writer.WritePropertyName("tool_choice"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ToolChoice); +#else + using (JsonDocument document = JsonDocument.Parse(ToolChoice)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else + { + writer.WriteNull("tool_choice"); + } + } + if (Optional.IsDefined(ResponseFormat)) + { + if (ResponseFormat != null) + { + writer.WritePropertyName("response_format"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ResponseFormat); +#else + using (JsonDocument document = JsonDocument.Parse(ResponseFormat)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else { - writer.WriteObjectValue(item, options); + writer.WriteNull("response_format"); } - writer.WriteEndArray(); } if (Optional.IsCollectionDefined(Metadata)) { @@ -114,6 +250,15 @@ internal static CreateAndRunThreadOptions DeserializeCreateAndRunThreadOptions(J string model = default; string instructions = default; IList tools = default; + UpdateToolResourcesOptions toolResources = default; + bool? stream = default; + float? temperature = default; + float? topP = default; + int? maxPromptTokens = default; + int? maxCompletionTokens = default; + TruncationObject truncationStrategy = default; + BinaryData toolChoice = default; + BinaryData responseFormat = default; IDictionary metadata = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); @@ -135,11 +280,21 @@ internal static CreateAndRunThreadOptions DeserializeCreateAndRunThreadOptions(J } if (property.NameEquals("model"u8)) { + if (property.Value.ValueKind == JsonValueKind.Null) + { + model = null; + continue; + } model = property.Value.GetString(); continue; } if (property.NameEquals("instructions"u8)) { + if (property.Value.ValueKind == JsonValueKind.Null) + { + instructions = null; + continue; + } instructions = property.Value.GetString(); continue; } @@ -157,6 +312,95 @@ internal static CreateAndRunThreadOptions DeserializeCreateAndRunThreadOptions(J tools = array; continue; } + if (property.NameEquals("tool_resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + toolResources = null; + continue; + } + toolResources = UpdateToolResourcesOptions.DeserializeUpdateToolResourcesOptions(property.Value, options); + continue; + } + if (property.NameEquals("stream"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + stream = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + temperature = null; + continue; + } + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("top_p"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + topP = null; + continue; + } + topP = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("max_prompt_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + maxPromptTokens = null; + continue; + } + maxPromptTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("max_completion_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + maxCompletionTokens = null; + continue; + } + maxCompletionTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("truncation_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + truncationStrategy = null; + continue; + } + truncationStrategy = TruncationObject.DeserializeTruncationObject(property.Value, options); + continue; + } + if (property.NameEquals("tool_choice"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + toolChoice = null; + continue; + } + toolChoice = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + responseFormat = null; + continue; + } + responseFormat = BinaryData.FromString(property.Value.GetRawText()); + continue; + } if (property.NameEquals("metadata"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -183,6 +427,15 @@ internal static CreateAndRunThreadOptions DeserializeCreateAndRunThreadOptions(J model, instructions, tools ?? new ChangeTrackingList(), + toolResources, + stream, + temperature, + topP, + maxPromptTokens, + maxCompletionTokens, + truncationStrategy, + toolChoice, + responseFormat, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateAndRunThreadOptions.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateAndRunThreadOptions.cs index cf9c983195f7..b32fe2f7656b 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateAndRunThreadOptions.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateAndRunThreadOptions.cs @@ -59,23 +59,61 @@ public CreateAndRunThreadOptions(string assistantId) /// Initializes a new instance of . /// The ID of the assistant for which the thread should be created. - /// The details used to create the new thread. + /// The details used to create the new thread. If no thread is provided, an empty one will be created. /// The overridden model that the assistant should use to run the thread. /// The overridden system instructions the assistant should use to run the thread. /// /// The overridden list of enabled tools the assistant should use to run the thread. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . /// + /// Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. + /// + /// If `true`, returns a stream of events that happen during the Run as server-sent events, + /// terminating when the Run enters a terminal state with a `data: [DONE]` message. + /// + /// + /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output + /// more random, while lower values like 0.2 will make it more focused and deterministic. + /// + /// + /// An alternative to sampling with temperature, called nucleus sampling, where the model + /// considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + /// comprising the top 10% probability mass are considered. + /// + /// We generally recommend altering this or temperature but not both. + /// + /// + /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, + /// the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + /// + /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens + /// specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + /// The strategy to use for dropping messages as the context windows moves forward. + /// Controls whether or not and which tool is called by the model. + /// Specifies the format that the model must output. /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// Keeps track of any properties unknown to the library. - internal CreateAndRunThreadOptions(string assistantId, AssistantThreadCreationOptions thread, string overrideModelName, string overrideInstructions, IList overrideTools, IDictionary metadata, IDictionary serializedAdditionalRawData) + internal CreateAndRunThreadOptions(string assistantId, AssistantThreadCreationOptions thread, string overrideModelName, string overrideInstructions, IList overrideTools, UpdateToolResourcesOptions toolResources, bool? stream, float? temperature, float? topP, int? maxPromptTokens, int? maxCompletionTokens, TruncationObject truncationStrategy, BinaryData toolChoice, BinaryData responseFormat, IDictionary metadata, IDictionary serializedAdditionalRawData) { AssistantId = assistantId; Thread = thread; OverrideModelName = overrideModelName; OverrideInstructions = overrideInstructions; OverrideTools = overrideTools; + ToolResources = toolResources; + Stream = stream; + Temperature = temperature; + TopP = topP; + MaxPromptTokens = maxPromptTokens; + MaxCompletionTokens = maxCompletionTokens; + TruncationStrategy = truncationStrategy; + ToolChoice = toolChoice; + ResponseFormat = responseFormat; Metadata = metadata; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -87,7 +125,7 @@ internal CreateAndRunThreadOptions() /// The ID of the assistant for which the thread should be created. public string AssistantId { get; } - /// The details used to create the new thread. + /// The details used to create the new thread. If no thread is provided, an empty one will be created. public AssistantThreadCreationOptions Thread { get; set; } /// The overridden model that the assistant should use to run the thread. public string OverrideModelName { get; set; } @@ -96,9 +134,133 @@ internal CreateAndRunThreadOptions() /// /// The overridden list of enabled tools the assistant should use to run the thread. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . + /// + public IList OverrideTools { get; set; } + /// Override the tools the assistant can use for this run. This is useful for modifying the behavior on a per-run basis. + public UpdateToolResourcesOptions ToolResources { get; set; } + /// + /// If `true`, returns a stream of events that happen during the Run as server-sent events, + /// terminating when the Run enters a terminal state with a `data: [DONE]` message. + /// + public bool? Stream { get; set; } + /// + /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output + /// more random, while lower values like 0.2 will make it more focused and deterministic. + /// + public float? Temperature { get; set; } + /// + /// An alternative to sampling with temperature, called nucleus sampling, where the model + /// considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + /// comprising the top 10% probability mass are considered. + /// + /// We generally recommend altering this or temperature but not both. + /// + public float? TopP { get; set; } + /// + /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, + /// the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + public int? MaxPromptTokens { get; set; } + /// + /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens + /// specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + public int? MaxCompletionTokens { get; set; } + /// The strategy to use for dropping messages as the context windows moves forward. + public TruncationObject TruncationStrategy { get; set; } + /// + /// Controls whether or not and which tool is called by the model. + /// + /// To assign an object to this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// + /// Supported types: + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData ToolChoice { get; set; } + /// + /// Specifies the format that the model must output. + /// + /// To assign an object to this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// + /// Supported types: + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// /// - public IList OverrideTools { get; } + public BinaryData ResponseFormat { get; set; } /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. public IDictionary Metadata { get; set; } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateCodeInterpreterToolResourceOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateCodeInterpreterToolResourceOptions.Serialization.cs new file mode 100644 index 000000000000..887cb1e943d8 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateCodeInterpreterToolResourceOptions.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class CreateCodeInterpreterToolResourceOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateCodeInterpreterToolResourceOptions)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CreateCodeInterpreterToolResourceOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateCodeInterpreterToolResourceOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateCodeInterpreterToolResourceOptions(document.RootElement, options); + } + + internal static CreateCodeInterpreterToolResourceOptions DeserializeCreateCodeInterpreterToolResourceOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList fileIds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_ids"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + fileIds = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CreateCodeInterpreterToolResourceOptions(fileIds ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CreateCodeInterpreterToolResourceOptions)} does not support writing '{options.Format}' format."); + } + } + + CreateCodeInterpreterToolResourceOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCreateCodeInterpreterToolResourceOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateCodeInterpreterToolResourceOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CreateCodeInterpreterToolResourceOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeCreateCodeInterpreterToolResourceOptions(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateAssistantFileRequest.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateCodeInterpreterToolResourceOptions.cs similarity index 64% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateAssistantFileRequest.cs rename to sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateCodeInterpreterToolResourceOptions.cs index 5a1af0cc4664..97be44a94098 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateAssistantFileRequest.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateCodeInterpreterToolResourceOptions.cs @@ -10,8 +10,8 @@ namespace Azure.AI.OpenAI.Assistants { - /// The CreateAssistantFileRequest. - internal partial class CreateAssistantFileRequest + /// A set of resources that will be used by the `code_interpreter` tool. Request object. + public partial class CreateCodeInterpreterToolResourceOptions { /// /// Keeps track of any properties unknown to the library. @@ -45,31 +45,22 @@ internal partial class CreateAssistantFileRequest /// private IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . - /// The ID of the previously uploaded file to attach. - /// is null. - internal CreateAssistantFileRequest(string fileId) + /// Initializes a new instance of . + public CreateCodeInterpreterToolResourceOptions() { - Argument.AssertNotNull(fileId, nameof(fileId)); - - FileId = fileId; + FileIds = new ChangeTrackingList(); } - /// Initializes a new instance of . - /// The ID of the previously uploaded file to attach. + /// Initializes a new instance of . + /// A list of file IDs made available to the `code_interpreter` tool. /// Keeps track of any properties unknown to the library. - internal CreateAssistantFileRequest(string fileId, IDictionary serializedAdditionalRawData) + internal CreateCodeInterpreterToolResourceOptions(IList fileIds, IDictionary serializedAdditionalRawData) { - FileId = fileId; + FileIds = fileIds; _serializedAdditionalRawData = serializedAdditionalRawData; } - /// Initializes a new instance of for deserialization. - internal CreateAssistantFileRequest() - { - } - - /// The ID of the previously uploaded file to attach. - public string FileId { get; } + /// A list of file IDs made available to the `code_interpreter` tool. + public IList FileIds { get; } } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadInitializationMessage.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateFileSearchToolResourceVectorStoreOptions.Serialization.cs similarity index 60% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadInitializationMessage.Serialization.cs rename to sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateFileSearchToolResourceVectorStoreOptions.Serialization.cs index 8ec0eefb2fc4..758a3da794aa 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadInitializationMessage.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateFileSearchToolResourceVectorStoreOptions.Serialization.cs @@ -13,33 +13,28 @@ namespace Azure.AI.OpenAI.Assistants { - public partial class ThreadInitializationMessage : IUtf8JsonSerializable, IJsonModel + public partial class CreateFileSearchToolResourceVectorStoreOptions : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(ThreadInitializationMessage)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(CreateFileSearchToolResourceVectorStoreOptions)} does not support writing '{format}' format."); } writer.WriteStartObject(); - writer.WritePropertyName("role"u8); - writer.WriteStringValue(Role.ToString()); - writer.WritePropertyName("content"u8); - writer.WriteStringValue(Content); - if (Optional.IsCollectionDefined(FileIds)) + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) { - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); + writer.WriteStringValue(item); } + writer.WriteEndArray(); + writer.WritePropertyName("chunking_strategy"u8); + writer.WriteObjectValue(ChunkingStrategy, options); if (Optional.IsCollectionDefined(Metadata)) { if (Metadata != null) @@ -76,19 +71,19 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR writer.WriteEndObject(); } - ThreadInitializationMessage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + CreateFileSearchToolResourceVectorStoreOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(ThreadInitializationMessage)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(CreateFileSearchToolResourceVectorStoreOptions)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeThreadInitializationMessage(document.RootElement, options); + return DeserializeCreateFileSearchToolResourceVectorStoreOptions(document.RootElement, options); } - internal static ThreadInitializationMessage DeserializeThreadInitializationMessage(JsonElement element, ModelReaderWriterOptions options = null) + internal static CreateFileSearchToolResourceVectorStoreOptions DeserializeCreateFileSearchToolResourceVectorStoreOptions(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -96,30 +91,15 @@ internal static ThreadInitializationMessage DeserializeThreadInitializationMessa { return null; } - MessageRole role = default; - string content = default; IList fileIds = default; + VectorStoreChunkingStrategyRequest chunkingStrategy = default; IDictionary metadata = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("role"u8)) - { - role = new MessageRole(property.Value.GetString()); - continue; - } - if (property.NameEquals("content"u8)) - { - content = property.Value.GetString(); - continue; - } if (property.NameEquals("file_ids"u8)) { - if (property.Value.ValueKind == JsonValueKind.Null) - { - continue; - } List array = new List(); foreach (var item in property.Value.EnumerateArray()) { @@ -128,6 +108,11 @@ internal static ThreadInitializationMessage DeserializeThreadInitializationMessa fileIds = array; continue; } + if (property.NameEquals("chunking_strategy"u8)) + { + chunkingStrategy = VectorStoreChunkingStrategyRequest.DeserializeVectorStoreChunkingStrategyRequest(property.Value, options); + continue; + } if (property.NameEquals("metadata"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -148,46 +133,46 @@ internal static ThreadInitializationMessage DeserializeThreadInitializationMessa } } serializedAdditionalRawData = rawDataDictionary; - return new ThreadInitializationMessage(role, content, fileIds ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + return new CreateFileSearchToolResourceVectorStoreOptions(fileIds, chunkingStrategy, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(ThreadInitializationMessage)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(CreateFileSearchToolResourceVectorStoreOptions)} does not support writing '{options.Format}' format."); } } - ThreadInitializationMessage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + CreateFileSearchToolResourceVectorStoreOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data); - return DeserializeThreadInitializationMessage(document.RootElement, options); + return DeserializeCreateFileSearchToolResourceVectorStoreOptions(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(ThreadInitializationMessage)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(CreateFileSearchToolResourceVectorStoreOptions)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static ThreadInitializationMessage FromResponse(Response response) + internal static CreateFileSearchToolResourceVectorStoreOptions FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content); - return DeserializeThreadInitializationMessage(document.RootElement); + return DeserializeCreateFileSearchToolResourceVectorStoreOptions(document.RootElement); } /// Convert into a . diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateFileSearchToolResourceVectorStoreOptions.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateFileSearchToolResourceVectorStoreOptions.cs new file mode 100644 index 000000000000..cac5e291a8a8 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateFileSearchToolResourceVectorStoreOptions.cs @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.OpenAI.Assistants +{ + /// File IDs associated to the vector store to be passed to the helper. + public partial class CreateFileSearchToolResourceVectorStoreOptions + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// A list of file IDs to add to the vector store. There can be a maximum of 10000 files in a vector store. + /// + /// The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// or is null. + public CreateFileSearchToolResourceVectorStoreOptions(IEnumerable fileIds, VectorStoreChunkingStrategyRequest chunkingStrategy) + { + Argument.AssertNotNull(fileIds, nameof(fileIds)); + Argument.AssertNotNull(chunkingStrategy, nameof(chunkingStrategy)); + + FileIds = fileIds.ToList(); + ChunkingStrategy = chunkingStrategy; + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// A list of file IDs to add to the vector store. There can be a maximum of 10000 files in a vector store. + /// + /// The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal CreateFileSearchToolResourceVectorStoreOptions(IList fileIds, VectorStoreChunkingStrategyRequest chunkingStrategy, IDictionary metadata, IDictionary serializedAdditionalRawData) + { + FileIds = fileIds; + ChunkingStrategy = chunkingStrategy; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CreateFileSearchToolResourceVectorStoreOptions() + { + } + + /// A list of file IDs to add to the vector store. There can be a maximum of 10000 files in a vector store. + public IList FileIds { get; } + /// + /// The chunking strategy used to chunk the file(s). If not set, will use the `auto` strategy. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public VectorStoreChunkingStrategyRequest ChunkingStrategy { get; } + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IDictionary Metadata { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateRunOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateRunOptions.Serialization.cs index 1e4243ff8d01..6e24655c266c 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateRunOptions.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateRunOptions.Serialization.cs @@ -64,6 +64,23 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter writer.WriteNull("additional_instructions"); } } + if (Optional.IsCollectionDefined(AdditionalMessages)) + { + if (AdditionalMessages != null) + { + writer.WritePropertyName("additional_messages"u8); + writer.WriteStartArray(); + foreach (var item in AdditionalMessages) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("additional_messages"); + } + } if (Optional.IsCollectionDefined(OverrideTools)) { if (OverrideTools != null) @@ -81,6 +98,109 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter writer.WriteNull("tools"); } } + if (Optional.IsDefined(Stream)) + { + writer.WritePropertyName("stream"u8); + writer.WriteBooleanValue(Stream.Value); + } + if (Optional.IsDefined(Temperature)) + { + if (Temperature != null) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + else + { + writer.WriteNull("temperature"); + } + } + if (Optional.IsDefined(TopP)) + { + if (TopP != null) + { + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(TopP.Value); + } + else + { + writer.WriteNull("top_p"); + } + } + if (Optional.IsDefined(MaxPromptTokens)) + { + if (MaxPromptTokens != null) + { + writer.WritePropertyName("max_prompt_tokens"u8); + writer.WriteNumberValue(MaxPromptTokens.Value); + } + else + { + writer.WriteNull("max_prompt_tokens"); + } + } + if (Optional.IsDefined(MaxCompletionTokens)) + { + if (MaxCompletionTokens != null) + { + writer.WritePropertyName("max_completion_tokens"u8); + writer.WriteNumberValue(MaxCompletionTokens.Value); + } + else + { + writer.WriteNull("max_completion_tokens"); + } + } + if (Optional.IsDefined(TruncationStrategy)) + { + if (TruncationStrategy != null) + { + writer.WritePropertyName("truncation_strategy"u8); + writer.WriteObjectValue(TruncationStrategy, options); + } + else + { + writer.WriteNull("truncation_strategy"); + } + } + if (Optional.IsDefined(ToolChoice)) + { + if (ToolChoice != null) + { + writer.WritePropertyName("tool_choice"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ToolChoice); +#else + using (JsonDocument document = JsonDocument.Parse(ToolChoice)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else + { + writer.WriteNull("tool_choice"); + } + } + if (Optional.IsDefined(ResponseFormat)) + { + if (ResponseFormat != null) + { + writer.WritePropertyName("response_format"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ResponseFormat); +#else + using (JsonDocument document = JsonDocument.Parse(ResponseFormat)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else + { + writer.WriteNull("response_format"); + } + } if (Optional.IsCollectionDefined(Metadata)) { if (Metadata != null) @@ -141,7 +261,16 @@ internal static CreateRunOptions DeserializeCreateRunOptions(JsonElement element string model = default; string instructions = default; string additionalInstructions = default; + IList additionalMessages = default; IList tools = default; + bool? stream = default; + float? temperature = default; + float? topP = default; + int? maxPromptTokens = default; + int? maxCompletionTokens = default; + TruncationObject truncationStrategy = default; + BinaryData toolChoice = default; + BinaryData responseFormat = default; IDictionary metadata = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); @@ -182,6 +311,20 @@ internal static CreateRunOptions DeserializeCreateRunOptions(JsonElement element additionalInstructions = property.Value.GetString(); continue; } + if (property.NameEquals("additional_messages"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ThreadMessage.DeserializeThreadMessage(item, options)); + } + additionalMessages = array; + continue; + } if (property.NameEquals("tools"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -196,6 +339,85 @@ internal static CreateRunOptions DeserializeCreateRunOptions(JsonElement element tools = array; continue; } + if (property.NameEquals("stream"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + stream = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + temperature = null; + continue; + } + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("top_p"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + topP = null; + continue; + } + topP = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("max_prompt_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + maxPromptTokens = null; + continue; + } + maxPromptTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("max_completion_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + maxCompletionTokens = null; + continue; + } + maxCompletionTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("truncation_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + truncationStrategy = null; + continue; + } + truncationStrategy = TruncationObject.DeserializeTruncationObject(property.Value, options); + continue; + } + if (property.NameEquals("tool_choice"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + toolChoice = null; + continue; + } + toolChoice = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + responseFormat = null; + continue; + } + responseFormat = BinaryData.FromString(property.Value.GetRawText()); + continue; + } if (property.NameEquals("metadata"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -221,7 +443,16 @@ internal static CreateRunOptions DeserializeCreateRunOptions(JsonElement element model, instructions, additionalInstructions, + additionalMessages ?? new ChangeTrackingList(), tools ?? new ChangeTrackingList(), + stream, + temperature, + topP, + maxPromptTokens, + maxCompletionTokens, + truncationStrategy, + toolChoice, + responseFormat, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateRunOptions.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateRunOptions.cs index 1c307b753523..810b7d903506 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateRunOptions.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateRunOptions.cs @@ -53,6 +53,7 @@ public CreateRunOptions(string assistantId) Argument.AssertNotNull(assistantId, nameof(assistantId)); AssistantId = assistantId; + AdditionalMessages = new ChangeTrackingList(); OverrideTools = new ChangeTrackingList(); Metadata = new ChangeTrackingDictionary(); } @@ -65,20 +66,58 @@ public CreateRunOptions(string assistantId) /// Additional instructions to append at the end of the instructions for the run. This is useful for modifying the behavior /// on a per-run basis without overriding other instructions. /// + /// Adds additional messages to the thread before creating the run. /// /// The overridden list of enabled tools that the assistant should use to run the thread. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . /// + /// + /// If `true`, returns a stream of events that happen during the Run as server-sent events, + /// terminating when the Run enters a terminal state with a `data: [DONE]` message. + /// + /// + /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output + /// more random, while lower values like 0.2 will make it more focused and deterministic. + /// + /// + /// An alternative to sampling with temperature, called nucleus sampling, where the model + /// considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + /// comprising the top 10% probability mass are considered. + /// + /// We generally recommend altering this or temperature but not both. + /// + /// + /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, + /// the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + /// + /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort + /// to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of + /// completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + /// The strategy to use for dropping messages as the context windows moves forward. + /// Controls whether or not and which tool is called by the model. + /// Specifies the format that the model must output. /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// Keeps track of any properties unknown to the library. - internal CreateRunOptions(string assistantId, string overrideModelName, string overrideInstructions, string additionalInstructions, IList overrideTools, IDictionary metadata, IDictionary serializedAdditionalRawData) + internal CreateRunOptions(string assistantId, string overrideModelName, string overrideInstructions, string additionalInstructions, IList additionalMessages, IList overrideTools, bool? stream, float? temperature, float? topP, int? maxPromptTokens, int? maxCompletionTokens, TruncationObject truncationStrategy, BinaryData toolChoice, BinaryData responseFormat, IDictionary metadata, IDictionary serializedAdditionalRawData) { AssistantId = assistantId; OverrideModelName = overrideModelName; OverrideInstructions = overrideInstructions; AdditionalInstructions = additionalInstructions; + AdditionalMessages = additionalMessages; OverrideTools = overrideTools; + Stream = stream; + Temperature = temperature; + TopP = topP; + MaxPromptTokens = maxPromptTokens; + MaxCompletionTokens = maxCompletionTokens; + TruncationStrategy = truncationStrategy; + ToolChoice = toolChoice; + ResponseFormat = responseFormat; Metadata = metadata; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -99,12 +138,136 @@ internal CreateRunOptions() /// on a per-run basis without overriding other instructions. /// public string AdditionalInstructions { get; set; } + /// Adds additional messages to the thread before creating the run. + public IList AdditionalMessages { get; set; } /// /// The overridden list of enabled tools that the assistant should use to run the thread. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . /// public IList OverrideTools { get; set; } + /// + /// If `true`, returns a stream of events that happen during the Run as server-sent events, + /// terminating when the Run enters a terminal state with a `data: [DONE]` message. + /// + public bool? Stream { get; set; } + /// + /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output + /// more random, while lower values like 0.2 will make it more focused and deterministic. + /// + public float? Temperature { get; set; } + /// + /// An alternative to sampling with temperature, called nucleus sampling, where the model + /// considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens + /// comprising the top 10% probability mass are considered. + /// + /// We generally recommend altering this or temperature but not both. + /// + public float? TopP { get; set; } + /// + /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only + /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, + /// the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + public int? MaxPromptTokens { get; set; } + /// + /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort + /// to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of + /// completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. + /// + public int? MaxCompletionTokens { get; set; } + /// The strategy to use for dropping messages as the context windows moves forward. + public TruncationObject TruncationStrategy { get; set; } + /// + /// Controls whether or not and which tool is called by the model. + /// + /// To assign an object to this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// + /// Supported types: + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData ToolChoice { get; set; } + /// + /// Specifies the format that the model must output. + /// + /// To assign an object to this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// + /// Supported types: + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData ResponseFormat { get; set; } /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. public IDictionary Metadata { get; set; } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateToolResourcesOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateToolResourcesOptions.Serialization.cs new file mode 100644 index 000000000000..228c9350b244 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateToolResourcesOptions.Serialization.cs @@ -0,0 +1,164 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class CreateToolResourcesOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateToolResourcesOptions)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(CodeInterpreter)) + { + writer.WritePropertyName("code_interpreter"u8); + writer.WriteObjectValue(CodeInterpreter, options); + } + if (Optional.IsDefined(FileSearch)) + { + writer.WritePropertyName("file_search"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(FileSearch); +#else + using (JsonDocument document = JsonDocument.Parse(FileSearch)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CreateToolResourcesOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateToolResourcesOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateToolResourcesOptions(document.RootElement, options); + } + + internal static CreateToolResourcesOptions DeserializeCreateToolResourcesOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + CreateCodeInterpreterToolResourceOptions codeInterpreter = default; + BinaryData fileSearch = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code_interpreter"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + codeInterpreter = CreateCodeInterpreterToolResourceOptions.DeserializeCreateCodeInterpreterToolResourceOptions(property.Value, options); + continue; + } + if (property.NameEquals("file_search"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fileSearch = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CreateToolResourcesOptions(codeInterpreter, fileSearch, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CreateToolResourcesOptions)} does not support writing '{options.Format}' format."); + } + } + + CreateToolResourcesOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCreateToolResourcesOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateToolResourcesOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CreateToolResourcesOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeCreateToolResourcesOptions(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateToolResourcesOptions.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateToolResourcesOptions.cs new file mode 100644 index 000000000000..796bdccc21f0 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateToolResourcesOptions.cs @@ -0,0 +1,119 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// + /// Request object. A set of resources that are used by the assistant's tools. The resources are specific to the + /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` + /// tool requires a list of vector store IDs. + /// + public partial class CreateToolResourcesOptions + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public CreateToolResourcesOptions() + { + } + + /// Initializes a new instance of . + /// + /// A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files + /// associated with the tool. + /// + /// A list of vector stores or their IDs made available to the `file_search` tool. + /// Keeps track of any properties unknown to the library. + internal CreateToolResourcesOptions(CreateCodeInterpreterToolResourceOptions codeInterpreter, BinaryData fileSearch, IDictionary serializedAdditionalRawData) + { + CodeInterpreter = codeInterpreter; + FileSearch = fileSearch; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files + /// associated with the tool. + /// + public CreateCodeInterpreterToolResourceOptions CodeInterpreter { get; set; } + /// + /// A list of vector stores or their IDs made available to the `file_search` tool. + /// + /// To assign an object to this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// + /// Supported types: + /// + /// + /// where T is of type + /// + /// + /// where T is of type + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData FileSearch { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateVectorStoreFileBatchRequest.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateVectorStoreFileBatchRequest.Serialization.cs new file mode 100644 index 000000000000..0afaf2dea1a2 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateVectorStoreFileBatchRequest.Serialization.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class CreateVectorStoreFileBatchRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateVectorStoreFileBatchRequest)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + if (Optional.IsDefined(ChunkingStrategy)) + { + writer.WritePropertyName("chunking_strategy"u8); + writer.WriteObjectValue(ChunkingStrategy, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CreateVectorStoreFileBatchRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateVectorStoreFileBatchRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateVectorStoreFileBatchRequest(document.RootElement, options); + } + + internal static CreateVectorStoreFileBatchRequest DeserializeCreateVectorStoreFileBatchRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList fileIds = default; + VectorStoreChunkingStrategyRequest chunkingStrategy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_ids"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + fileIds = array; + continue; + } + if (property.NameEquals("chunking_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + chunkingStrategy = VectorStoreChunkingStrategyRequest.DeserializeVectorStoreChunkingStrategyRequest(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CreateVectorStoreFileBatchRequest(fileIds, chunkingStrategy, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CreateVectorStoreFileBatchRequest)} does not support writing '{options.Format}' format."); + } + } + + CreateVectorStoreFileBatchRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCreateVectorStoreFileBatchRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateVectorStoreFileBatchRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CreateVectorStoreFileBatchRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeCreateVectorStoreFileBatchRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateVectorStoreFileBatchRequest.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateVectorStoreFileBatchRequest.cs new file mode 100644 index 000000000000..ae91f3b2fed8 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateVectorStoreFileBatchRequest.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The CreateVectorStoreFileBatchRequest. + internal partial class CreateVectorStoreFileBatchRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// A list of File IDs that the vector store should use. Useful for tools like `file_search` that can access files. + /// is null. + internal CreateVectorStoreFileBatchRequest(IEnumerable fileIds) + { + Argument.AssertNotNull(fileIds, nameof(fileIds)); + + FileIds = fileIds.ToList(); + } + + /// Initializes a new instance of . + /// A list of File IDs that the vector store should use. Useful for tools like `file_search` that can access files. + /// + /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// Keeps track of any properties unknown to the library. + internal CreateVectorStoreFileBatchRequest(IReadOnlyList fileIds, VectorStoreChunkingStrategyRequest chunkingStrategy, IDictionary serializedAdditionalRawData) + { + FileIds = fileIds; + ChunkingStrategy = chunkingStrategy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CreateVectorStoreFileBatchRequest() + { + } + + /// A list of File IDs that the vector store should use. Useful for tools like `file_search` that can access files. + public IReadOnlyList FileIds { get; } + /// + /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public VectorStoreChunkingStrategyRequest ChunkingStrategy { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateVectorStoreFileRequest.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateVectorStoreFileRequest.Serialization.cs new file mode 100644 index 000000000000..7b1a5bf6ac82 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateVectorStoreFileRequest.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class CreateVectorStoreFileRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateVectorStoreFileRequest)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + if (Optional.IsDefined(ChunkingStrategy)) + { + writer.WritePropertyName("chunking_strategy"u8); + writer.WriteObjectValue(ChunkingStrategy, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + CreateVectorStoreFileRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateVectorStoreFileRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateVectorStoreFileRequest(document.RootElement, options); + } + + internal static CreateVectorStoreFileRequest DeserializeCreateVectorStoreFileRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + VectorStoreChunkingStrategyRequest chunkingStrategy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (property.NameEquals("chunking_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + chunkingStrategy = VectorStoreChunkingStrategyRequest.DeserializeVectorStoreChunkingStrategyRequest(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CreateVectorStoreFileRequest(fileId, chunkingStrategy, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CreateVectorStoreFileRequest)} does not support writing '{options.Format}' format."); + } + } + + CreateVectorStoreFileRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeCreateVectorStoreFileRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateVectorStoreFileRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CreateVectorStoreFileRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeCreateVectorStoreFileRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateVectorStoreFileRequest.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateVectorStoreFileRequest.cs new file mode 100644 index 000000000000..fdda0a8891d1 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateVectorStoreFileRequest.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The CreateVectorStoreFileRequest. + internal partial class CreateVectorStoreFileRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// A File ID that the vector store should use. Useful for tools like `file_search` that can access files. + /// is null. + internal CreateVectorStoreFileRequest(string fileId) + { + Argument.AssertNotNull(fileId, nameof(fileId)); + + FileId = fileId; + } + + /// Initializes a new instance of . + /// A File ID that the vector store should use. Useful for tools like `file_search` that can access files. + /// + /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// Keeps track of any properties unknown to the library. + internal CreateVectorStoreFileRequest(string fileId, VectorStoreChunkingStrategyRequest chunkingStrategy, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + ChunkingStrategy = chunkingStrategy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CreateVectorStoreFileRequest() + { + } + + /// A File ID that the vector store should use. Useful for tools like `file_search` that can access files. + public string FileId { get; } + /// + /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public VectorStoreChunkingStrategyRequest ChunkingStrategy { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/DoneEvent.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/DoneEvent.cs new file mode 100644 index 000000000000..bf4a9d6aa6b9 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/DoneEvent.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Terminal event indicating the successful end of a stream. + public readonly partial struct DoneEvent : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DoneEvent(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string DoneValue = "done"; + + /// Event sent when the stream is done. + public static DoneEvent Done { get; } = new DoneEvent(DoneValue); + /// Determines if two values are the same. + public static bool operator ==(DoneEvent left, DoneEvent right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DoneEvent left, DoneEvent right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator DoneEvent(string value) => new DoneEvent(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DoneEvent other && Equals(other); + /// + public bool Equals(DoneEvent other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ErrorEvent.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ErrorEvent.cs new file mode 100644 index 000000000000..3fdf835fe1a1 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ErrorEvent.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Terminal event indicating a server side error while streaming. + public readonly partial struct ErrorEvent : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ErrorEvent(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ErrorValue = "error"; + + /// Event sent when an error occurs, such as an internal server error or a timeout. + public static ErrorEvent Error { get; } = new ErrorEvent(ErrorValue); + /// Determines if two values are the same. + public static bool operator ==(ErrorEvent left, ErrorEvent right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ErrorEvent left, ErrorEvent right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ErrorEvent(string value) => new ErrorEvent(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ErrorEvent other && Equals(other); + /// + public bool Equals(ErrorEvent other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolDefinition.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolDefinition.Serialization.cs new file mode 100644 index 000000000000..044e4cfb677f --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolDefinition.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class FileSearchToolDefinition : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileSearchToolDefinition)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(FileSearch)) + { + writer.WritePropertyName("file_search"u8); + writer.WriteObjectValue(FileSearch, options); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + FileSearchToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileSearchToolDefinition)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileSearchToolDefinition(document.RootElement, options); + } + + internal static FileSearchToolDefinition DeserializeFileSearchToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + FileSearchToolDefinitionDetails fileSearch = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_search"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fileSearch = FileSearchToolDefinitionDetails.DeserializeFileSearchToolDefinitionDetails(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FileSearchToolDefinition(type, serializedAdditionalRawData, fileSearch); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FileSearchToolDefinition)} does not support writing '{options.Format}' format."); + } + } + + FileSearchToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFileSearchToolDefinition(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileSearchToolDefinition)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new FileSearchToolDefinition FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFileSearchToolDefinition(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolDefinition.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolDefinition.cs new file mode 100644 index 000000000000..e68594b90832 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolDefinition.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The input definition information for a file search tool as used to configure an assistant. + public partial class FileSearchToolDefinition : ToolDefinition + { + /// Initializes a new instance of . + public FileSearchToolDefinition() + { + Type = "file_search"; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// Options overrides for the file search tool. + internal FileSearchToolDefinition(string type, IDictionary serializedAdditionalRawData, FileSearchToolDefinitionDetails fileSearch) : base(type, serializedAdditionalRawData) + { + FileSearch = fileSearch; + } + + /// Options overrides for the file search tool. + public FileSearchToolDefinitionDetails FileSearch { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolDefinitionDetails.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolDefinitionDetails.Serialization.cs new file mode 100644 index 000000000000..e1f77ecfcfbb --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolDefinitionDetails.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class FileSearchToolDefinitionDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileSearchToolDefinitionDetails)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(MaxNumResults)) + { + writer.WritePropertyName("max_num_results"u8); + writer.WriteNumberValue(MaxNumResults.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + FileSearchToolDefinitionDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileSearchToolDefinitionDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileSearchToolDefinitionDetails(document.RootElement, options); + } + + internal static FileSearchToolDefinitionDetails DeserializeFileSearchToolDefinitionDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int? maxNumResults = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("max_num_results"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxNumResults = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FileSearchToolDefinitionDetails(maxNumResults, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FileSearchToolDefinitionDetails)} does not support writing '{options.Format}' format."); + } + } + + FileSearchToolDefinitionDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFileSearchToolDefinitionDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileSearchToolDefinitionDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static FileSearchToolDefinitionDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFileSearchToolDefinitionDetails(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolDefinitionDetails.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolDefinitionDetails.cs new file mode 100644 index 000000000000..019548640805 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolDefinitionDetails.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Options overrides for the file search tool. + public partial class FileSearchToolDefinitionDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public FileSearchToolDefinitionDetails() + { + } + + /// Initializes a new instance of . + /// + /// The maximum number of results the file search tool should output. The default is 20 for gpt-4* models and 5 for gpt-3.5-turbo. This number should be between 1 and 50 inclusive. + /// + /// Note that the file search tool may output fewer than `max_num_results` results. See the file search tool documentation for more information. + /// + /// Keeps track of any properties unknown to the library. + internal FileSearchToolDefinitionDetails(int? maxNumResults, IDictionary serializedAdditionalRawData) + { + MaxNumResults = maxNumResults; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// The maximum number of results the file search tool should output. The default is 20 for gpt-4* models and 5 for gpt-3.5-turbo. This number should be between 1 and 50 inclusive. + /// + /// Note that the file search tool may output fewer than `max_num_results` results. See the file search tool documentation for more information. + /// + public int? MaxNumResults { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolResource.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolResource.Serialization.cs new file mode 100644 index 000000000000..eeeba6c1ad6f --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolResource.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class FileSearchToolResource : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileSearchToolResource)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(VectorStoreIds)) + { + writer.WritePropertyName("vector_store_ids"u8); + writer.WriteStartArray(); + foreach (var item in VectorStoreIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + FileSearchToolResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileSearchToolResource)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileSearchToolResource(document.RootElement, options); + } + + internal static FileSearchToolResource DeserializeFileSearchToolResource(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList vectorStoreIds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("vector_store_ids"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + vectorStoreIds = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FileSearchToolResource(vectorStoreIds ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FileSearchToolResource)} does not support writing '{options.Format}' format."); + } + } + + FileSearchToolResource IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFileSearchToolResource(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileSearchToolResource)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static FileSearchToolResource FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFileSearchToolResource(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolResource.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolResource.cs new file mode 100644 index 000000000000..94422e677d08 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileSearchToolResource.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// A set of resources that are used by the `file_search` tool. + public partial class FileSearchToolResource + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal FileSearchToolResource() + { + VectorStoreIds = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// The ID of the vector store attached to this assistant. There can be a maximum of 1 vector + /// store attached to the assistant. + /// + /// Keeps track of any properties unknown to the library. + internal FileSearchToolResource(IReadOnlyList vectorStoreIds, IDictionary serializedAdditionalRawData) + { + VectorStoreIds = vectorStoreIds; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// The ID of the vector store attached to this assistant. There can be a maximum of 1 vector + /// store attached to the assistant. + /// + public IReadOnlyList VectorStoreIds { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileState.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileState.cs new file mode 100644 index 000000000000..9d5974bd8a45 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FileState.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The state of the file. + public readonly partial struct FileState : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public FileState(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string UploadedValue = "uploaded"; + private const string PendingValue = "pending"; + private const string RunningValue = "running"; + private const string ProcessedValue = "processed"; + private const string ErrorValue = "error"; + private const string DeletingValue = "deleting"; + private const string DeletedValue = "deleted"; + + /// + /// The file has been uploaded but it's not yet processed. This state is not returned by Azure OpenAI and exposed only for + /// compatibility. It can be categorized as an inactive state. + /// + public static FileState Uploaded { get; } = new FileState(UploadedValue); + /// The operation was created and is not queued to be processed in the future. It can be categorized as an inactive state. + public static FileState Pending { get; } = new FileState(PendingValue); + /// The operation has started to be processed. It can be categorized as an active state. + public static FileState Running { get; } = new FileState(RunningValue); + /// The operation has successfully processed and is ready for consumption. It can be categorized as a terminal state. + public static FileState Processed { get; } = new FileState(ProcessedValue); + /// The operation has completed processing with a failure and cannot be further consumed. It can be categorized as a terminal state. + public static FileState Error { get; } = new FileState(ErrorValue); + /// + /// The entity is in the process to be deleted. This state is not returned by Azure OpenAI and exposed only for compatibility. + /// It can be categorized as an active state. + /// + public static FileState Deleting { get; } = new FileState(DeletingValue); + /// + /// The entity has been deleted but may still be referenced by other entities predating the deletion. It can be categorized as a + /// terminal state. + /// + public static FileState Deleted { get; } = new FileState(DeletedValue); + /// Determines if two values are the same. + public static bool operator ==(FileState left, FileState right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(FileState left, FileState right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator FileState(string value) => new FileState(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is FileState other && Equals(other); + /// + public bool Equals(FileState other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FunctionName.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FunctionName.Serialization.cs new file mode 100644 index 000000000000..1af0a6d26063 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FunctionName.Serialization.cs @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class FunctionName : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FunctionName)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + FunctionName IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FunctionName)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFunctionName(document.RootElement, options); + } + + internal static FunctionName DeserializeFunctionName(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FunctionName(name, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FunctionName)} does not support writing '{options.Format}' format."); + } + } + + FunctionName IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeFunctionName(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FunctionName)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static FunctionName FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeFunctionName(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FunctionName.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FunctionName.cs new file mode 100644 index 000000000000..70fcf993d4ae --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/FunctionName.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The function name that will be used, if using the `function` tool. + public partial class FunctionName + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The name of the function to call. + /// is null. + public FunctionName(string name) + { + Argument.AssertNotNull(name, nameof(name)); + + Name = name; + } + + /// Initializes a new instance of . + /// The name of the function to call. + /// Keeps track of any properties unknown to the library. + internal FunctionName(string name, IDictionary serializedAdditionalRawData) + { + Name = name; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FunctionName() + { + } + + /// The name of the function to call. + public string Name { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/IncompleteRunDetails.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/IncompleteRunDetails.cs new file mode 100644 index 000000000000..3b7a7240a624 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/IncompleteRunDetails.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The reason why the run is incomplete. This will point to which specific token limit was reached over the course of the run. + public readonly partial struct IncompleteRunDetails : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public IncompleteRunDetails(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string MaxCompletionTokensValue = "max_completion_tokens"; + private const string MaxPromptTokensValue = "max_prompt_tokens"; + + /// Maximum completion tokens exceeded. + public static IncompleteRunDetails MaxCompletionTokens { get; } = new IncompleteRunDetails(MaxCompletionTokensValue); + /// Maximum prompt tokens exceeded. + public static IncompleteRunDetails MaxPromptTokens { get; } = new IncompleteRunDetails(MaxPromptTokensValue); + /// Determines if two values are the same. + public static bool operator ==(IncompleteRunDetails left, IncompleteRunDetails right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(IncompleteRunDetails left, IncompleteRunDetails right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator IncompleteRunDetails(string value) => new IncompleteRunDetails(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is IncompleteRunDetails other && Equals(other); + /// + public bool Equals(IncompleteRunDetails other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatusObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatusObject.cs deleted file mode 100644 index 36254df4eba7..000000000000 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatusObject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.OpenAI.Assistants -{ - /// The InternalAssistantFileDeletionStatus_object. - internal readonly partial struct InternalAssistantFileDeletionStatusObject : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public InternalAssistantFileDeletionStatusObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string AssistantFileDeletedValue = "assistant.file.deleted"; - - /// assistant.file.deleted. - public static InternalAssistantFileDeletionStatusObject AssistantFileDeleted { get; } = new InternalAssistantFileDeletionStatusObject(AssistantFileDeletedValue); - /// Determines if two values are the same. - public static bool operator ==(InternalAssistantFileDeletionStatusObject left, InternalAssistantFileDeletionStatusObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(InternalAssistantFileDeletionStatusObject left, InternalAssistantFileDeletionStatusObject right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator InternalAssistantFileDeletionStatusObject(string value) => new InternalAssistantFileDeletionStatusObject(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is InternalAssistantFileDeletionStatusObject other && Equals(other); - /// - public bool Equals(InternalAssistantFileDeletionStatusObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// - public override string ToString() => _value; - } -} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageImageFileDetails.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageImageFileDetails.cs index eb315c465ad1..89cfab2a18a4 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageImageFileDetails.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageImageFileDetails.cs @@ -48,7 +48,7 @@ internal partial class InternalMessageImageFileDetails /// Initializes a new instance of . /// The ID for the file associated with this image. /// is null. - internal InternalMessageImageFileDetails(string internalDetails) + public InternalMessageImageFileDetails(string internalDetails) { Argument.AssertNotNull(internalDetails, nameof(internalDetails)); @@ -70,6 +70,6 @@ internal InternalMessageImageFileDetails() } /// The ID for the file associated with this image. - public string InternalDetails { get; } + public string InternalDetails { get; set; } } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextDetails.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextDetails.Serialization.cs index 29ffc7f46eb7..a181f9527cb5 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextDetails.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextDetails.Serialization.cs @@ -74,7 +74,7 @@ internal static InternalMessageTextDetails DeserializeInternalMessageTextDetails return null; } string value = default; - IReadOnlyList annotations = default; + IList annotations = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextDetails.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextDetails.cs index 7f6a60a62245..4489c4dd184e 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextDetails.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextDetails.cs @@ -54,7 +54,7 @@ internal partial class InternalMessageTextDetails /// The available derived classes include and . /// /// or is null. - internal InternalMessageTextDetails(string text, IEnumerable annotations) + public InternalMessageTextDetails(string text, IEnumerable annotations) { Argument.AssertNotNull(text, nameof(text)); Argument.AssertNotNull(annotations, nameof(annotations)); @@ -71,7 +71,7 @@ internal InternalMessageTextDetails(string text, IEnumerable and . /// /// Keeps track of any properties unknown to the library. - internal InternalMessageTextDetails(string text, IReadOnlyList annotations, IDictionary serializedAdditionalRawData) + internal InternalMessageTextDetails(string text, IList annotations, IDictionary serializedAdditionalRawData) { Text = text; Annotations = annotations; @@ -84,12 +84,12 @@ internal InternalMessageTextDetails() } /// The text data. - public string Text { get; } + public string Text { get; set; } /// /// A list of annotations associated with this text. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. /// The available derived classes include and . /// - public IReadOnlyList Annotations { get; } + public IList Annotations { get; } } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFileCitationDetails.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFileCitationDetails.cs index 3bbdf07622ce..158100231c04 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFileCitationDetails.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFileCitationDetails.cs @@ -49,7 +49,7 @@ internal partial class InternalMessageTextFileCitationDetails /// The ID of the file associated with this citation. /// The specific quote cited in the associated file. /// or is null. - internal InternalMessageTextFileCitationDetails(string fileId, string quote) + public InternalMessageTextFileCitationDetails(string fileId, string quote) { Argument.AssertNotNull(fileId, nameof(fileId)); Argument.AssertNotNull(quote, nameof(quote)); @@ -75,8 +75,8 @@ internal InternalMessageTextFileCitationDetails() } /// The ID of the file associated with this citation. - public string FileId { get; } + public string FileId { get; set; } /// The specific quote cited in the associated file. - public string Quote { get; } + public string Quote { get; set; } } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFilePathDetails.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFilePathDetails.cs index 4b86d66be5a2..f56d8a2f2cce 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFilePathDetails.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalMessageTextFilePathDetails.cs @@ -48,7 +48,7 @@ internal partial class InternalMessageTextFilePathDetails /// Initializes a new instance of . /// The ID of the specific file that the citation is from. /// is null. - internal InternalMessageTextFilePathDetails(string fileId) + public InternalMessageTextFilePathDetails(string fileId) { Argument.AssertNotNull(fileId, nameof(fileId)); @@ -70,6 +70,6 @@ internal InternalMessageTextFilePathDetails() } /// The ID of the specific file that the citation is from. - public string FileId { get; } + public string FileId { get; set; } } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageAttachment.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageAttachment.Serialization.cs new file mode 100644 index 000000000000..9a30136e04e3 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageAttachment.Serialization.cs @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class MessageAttachment : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageAttachment)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + writer.WritePropertyName("tools"u8); + writer.WriteStartArray(); + foreach (var item in Tools) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item); +#else + using (JsonDocument document = JsonDocument.Parse(item)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + MessageAttachment IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageAttachment)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageAttachment(document.RootElement, options); + } + + internal static MessageAttachment DeserializeMessageAttachment(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IList tools = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (property.NameEquals("tools"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + array.Add(BinaryData.FromString(item.GetRawText())); + } + } + tools = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageAttachment(fileId, tools, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageAttachment)} does not support writing '{options.Format}' format."); + } + } + + MessageAttachment IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageAttachment(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageAttachment)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageAttachment FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageAttachment(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageAttachment.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageAttachment.cs new file mode 100644 index 000000000000..f905e2a52576 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageAttachment.cs @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.OpenAI.Assistants +{ + /// This describes to which tools a file has been attached. + public partial class MessageAttachment + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ID of the file to attach to the message. + /// The tools to add to this file. + /// or is null. + public MessageAttachment(string fileId, IEnumerable tools) + { + Argument.AssertNotNull(fileId, nameof(fileId)); + Argument.AssertNotNull(tools, nameof(tools)); + + FileId = fileId; + Tools = tools.ToList(); + } + + /// Initializes a new instance of . + /// The ID of the file to attach to the message. + /// The tools to add to this file. + /// Keeps track of any properties unknown to the library. + internal MessageAttachment(string fileId, IList tools, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + Tools = tools; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MessageAttachment() + { + } + + /// The ID of the file to attach to the message. + public string FileId { get; set; } + /// + /// The tools to add to this file. + /// + /// To assign an object to the element of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// + /// Supported types: + /// + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IList Tools { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDelta.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDelta.Serialization.cs new file mode 100644 index 000000000000..8fbd90a6237b --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDelta.Serialization.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class MessageDelta : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDelta)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("role"u8); + writer.WriteStringValue(Role.ToString()); + writer.WritePropertyName("content"u8); + writer.WriteStartArray(); + foreach (var item in Content) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + MessageDelta IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDelta)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDelta(document.RootElement, options); + } + + internal static MessageDelta DeserializeMessageDelta(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageRole role = default; + IReadOnlyList content = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("role"u8)) + { + role = new MessageRole(property.Value.GetString()); + continue; + } + if (property.NameEquals("content"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MessageDeltaContent.DeserializeMessageDeltaContent(item, options)); + } + content = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDelta(role, content, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDelta)} does not support writing '{options.Format}' format."); + } + } + + MessageDelta IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageDelta(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDelta)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageDelta FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageDelta(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDelta.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDelta.cs new file mode 100644 index 000000000000..ec114efcb09d --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDelta.cs @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents the typed 'delta' payload within a streaming message delta chunk. + public partial class MessageDelta + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The entity that produced the message. + /// + /// The content of the message as an array of text and/or images. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// is null. + internal MessageDelta(MessageRole role, IEnumerable content) + { + Argument.AssertNotNull(content, nameof(content)); + + Role = role; + Content = content.ToList(); + } + + /// Initializes a new instance of . + /// The entity that produced the message. + /// + /// The content of the message as an array of text and/or images. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// Keeps track of any properties unknown to the library. + internal MessageDelta(MessageRole role, IReadOnlyList content, IDictionary serializedAdditionalRawData) + { + Role = role; + Content = content; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MessageDelta() + { + } + + /// The entity that produced the message. + public MessageRole Role { get; } + /// + /// The content of the message as an array of text and/or images. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public IReadOnlyList Content { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaChunk.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaChunk.Serialization.cs new file mode 100644 index 000000000000..0021de85df1f --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaChunk.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class MessageDeltaChunk : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaChunk)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("delta"u8); + writer.WriteObjectValue(Delta, options); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + MessageDeltaChunk IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaChunk)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaChunk(document.RootElement, options); + } + + internal static MessageDeltaChunk DeserializeMessageDeltaChunk(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + MessageDeltaChunkObject @object = default; + MessageDelta delta = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new MessageDeltaChunkObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("delta"u8)) + { + delta = MessageDelta.DeserializeMessageDelta(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeltaChunk(id, @object, delta, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaChunk)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaChunk IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageDeltaChunk(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaChunk)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageDeltaChunk FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageDeltaChunk(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageFile.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaChunk.cs similarity index 56% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageFile.cs rename to sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaChunk.cs index a33691868926..3a8984a1a101 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageFile.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaChunk.cs @@ -10,8 +10,8 @@ namespace Azure.AI.OpenAI.Assistants { - /// Information about a file attached to an assistant thread message. - public partial class MessageFile + /// Represents a message delta i.e. any changed fields on a message during streaming. + public partial class MessageDeltaChunk { /// /// Keeps track of any properties unknown to the library. @@ -45,47 +45,43 @@ public partial class MessageFile /// private IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . - /// The identifier, which can be referenced in API endpoints. - /// The Unix timestamp, in seconds, representing when this object was created. - /// The ID of the message that this file is attached to. - /// or is null. - internal MessageFile(string id, DateTimeOffset createdAt, string messageId) + /// Initializes a new instance of . + /// The identifier of the message, which can be referenced in API endpoints. + /// The delta containing the fields that have changed on the Message. + /// or is null. + internal MessageDeltaChunk(string id, MessageDelta delta) { Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(messageId, nameof(messageId)); + Argument.AssertNotNull(delta, nameof(delta)); Id = id; - CreatedAt = createdAt; - MessageId = messageId; + Delta = delta; } - /// Initializes a new instance of . - /// The identifier, which can be referenced in API endpoints. - /// The object type, which is always 'thread.message.file'. - /// The Unix timestamp, in seconds, representing when this object was created. - /// The ID of the message that this file is attached to. + /// Initializes a new instance of . + /// The identifier of the message, which can be referenced in API endpoints. + /// The object type, which is always `thread.message.delta`. + /// The delta containing the fields that have changed on the Message. /// Keeps track of any properties unknown to the library. - internal MessageFile(string id, string @object, DateTimeOffset createdAt, string messageId, IDictionary serializedAdditionalRawData) + internal MessageDeltaChunk(string id, MessageDeltaChunkObject @object, MessageDelta delta, IDictionary serializedAdditionalRawData) { Id = id; Object = @object; - CreatedAt = createdAt; - MessageId = messageId; + Delta = delta; _serializedAdditionalRawData = serializedAdditionalRawData; } - /// Initializes a new instance of for deserialization. - internal MessageFile() + /// Initializes a new instance of for deserialization. + internal MessageDeltaChunk() { } - /// The identifier, which can be referenced in API endpoints. + /// The identifier of the message, which can be referenced in API endpoints. public string Id { get; } + /// The object type, which is always `thread.message.delta`. + public MessageDeltaChunkObject Object { get; } = MessageDeltaChunkObject.ThreadMessageDelta; - /// The Unix timestamp, in seconds, representing when this object was created. - public DateTimeOffset CreatedAt { get; } - /// The ID of the message that this file is attached to. - public string MessageId { get; } + /// The delta containing the fields that have changed on the Message. + public MessageDelta Delta { get; } } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaChunkObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaChunkObject.cs new file mode 100644 index 000000000000..c2de57b59ac1 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaChunkObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The MessageDeltaChunk_object. + public readonly partial struct MessageDeltaChunkObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MessageDeltaChunkObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadMessageDeltaValue = "thread.message.delta"; + + /// thread.message.delta. + public static MessageDeltaChunkObject ThreadMessageDelta { get; } = new MessageDeltaChunkObject(ThreadMessageDeltaValue); + /// Determines if two values are the same. + public static bool operator ==(MessageDeltaChunkObject left, MessageDeltaChunkObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MessageDeltaChunkObject left, MessageDeltaChunkObject right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator MessageDeltaChunkObject(string value) => new MessageDeltaChunkObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MessageDeltaChunkObject other && Equals(other); + /// + public bool Equals(MessageDeltaChunkObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaContent.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaContent.Serialization.cs new file mode 100644 index 000000000000..772c6f38dba4 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaContent.Serialization.cs @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + [PersistableModelProxy(typeof(UnknownMessageDeltaContent))] + public partial class MessageDeltaContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaContent)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + MessageDeltaContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaContent(document.RootElement, options); + } + + internal static MessageDeltaContent DeserializeMessageDeltaContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "image_file": return MessageDeltaImageFileContent.DeserializeMessageDeltaImageFileContent(element, options); + case "text": return MessageDeltaTextContentObject.DeserializeMessageDeltaTextContentObject(element, options); + } + } + return UnknownMessageDeltaContent.DeserializeUnknownMessageDeltaContent(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaContent)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageDeltaContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageDeltaContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageDeltaContent(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaContent.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaContent.cs new file mode 100644 index 000000000000..454d8e437f56 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaContent.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// + /// The abstract base representation of a partial streamed message content payload. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public abstract partial class MessageDeltaContent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The index of the content part of the message. + protected MessageDeltaContent(int index) + { + Index = index; + } + + /// Initializes a new instance of . + /// The index of the content part of the message. + /// The type of content for this content part. + /// Keeps track of any properties unknown to the library. + internal MessageDeltaContent(int index, string type, IDictionary serializedAdditionalRawData) + { + Index = index; + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MessageDeltaContent() + { + } + + /// The index of the content part of the message. + public int Index { get; } + /// The type of content for this content part. + internal string Type { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaImageFileContent.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaImageFileContent.Serialization.cs new file mode 100644 index 000000000000..b5fb1b24e1d1 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaImageFileContent.Serialization.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class MessageDeltaImageFileContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaImageFileContent)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(ImageFile)) + { + writer.WritePropertyName("image_file"u8); + writer.WriteObjectValue(ImageFile, options); + } + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + MessageDeltaImageFileContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaImageFileContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaImageFileContent(document.RootElement, options); + } + + internal static MessageDeltaImageFileContent DeserializeMessageDeltaImageFileContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageDeltaImageFileContentObject imageFile = default; + int index = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("image_file"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + imageFile = MessageDeltaImageFileContentObject.DeserializeMessageDeltaImageFileContentObject(property.Value, options); + continue; + } + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeltaImageFileContent(index, type, serializedAdditionalRawData, imageFile); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaImageFileContent)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaImageFileContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageDeltaImageFileContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaImageFileContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MessageDeltaImageFileContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageDeltaImageFileContent(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaImageFileContent.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaImageFileContent.cs new file mode 100644 index 000000000000..212421c7c2e7 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaImageFileContent.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents a streamed image file content part within a streaming message delta chunk. + public partial class MessageDeltaImageFileContent : MessageDeltaContent + { + /// Initializes a new instance of . + /// The index of the content part of the message. + internal MessageDeltaImageFileContent(int index) : base(index) + { + Type = "image_file"; + } + + /// Initializes a new instance of . + /// The index of the content part of the message. + /// The type of content for this content part. + /// Keeps track of any properties unknown to the library. + /// The image_file data. + internal MessageDeltaImageFileContent(int index, string type, IDictionary serializedAdditionalRawData, MessageDeltaImageFileContentObject imageFile) : base(index, type, serializedAdditionalRawData) + { + ImageFile = imageFile; + } + + /// Initializes a new instance of for deserialization. + internal MessageDeltaImageFileContent() + { + } + + /// The image_file data. + public MessageDeltaImageFileContentObject ImageFile { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaImageFileContentObject.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaImageFileContentObject.Serialization.cs new file mode 100644 index 000000000000..058851b1fc5e --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaImageFileContentObject.Serialization.cs @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class MessageDeltaImageFileContentObject : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaImageFileContentObject)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + MessageDeltaImageFileContentObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaImageFileContentObject)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaImageFileContentObject(document.RootElement, options); + } + + internal static MessageDeltaImageFileContentObject DeserializeMessageDeltaImageFileContentObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeltaImageFileContentObject(fileId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaImageFileContentObject)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaImageFileContentObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageDeltaImageFileContentObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaImageFileContentObject)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageDeltaImageFileContentObject FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageDeltaImageFileContentObject(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaImageFileContentObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaImageFileContentObject.cs new file mode 100644 index 000000000000..592b0e9cef60 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaImageFileContentObject.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents the 'image_file' payload within streaming image file content. + public partial class MessageDeltaImageFileContentObject + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal MessageDeltaImageFileContentObject() + { + } + + /// Initializes a new instance of . + /// The file ID of the image in the message content. + /// Keeps track of any properties unknown to the library. + internal MessageDeltaImageFileContentObject(string fileId, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The file ID of the image in the message content. + public string FileId { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextAnnotation.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextAnnotation.Serialization.cs new file mode 100644 index 000000000000..d8cce0302222 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextAnnotation.Serialization.cs @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + [PersistableModelProxy(typeof(UnknownMessageDeltaTextAnnotation))] + public partial class MessageDeltaTextAnnotation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextAnnotation)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + MessageDeltaTextAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextAnnotation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaTextAnnotation(document.RootElement, options); + } + + internal static MessageDeltaTextAnnotation DeserializeMessageDeltaTextAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "file_citation": return MessageDeltaTextFileCitationAnnotationObject.DeserializeMessageDeltaTextFileCitationAnnotationObject(element, options); + case "file_path": return MessageDeltaTextFilePathAnnotationObject.DeserializeMessageDeltaTextFilePathAnnotationObject(element, options); + } + } + return UnknownMessageDeltaTextAnnotation.DeserializeUnknownMessageDeltaTextAnnotation(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaTextAnnotation)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaTextAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageDeltaTextAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaTextAnnotation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageDeltaTextAnnotation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageDeltaTextAnnotation(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextAnnotation.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextAnnotation.cs new file mode 100644 index 000000000000..2171bf6148cb --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextAnnotation.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// + /// The abstract base representation of a streamed text content part's text annotation. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public abstract partial class MessageDeltaTextAnnotation + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + protected MessageDeltaTextAnnotation(int index) + { + Index = index; + } + + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + /// The type of the text content annotation. + /// Keeps track of any properties unknown to the library. + internal MessageDeltaTextAnnotation(int index, string type, IDictionary serializedAdditionalRawData) + { + Index = index; + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MessageDeltaTextAnnotation() + { + } + + /// The index of the annotation within a text content part. + public int Index { get; } + /// The type of the text content annotation. + internal string Type { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextContent.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextContent.Serialization.cs new file mode 100644 index 000000000000..49e3cab4ca65 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextContent.Serialization.cs @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class MessageDeltaTextContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextContent)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + } + if (Optional.IsCollectionDefined(Annotations)) + { + writer.WritePropertyName("annotations"u8); + writer.WriteStartArray(); + foreach (var item in Annotations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + MessageDeltaTextContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaTextContent(document.RootElement, options); + } + + internal static MessageDeltaTextContent DeserializeMessageDeltaTextContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string value = default; + IReadOnlyList annotations = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + value = property.Value.GetString(); + continue; + } + if (property.NameEquals("annotations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MessageDeltaTextAnnotation.DeserializeMessageDeltaTextAnnotation(item, options)); + } + annotations = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeltaTextContent(value, annotations ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaTextContent)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaTextContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageDeltaTextContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaTextContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageDeltaTextContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageDeltaTextContent(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextContent.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextContent.cs new file mode 100644 index 000000000000..15c4cac2d7ca --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextContent.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents the data of a streamed text content part within a streaming message delta chunk. + public partial class MessageDeltaTextContent + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal MessageDeltaTextContent() + { + Annotations = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The data that makes up the text. + /// + /// Annotations for the text. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// Keeps track of any properties unknown to the library. + internal MessageDeltaTextContent(string value, IReadOnlyList annotations, IDictionary serializedAdditionalRawData) + { + Value = value; + Annotations = annotations; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The data that makes up the text. + public string Value { get; } + /// + /// Annotations for the text. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public IReadOnlyList Annotations { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextContentObject.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextContentObject.Serialization.cs new file mode 100644 index 000000000000..7261ccd92cb4 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextContentObject.Serialization.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class MessageDeltaTextContentObject : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextContentObject)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteObjectValue(Text, options); + } + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + MessageDeltaTextContentObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextContentObject)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaTextContentObject(document.RootElement, options); + } + + internal static MessageDeltaTextContentObject DeserializeMessageDeltaTextContentObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageDeltaTextContent text = default; + int index = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("text"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + text = MessageDeltaTextContent.DeserializeMessageDeltaTextContent(property.Value, options); + continue; + } + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeltaTextContentObject(index, type, serializedAdditionalRawData, text); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaTextContentObject)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaTextContentObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageDeltaTextContentObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaTextContentObject)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MessageDeltaTextContentObject FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageDeltaTextContentObject(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextContentObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextContentObject.cs new file mode 100644 index 000000000000..54247431988a --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextContentObject.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents a streamed text content part within a streaming message delta chunk. + public partial class MessageDeltaTextContentObject : MessageDeltaContent + { + /// Initializes a new instance of . + /// The index of the content part of the message. + internal MessageDeltaTextContentObject(int index) : base(index) + { + Type = "text"; + } + + /// Initializes a new instance of . + /// The index of the content part of the message. + /// The type of content for this content part. + /// Keeps track of any properties unknown to the library. + /// The text content details. + internal MessageDeltaTextContentObject(int index, string type, IDictionary serializedAdditionalRawData, MessageDeltaTextContent text) : base(index, type, serializedAdditionalRawData) + { + Text = text; + } + + /// Initializes a new instance of for deserialization. + internal MessageDeltaTextContentObject() + { + } + + /// The text content details. + public MessageDeltaTextContent Text { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFileCitationAnnotation.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFileCitationAnnotation.Serialization.cs new file mode 100644 index 000000000000..155551a551c7 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFileCitationAnnotation.Serialization.cs @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class MessageDeltaTextFileCitationAnnotation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextFileCitationAnnotation)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (Optional.IsDefined(Quote)) + { + writer.WritePropertyName("quote"u8); + writer.WriteStringValue(Quote); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + MessageDeltaTextFileCitationAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextFileCitationAnnotation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaTextFileCitationAnnotation(document.RootElement, options); + } + + internal static MessageDeltaTextFileCitationAnnotation DeserializeMessageDeltaTextFileCitationAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + string quote = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (property.NameEquals("quote"u8)) + { + quote = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeltaTextFileCitationAnnotation(fileId, quote, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaTextFileCitationAnnotation)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaTextFileCitationAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageDeltaTextFileCitationAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaTextFileCitationAnnotation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageDeltaTextFileCitationAnnotation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageDeltaTextFileCitationAnnotation(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFileCitationAnnotation.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFileCitationAnnotation.cs new file mode 100644 index 000000000000..6f2fd703c231 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFileCitationAnnotation.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents the data of a streamed file citation as applied to a streaming text content part. + public partial class MessageDeltaTextFileCitationAnnotation + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal MessageDeltaTextFileCitationAnnotation() + { + } + + /// Initializes a new instance of . + /// The ID of the specific file the citation is from. + /// The specific quote in the cited file. + /// Keeps track of any properties unknown to the library. + internal MessageDeltaTextFileCitationAnnotation(string fileId, string quote, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + Quote = quote; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The ID of the specific file the citation is from. + public string FileId { get; } + /// The specific quote in the cited file. + public string Quote { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFileCitationAnnotationObject.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFileCitationAnnotationObject.Serialization.cs new file mode 100644 index 000000000000..9fde82d67e2e --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFileCitationAnnotationObject.Serialization.cs @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class MessageDeltaTextFileCitationAnnotationObject : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextFileCitationAnnotationObject)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(FileCitation)) + { + writer.WritePropertyName("file_citation"u8); + writer.WriteObjectValue(FileCitation, options); + } + if (Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + if (Optional.IsDefined(StartIndex)) + { + writer.WritePropertyName("start_index"u8); + writer.WriteNumberValue(StartIndex.Value); + } + if (Optional.IsDefined(EndIndex)) + { + writer.WritePropertyName("end_index"u8); + writer.WriteNumberValue(EndIndex.Value); + } + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + MessageDeltaTextFileCitationAnnotationObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextFileCitationAnnotationObject)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaTextFileCitationAnnotationObject(document.RootElement, options); + } + + internal static MessageDeltaTextFileCitationAnnotationObject DeserializeMessageDeltaTextFileCitationAnnotationObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageDeltaTextFileCitationAnnotation fileCitation = default; + string text = default; + int? startIndex = default; + int? endIndex = default; + int index = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_citation"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fileCitation = MessageDeltaTextFileCitationAnnotation.DeserializeMessageDeltaTextFileCitationAnnotation(property.Value, options); + continue; + } + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (property.NameEquals("start_index"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("end_index"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeltaTextFileCitationAnnotationObject( + index, + type, + serializedAdditionalRawData, + fileCitation, + text, + startIndex, + endIndex); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaTextFileCitationAnnotationObject)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaTextFileCitationAnnotationObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageDeltaTextFileCitationAnnotationObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaTextFileCitationAnnotationObject)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MessageDeltaTextFileCitationAnnotationObject FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageDeltaTextFileCitationAnnotationObject(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFileCitationAnnotationObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFileCitationAnnotationObject.cs new file mode 100644 index 000000000000..1a67dafe8dfa --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFileCitationAnnotationObject.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents a streamed file citation applied to a streaming text content part. + public partial class MessageDeltaTextFileCitationAnnotationObject : MessageDeltaTextAnnotation + { + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + internal MessageDeltaTextFileCitationAnnotationObject(int index) : base(index) + { + Type = "file_citation"; + } + + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + /// The type of the text content annotation. + /// Keeps track of any properties unknown to the library. + /// The file citation information. + /// The text in the message content that needs to be replaced. + /// The start index of this annotation in the content text. + /// The end index of this annotation in the content text. + internal MessageDeltaTextFileCitationAnnotationObject(int index, string type, IDictionary serializedAdditionalRawData, MessageDeltaTextFileCitationAnnotation fileCitation, string text, int? startIndex, int? endIndex) : base(index, type, serializedAdditionalRawData) + { + FileCitation = fileCitation; + Text = text; + StartIndex = startIndex; + EndIndex = endIndex; + } + + /// Initializes a new instance of for deserialization. + internal MessageDeltaTextFileCitationAnnotationObject() + { + } + + /// The file citation information. + public MessageDeltaTextFileCitationAnnotation FileCitation { get; } + /// The text in the message content that needs to be replaced. + public string Text { get; } + /// The start index of this annotation in the content text. + public int? StartIndex { get; } + /// The end index of this annotation in the content text. + public int? EndIndex { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFilePathAnnotation.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFilePathAnnotation.Serialization.cs new file mode 100644 index 000000000000..dcbbf8904dde --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFilePathAnnotation.Serialization.cs @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class MessageDeltaTextFilePathAnnotation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextFilePathAnnotation)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + MessageDeltaTextFilePathAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextFilePathAnnotation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaTextFilePathAnnotation(document.RootElement, options); + } + + internal static MessageDeltaTextFilePathAnnotation DeserializeMessageDeltaTextFilePathAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeltaTextFilePathAnnotation(fileId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaTextFilePathAnnotation)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaTextFilePathAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageDeltaTextFilePathAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaTextFilePathAnnotation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageDeltaTextFilePathAnnotation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageDeltaTextFilePathAnnotation(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFilePathAnnotation.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFilePathAnnotation.cs new file mode 100644 index 000000000000..dbdd8626dc56 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFilePathAnnotation.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents the data of a streamed file path annotation as applied to a streaming text content part. + public partial class MessageDeltaTextFilePathAnnotation + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal MessageDeltaTextFilePathAnnotation() + { + } + + /// Initializes a new instance of . + /// The file ID for the annotation. + /// Keeps track of any properties unknown to the library. + internal MessageDeltaTextFilePathAnnotation(string fileId, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The file ID for the annotation. + public string FileId { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFilePathAnnotationObject.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFilePathAnnotationObject.Serialization.cs new file mode 100644 index 000000000000..2acabd3d49c5 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFilePathAnnotationObject.Serialization.cs @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class MessageDeltaTextFilePathAnnotationObject : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextFilePathAnnotationObject)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(FilePath)) + { + writer.WritePropertyName("file_path"u8); + writer.WriteObjectValue(FilePath, options); + } + if (Optional.IsDefined(StartIndex)) + { + writer.WritePropertyName("start_index"u8); + writer.WriteNumberValue(StartIndex.Value); + } + if (Optional.IsDefined(EndIndex)) + { + writer.WritePropertyName("end_index"u8); + writer.WriteNumberValue(EndIndex.Value); + } + if (Optional.IsDefined(Text)) + { + writer.WritePropertyName("text"u8); + writer.WriteStringValue(Text); + } + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + MessageDeltaTextFilePathAnnotationObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextFilePathAnnotationObject)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaTextFilePathAnnotationObject(document.RootElement, options); + } + + internal static MessageDeltaTextFilePathAnnotationObject DeserializeMessageDeltaTextFilePathAnnotationObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageDeltaTextFilePathAnnotation filePath = default; + int? startIndex = default; + int? endIndex = default; + string text = default; + int index = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_path"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + filePath = MessageDeltaTextFilePathAnnotation.DeserializeMessageDeltaTextFilePathAnnotation(property.Value, options); + continue; + } + if (property.NameEquals("start_index"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("end_index"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endIndex = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("text"u8)) + { + text = property.Value.GetString(); + continue; + } + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageDeltaTextFilePathAnnotationObject( + index, + type, + serializedAdditionalRawData, + filePath, + startIndex, + endIndex, + text); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaTextFilePathAnnotationObject)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaTextFilePathAnnotationObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageDeltaTextFilePathAnnotationObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaTextFilePathAnnotationObject)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MessageDeltaTextFilePathAnnotationObject FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageDeltaTextFilePathAnnotationObject(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFilePathAnnotationObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFilePathAnnotationObject.cs new file mode 100644 index 000000000000..85df4f20c57d --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageDeltaTextFilePathAnnotationObject.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents a streamed file path annotation applied to a streaming text content part. + public partial class MessageDeltaTextFilePathAnnotationObject : MessageDeltaTextAnnotation + { + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + internal MessageDeltaTextFilePathAnnotationObject(int index) : base(index) + { + Type = "file_path"; + } + + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + /// The type of the text content annotation. + /// Keeps track of any properties unknown to the library. + /// The file path information. + /// The start index of this annotation in the content text. + /// The end index of this annotation in the content text. + /// The text in the message content that needs to be replaced. + internal MessageDeltaTextFilePathAnnotationObject(int index, string type, IDictionary serializedAdditionalRawData, MessageDeltaTextFilePathAnnotation filePath, int? startIndex, int? endIndex, string text) : base(index, type, serializedAdditionalRawData) + { + FilePath = filePath; + StartIndex = startIndex; + EndIndex = endIndex; + Text = text; + } + + /// Initializes a new instance of for deserialization. + internal MessageDeltaTextFilePathAnnotationObject() + { + } + + /// The file path information. + public MessageDeltaTextFilePathAnnotation FilePath { get; } + /// The start index of this annotation in the content text. + public int? StartIndex { get; } + /// The end index of this annotation in the content text. + public int? EndIndex { get; } + /// The text in the message content that needs to be replaced. + public string Text { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageImageFileContent.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageImageFileContent.cs index 8997ff05b177..7e252658ea5e 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageImageFileContent.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageImageFileContent.cs @@ -16,7 +16,7 @@ public partial class MessageImageFileContent : MessageContent /// Initializes a new instance of . /// The image file for this thread message content item. /// is null. - internal MessageImageFileContent(InternalMessageImageFileDetails internalDetails) + public MessageImageFileContent(InternalMessageImageFileDetails internalDetails) { Argument.AssertNotNull(internalDetails, nameof(internalDetails)); diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageIncompleteDetails.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageIncompleteDetails.Serialization.cs new file mode 100644 index 000000000000..bee6aeb930a2 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageIncompleteDetails.Serialization.cs @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class MessageIncompleteDetails : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageIncompleteDetails)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("reason"u8); + writer.WriteStringValue(Reason.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + MessageIncompleteDetails IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageIncompleteDetails)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageIncompleteDetails(document.RootElement, options); + } + + internal static MessageIncompleteDetails DeserializeMessageIncompleteDetails(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + MessageIncompleteDetailsReason reason = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("reason"u8)) + { + reason = new MessageIncompleteDetailsReason(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MessageIncompleteDetails(reason, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageIncompleteDetails)} does not support writing '{options.Format}' format."); + } + } + + MessageIncompleteDetails IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageIncompleteDetails(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageIncompleteDetails)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static MessageIncompleteDetails FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeMessageIncompleteDetails(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageIncompleteDetails.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageIncompleteDetails.cs new file mode 100644 index 000000000000..335c1009db7f --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageIncompleteDetails.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Information providing additional detail about a message entering an incomplete status. + public partial class MessageIncompleteDetails + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The provided reason describing why the message was marked as incomplete. + public MessageIncompleteDetails(MessageIncompleteDetailsReason reason) + { + Reason = reason; + } + + /// Initializes a new instance of . + /// The provided reason describing why the message was marked as incomplete. + /// Keeps track of any properties unknown to the library. + internal MessageIncompleteDetails(MessageIncompleteDetailsReason reason, IDictionary serializedAdditionalRawData) + { + Reason = reason; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal MessageIncompleteDetails() + { + } + + /// The provided reason describing why the message was marked as incomplete. + public MessageIncompleteDetailsReason Reason { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageIncompleteDetailsReason.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageIncompleteDetailsReason.cs new file mode 100644 index 000000000000..f9150c24ffe5 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageIncompleteDetailsReason.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// A set of reasons describing why a message is marked as incomplete. + public readonly partial struct MessageIncompleteDetailsReason : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MessageIncompleteDetailsReason(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ContentFilterValue = "content_filter"; + private const string MaxTokensValue = "max_tokens"; + private const string RunCancelledValue = "run_cancelled"; + private const string RunFailedValue = "run_failed"; + private const string RunExpiredValue = "run_expired"; + + /// The run generating the message was terminated due to content filter flagging. + public static MessageIncompleteDetailsReason ContentFilter { get; } = new MessageIncompleteDetailsReason(ContentFilterValue); + /// The run generating the message exhausted available tokens before completion. + public static MessageIncompleteDetailsReason MaxTokens { get; } = new MessageIncompleteDetailsReason(MaxTokensValue); + /// The run generating the message was cancelled before completion. + public static MessageIncompleteDetailsReason RunCancelled { get; } = new MessageIncompleteDetailsReason(RunCancelledValue); + /// The run generating the message failed. + public static MessageIncompleteDetailsReason RunFailed { get; } = new MessageIncompleteDetailsReason(RunFailedValue); + /// The run generating the message expired. + public static MessageIncompleteDetailsReason RunExpired { get; } = new MessageIncompleteDetailsReason(RunExpiredValue); + /// Determines if two values are the same. + public static bool operator ==(MessageIncompleteDetailsReason left, MessageIncompleteDetailsReason right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MessageIncompleteDetailsReason left, MessageIncompleteDetailsReason right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator MessageIncompleteDetailsReason(string value) => new MessageIncompleteDetailsReason(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MessageIncompleteDetailsReason other && Equals(other); + /// + public bool Equals(MessageIncompleteDetailsReason other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageStatus.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageStatus.cs new file mode 100644 index 000000000000..55348664cda1 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageStatus.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The possible execution status values for a thread message. + public readonly partial struct MessageStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MessageStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InProgressValue = "in_progress"; + private const string IncompleteValue = "incomplete"; + private const string CompletedValue = "completed"; + + /// A run is currently creating this message. + public static MessageStatus InProgress { get; } = new MessageStatus(InProgressValue); + /// This message is incomplete. See incomplete_details for more information. + public static MessageStatus Incomplete { get; } = new MessageStatus(IncompleteValue); + /// This message was successfully completed by a run. + public static MessageStatus Completed { get; } = new MessageStatus(CompletedValue); + /// Determines if two values are the same. + public static bool operator ==(MessageStatus left, MessageStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MessageStatus left, MessageStatus right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator MessageStatus(string value) => new MessageStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MessageStatus other && Equals(other); + /// + public bool Equals(MessageStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageStreamEvent.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageStreamEvent.cs new file mode 100644 index 000000000000..89e5dcc131a5 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageStreamEvent.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Message operation related streaming events. + public readonly partial struct MessageStreamEvent : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public MessageStreamEvent(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadMessageCreatedValue = "thread.message.created"; + private const string ThreadMessageInProgressValue = "thread.message.in_progress"; + private const string ThreadMessageDeltaValue = "thread.message.delta"; + private const string ThreadMessageCompletedValue = "thread.message.completed"; + private const string ThreadMessageIncompleteValue = "thread.message.incomplete"; + + /// Event sent when a new message is created. The data of this event is of type ThreadMessage. + public static MessageStreamEvent ThreadMessageCreated { get; } = new MessageStreamEvent(ThreadMessageCreatedValue); + /// Event sent when a message moves to `in_progress` status. The data of this event is of type ThreadMessage. + public static MessageStreamEvent ThreadMessageInProgress { get; } = new MessageStreamEvent(ThreadMessageInProgressValue); + /// Event sent when a message is being streamed. The data of this event is of type MessageDeltaChunk. + public static MessageStreamEvent ThreadMessageDelta { get; } = new MessageStreamEvent(ThreadMessageDeltaValue); + /// Event sent when a message is completed. The data of this event is of type ThreadMessage. + public static MessageStreamEvent ThreadMessageCompleted { get; } = new MessageStreamEvent(ThreadMessageCompletedValue); + /// Event sent before a message is completed. The data of this event is of type ThreadMessage. + public static MessageStreamEvent ThreadMessageIncomplete { get; } = new MessageStreamEvent(ThreadMessageIncompleteValue); + /// Determines if two values are the same. + public static bool operator ==(MessageStreamEvent left, MessageStreamEvent right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MessageStreamEvent left, MessageStreamEvent right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator MessageStreamEvent(string value) => new MessageStreamEvent(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MessageStreamEvent other && Equals(other); + /// + public bool Equals(MessageStreamEvent other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextAnnotation.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextAnnotation.Serialization.cs index ae962644a772..99920983550d 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextAnnotation.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextAnnotation.Serialization.cs @@ -30,10 +30,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW writer.WriteStringValue(Type); writer.WritePropertyName("text"u8); writer.WriteStringValue(Text); - writer.WritePropertyName("start_index"u8); - writer.WriteNumberValue(StartIndex); - writer.WritePropertyName("end_index"u8); - writer.WriteNumberValue(EndIndex); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextAnnotation.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextAnnotation.cs index 082f8fea6a5b..aa8769d7ed21 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextAnnotation.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextAnnotation.cs @@ -51,30 +51,22 @@ public abstract partial class MessageTextAnnotation /// Initializes a new instance of . /// The textual content associated with this text annotation item. - /// The first text index associated with this text annotation. - /// The last text index associated with this text annotation. /// is null. - protected MessageTextAnnotation(string text, int startIndex, int endIndex) + protected MessageTextAnnotation(string text) { Argument.AssertNotNull(text, nameof(text)); Text = text; - StartIndex = startIndex; - EndIndex = endIndex; } /// Initializes a new instance of . /// The object type. /// The textual content associated with this text annotation item. - /// The first text index associated with this text annotation. - /// The last text index associated with this text annotation. /// Keeps track of any properties unknown to the library. - internal MessageTextAnnotation(string type, string text, int startIndex, int endIndex, IDictionary serializedAdditionalRawData) + internal MessageTextAnnotation(string type, string text, IDictionary serializedAdditionalRawData) { Type = type; Text = text; - StartIndex = startIndex; - EndIndex = endIndex; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -86,10 +78,6 @@ internal MessageTextAnnotation() /// The object type. internal string Type { get; set; } /// The textual content associated with this text annotation item. - public string Text { get; } - /// The first text index associated with this text annotation. - public int StartIndex { get; } - /// The last text index associated with this text annotation. - public int EndIndex { get; } + public string Text { get; set; } } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextContent.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextContent.cs index 61d7241bb927..ef579043014c 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextContent.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextContent.cs @@ -16,7 +16,7 @@ public partial class MessageTextContent : MessageContent /// Initializes a new instance of . /// The text and associated annotations for this thread message content item. /// is null. - internal MessageTextContent(InternalMessageTextDetails internalDetails) + public MessageTextContent(InternalMessageTextDetails internalDetails) { Argument.AssertNotNull(internalDetails, nameof(internalDetails)); diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFileCitationAnnotation.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFileCitationAnnotation.Serialization.cs index 986e6b38dfe0..858b184a6495 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFileCitationAnnotation.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFileCitationAnnotation.Serialization.cs @@ -28,14 +28,20 @@ void IJsonModel.Write(Utf8JsonWriter writer, writer.WriteStartObject(); writer.WritePropertyName("file_citation"u8); writer.WriteObjectValue(InternalDetails, options); + if (Optional.IsDefined(StartIndex)) + { + writer.WritePropertyName("start_index"u8); + writer.WriteNumberValue(StartIndex.Value); + } + if (Optional.IsDefined(EndIndex)) + { + writer.WritePropertyName("end_index"u8); + writer.WriteNumberValue(EndIndex.Value); + } writer.WritePropertyName("type"u8); writer.WriteStringValue(Type); writer.WritePropertyName("text"u8); writer.WriteStringValue(Text); - writer.WritePropertyName("start_index"u8); - writer.WriteNumberValue(StartIndex); - writer.WritePropertyName("end_index"u8); - writer.WriteNumberValue(EndIndex); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -75,10 +81,10 @@ internal static MessageTextFileCitationAnnotation DeserializeMessageTextFileCita return null; } InternalMessageTextFileCitationDetails fileCitation = default; + int? startIndex = default; + int? endIndex = default; string type = default; string text = default; - int startIndex = default; - int endIndex = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -88,24 +94,32 @@ internal static MessageTextFileCitationAnnotation DeserializeMessageTextFileCita fileCitation = InternalMessageTextFileCitationDetails.DeserializeInternalMessageTextFileCitationDetails(property.Value, options); continue; } - if (property.NameEquals("type"u8)) + if (property.NameEquals("start_index"u8)) { - type = property.Value.GetString(); + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startIndex = property.Value.GetInt32(); continue; } - if (property.NameEquals("text"u8)) + if (property.NameEquals("end_index"u8)) { - text = property.Value.GetString(); + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endIndex = property.Value.GetInt32(); continue; } - if (property.NameEquals("start_index"u8)) + if (property.NameEquals("type"u8)) { - startIndex = property.Value.GetInt32(); + type = property.Value.GetString(); continue; } - if (property.NameEquals("end_index"u8)) + if (property.NameEquals("text"u8)) { - endIndex = property.Value.GetInt32(); + text = property.Value.GetString(); continue; } if (options.Format != "W") @@ -117,10 +131,10 @@ internal static MessageTextFileCitationAnnotation DeserializeMessageTextFileCita return new MessageTextFileCitationAnnotation( type, text, - startIndex, - endIndex, serializedAdditionalRawData, - fileCitation); + fileCitation, + startIndex, + endIndex); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFileCitationAnnotation.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFileCitationAnnotation.cs index a036ec9b468b..6db943f9c9a3 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFileCitationAnnotation.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFileCitationAnnotation.cs @@ -10,19 +10,17 @@ namespace Azure.AI.OpenAI.Assistants { - /// A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the 'retrieval' tool to search files. + /// A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the 'file_search' tool to search files. public partial class MessageTextFileCitationAnnotation : MessageTextAnnotation { /// Initializes a new instance of . /// The textual content associated with this text annotation item. - /// The first text index associated with this text annotation. - /// The last text index associated with this text annotation. /// /// A citation within the message that points to a specific quote from a specific file. - /// Generated when the assistant uses the "retrieval" tool to search files. + /// Generated when the assistant uses the "file_search" tool to search files. /// /// or is null. - internal MessageTextFileCitationAnnotation(string text, int startIndex, int endIndex, InternalMessageTextFileCitationDetails internalDetails) : base(text, startIndex, endIndex) + public MessageTextFileCitationAnnotation(string text, InternalMessageTextFileCitationDetails internalDetails) : base(text) { Argument.AssertNotNull(text, nameof(text)); Argument.AssertNotNull(internalDetails, nameof(internalDetails)); @@ -34,21 +32,27 @@ internal MessageTextFileCitationAnnotation(string text, int startIndex, int endI /// Initializes a new instance of . /// The object type. /// The textual content associated with this text annotation item. - /// The first text index associated with this text annotation. - /// The last text index associated with this text annotation. /// Keeps track of any properties unknown to the library. /// /// A citation within the message that points to a specific quote from a specific file. - /// Generated when the assistant uses the "retrieval" tool to search files. + /// Generated when the assistant uses the "file_search" tool to search files. /// - internal MessageTextFileCitationAnnotation(string type, string text, int startIndex, int endIndex, IDictionary serializedAdditionalRawData, InternalMessageTextFileCitationDetails internalDetails) : base(type, text, startIndex, endIndex, serializedAdditionalRawData) + /// The first text index associated with this text annotation. + /// The last text index associated with this text annotation. + internal MessageTextFileCitationAnnotation(string type, string text, IDictionary serializedAdditionalRawData, InternalMessageTextFileCitationDetails internalDetails, int? startIndex, int? endIndex) : base(type, text, serializedAdditionalRawData) { InternalDetails = internalDetails; + StartIndex = startIndex; + EndIndex = endIndex; } /// Initializes a new instance of for deserialization. internal MessageTextFileCitationAnnotation() { } + /// The first text index associated with this text annotation. + public int? StartIndex { get; set; } + /// The last text index associated with this text annotation. + public int? EndIndex { get; set; } } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFilePathAnnotation.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFilePathAnnotation.Serialization.cs index 72659f5a0ea3..1b3342e369e5 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFilePathAnnotation.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFilePathAnnotation.Serialization.cs @@ -28,14 +28,20 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode writer.WriteStartObject(); writer.WritePropertyName("file_path"u8); writer.WriteObjectValue(InternalDetails, options); + if (Optional.IsDefined(StartIndex)) + { + writer.WritePropertyName("start_index"u8); + writer.WriteNumberValue(StartIndex.Value); + } + if (Optional.IsDefined(EndIndex)) + { + writer.WritePropertyName("end_index"u8); + writer.WriteNumberValue(EndIndex.Value); + } writer.WritePropertyName("type"u8); writer.WriteStringValue(Type); writer.WritePropertyName("text"u8); writer.WriteStringValue(Text); - writer.WritePropertyName("start_index"u8); - writer.WriteNumberValue(StartIndex); - writer.WritePropertyName("end_index"u8); - writer.WriteNumberValue(EndIndex); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -75,10 +81,10 @@ internal static MessageTextFilePathAnnotation DeserializeMessageTextFilePathAnno return null; } InternalMessageTextFilePathDetails filePath = default; + int? startIndex = default; + int? endIndex = default; string type = default; string text = default; - int startIndex = default; - int endIndex = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -88,24 +94,32 @@ internal static MessageTextFilePathAnnotation DeserializeMessageTextFilePathAnno filePath = InternalMessageTextFilePathDetails.DeserializeInternalMessageTextFilePathDetails(property.Value, options); continue; } - if (property.NameEquals("type"u8)) + if (property.NameEquals("start_index"u8)) { - type = property.Value.GetString(); + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startIndex = property.Value.GetInt32(); continue; } - if (property.NameEquals("text"u8)) + if (property.NameEquals("end_index"u8)) { - text = property.Value.GetString(); + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endIndex = property.Value.GetInt32(); continue; } - if (property.NameEquals("start_index"u8)) + if (property.NameEquals("type"u8)) { - startIndex = property.Value.GetInt32(); + type = property.Value.GetString(); continue; } - if (property.NameEquals("end_index"u8)) + if (property.NameEquals("text"u8)) { - endIndex = property.Value.GetInt32(); + text = property.Value.GetString(); continue; } if (options.Format != "W") @@ -117,10 +131,10 @@ internal static MessageTextFilePathAnnotation DeserializeMessageTextFilePathAnno return new MessageTextFilePathAnnotation( type, text, - startIndex, - endIndex, serializedAdditionalRawData, - filePath); + filePath, + startIndex, + endIndex); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFilePathAnnotation.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFilePathAnnotation.cs index 787c70831f54..276bb7ded43d 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFilePathAnnotation.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/MessageTextFilePathAnnotation.cs @@ -15,11 +15,9 @@ public partial class MessageTextFilePathAnnotation : MessageTextAnnotation { /// Initializes a new instance of . /// The textual content associated with this text annotation item. - /// The first text index associated with this text annotation. - /// The last text index associated with this text annotation. /// A URL for the file that's generated when the assistant used the code_interpreter tool to generate a file. /// or is null. - internal MessageTextFilePathAnnotation(string text, int startIndex, int endIndex, InternalMessageTextFilePathDetails internalDetails) : base(text, startIndex, endIndex) + public MessageTextFilePathAnnotation(string text, InternalMessageTextFilePathDetails internalDetails) : base(text) { Argument.AssertNotNull(text, nameof(text)); Argument.AssertNotNull(internalDetails, nameof(internalDetails)); @@ -31,18 +29,24 @@ internal MessageTextFilePathAnnotation(string text, int startIndex, int endIndex /// Initializes a new instance of . /// The object type. /// The textual content associated with this text annotation item. - /// The first text index associated with this text annotation. - /// The last text index associated with this text annotation. /// Keeps track of any properties unknown to the library. /// A URL for the file that's generated when the assistant used the code_interpreter tool to generate a file. - internal MessageTextFilePathAnnotation(string type, string text, int startIndex, int endIndex, IDictionary serializedAdditionalRawData, InternalMessageTextFilePathDetails internalDetails) : base(type, text, startIndex, endIndex, serializedAdditionalRawData) + /// The first text index associated with this text annotation. + /// The last text index associated with this text annotation. + internal MessageTextFilePathAnnotation(string type, string text, IDictionary serializedAdditionalRawData, InternalMessageTextFilePathDetails internalDetails, int? startIndex, int? endIndex) : base(type, text, serializedAdditionalRawData) { InternalDetails = internalDetails; + StartIndex = startIndex; + EndIndex = endIndex; } /// Initializes a new instance of for deserialization. internal MessageTextFilePathAnnotation() { } + /// The first text index associated with this text annotation. + public int? StartIndex { get; set; } + /// The last text index associated with this text annotation. + public int? EndIndex { get; set; } } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFile.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFile.Serialization.cs index e553361292ff..eabac96c3ba5 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFile.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFile.Serialization.cs @@ -38,6 +38,16 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOption writer.WriteNumberValue(CreatedAt, "U"); writer.WritePropertyName("purpose"u8); writer.WriteStringValue(Purpose.ToString()); + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.Value.ToString()); + } + if (Optional.IsDefined(StatusDetails)) + { + writer.WritePropertyName("status_details"u8); + writer.WriteStringValue(StatusDetails); + } if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -82,6 +92,8 @@ internal static OpenAIFile DeserializeOpenAIFile(JsonElement element, ModelReade string filename = default; DateTimeOffset createdAt = default; OpenAIFilePurpose purpose = default; + FileState? status = default; + string statusDetails = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -116,6 +128,20 @@ internal static OpenAIFile DeserializeOpenAIFile(JsonElement element, ModelReade purpose = new OpenAIFilePurpose(property.Value.GetString()); continue; } + if (property.NameEquals("status"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + status = new FileState(property.Value.GetString()); + continue; + } + if (property.NameEquals("status_details"u8)) + { + statusDetails = property.Value.GetString(); + continue; + } if (options.Format != "W") { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); @@ -129,6 +155,8 @@ internal static OpenAIFile DeserializeOpenAIFile(JsonElement element, ModelReade filename, createdAt, purpose, + status, + statusDetails, serializedAdditionalRawData); } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFile.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFile.cs index 318f90d4c5a5..29264237fe5a 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFile.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFile.cs @@ -71,8 +71,10 @@ internal OpenAIFile(string id, int size, string filename, DateTimeOffset created /// The name of the file. /// The Unix timestamp, in seconds, representing when this object was created. /// The intended purpose of a file. + /// The state of the file. This field is available in Azure OpenAI only. + /// The error message with details in case processing of this file failed. This field is available in Azure OpenAI only. /// Keeps track of any properties unknown to the library. - internal OpenAIFile(string @object, string id, int size, string filename, DateTimeOffset createdAt, OpenAIFilePurpose purpose, IDictionary serializedAdditionalRawData) + internal OpenAIFile(string @object, string id, int size, string filename, DateTimeOffset createdAt, OpenAIFilePurpose purpose, FileState? status, string statusDetails, IDictionary serializedAdditionalRawData) { Object = @object; Id = id; @@ -80,6 +82,8 @@ internal OpenAIFile(string @object, string id, int size, string filename, DateTi Filename = filename; CreatedAt = createdAt; Purpose = purpose; + Status = status; + StatusDetails = statusDetails; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -98,5 +102,9 @@ internal OpenAIFile() public DateTimeOffset CreatedAt { get; } /// The intended purpose of a file. public OpenAIFilePurpose Purpose { get; } + /// The state of the file. This field is available in Azure OpenAI only. + public FileState? Status { get; } + /// The error message with details in case processing of this file failed. This field is available in Azure OpenAI only. + public string StatusDetails { get; } } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFilePurpose.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFilePurpose.cs index a3042bc99ca0..93a7f55cebcf 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFilePurpose.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIFilePurpose.cs @@ -26,6 +26,9 @@ public OpenAIFilePurpose(string value) private const string FineTuneResultsValue = "fine-tune-results"; private const string AssistantsValue = "assistants"; private const string AssistantsOutputValue = "assistants_output"; + private const string BatchValue = "batch"; + private const string BatchOutputValue = "batch_output"; + private const string VisionValue = "vision"; /// Indicates a file is used for fine tuning input. public static OpenAIFilePurpose FineTune { get; } = new OpenAIFilePurpose(FineTuneValue); @@ -35,6 +38,12 @@ public OpenAIFilePurpose(string value) public static OpenAIFilePurpose Assistants { get; } = new OpenAIFilePurpose(AssistantsValue); /// Indicates a file is used as output by assistants. public static OpenAIFilePurpose AssistantsOutput { get; } = new OpenAIFilePurpose(AssistantsOutputValue); + /// Indicates a file is used as input to . + public static OpenAIFilePurpose Batch { get; } = new OpenAIFilePurpose(BatchValue); + /// Indicates a file is used as output by a vector store batch operation. + public static OpenAIFilePurpose BatchOutput { get; } = new OpenAIFilePurpose(BatchOutputValue); + /// Indicates a file is used as input to a vision operation. + public static OpenAIFilePurpose Vision { get; } = new OpenAIFilePurpose(VisionValue); /// Determines if two values are the same. public static bool operator ==(OpenAIFilePurpose left, OpenAIFilePurpose right) => left.Equals(right); /// Determines if two values are not the same. diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistantFileObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistantFileObject.cs deleted file mode 100644 index d78c3f2ed689..000000000000 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfAssistantFileObject.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ComponentModel; - -namespace Azure.AI.OpenAI.Assistants -{ - /// The OpenAIPageableListOfAssistantFile_object. - internal readonly partial struct OpenAIPageableListOfAssistantFileObject : IEquatable - { - private readonly string _value; - - /// Initializes a new instance of . - /// is null. - public OpenAIPageableListOfAssistantFileObject(string value) - { - _value = value ?? throw new ArgumentNullException(nameof(value)); - } - - private const string ListValue = "list"; - - /// list. - public static OpenAIPageableListOfAssistantFileObject List { get; } = new OpenAIPageableListOfAssistantFileObject(ListValue); - /// Determines if two values are the same. - public static bool operator ==(OpenAIPageableListOfAssistantFileObject left, OpenAIPageableListOfAssistantFileObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(OpenAIPageableListOfAssistantFileObject left, OpenAIPageableListOfAssistantFileObject right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator OpenAIPageableListOfAssistantFileObject(string value) => new OpenAIPageableListOfAssistantFileObject(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is OpenAIPageableListOfAssistantFileObject other && Equals(other); - /// - public bool Equals(OpenAIPageableListOfAssistantFileObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; - /// - public override string ToString() => _value; - } -} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalOpenAIPageableListOfMessageFile.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfVectorStore.Serialization.cs similarity index 64% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalOpenAIPageableListOfMessageFile.Serialization.cs rename to sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfVectorStore.Serialization.cs index 0fc4a1b175c0..1103b6e11633 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalOpenAIPageableListOfMessageFile.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfVectorStore.Serialization.cs @@ -13,16 +13,16 @@ namespace Azure.AI.OpenAI.Assistants { - internal partial class InternalOpenAIPageableListOfMessageFile : IUtf8JsonSerializable, IJsonModel + public partial class OpenAIPageableListOfVectorStore : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalOpenAIPageableListOfMessageFile)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(OpenAIPageableListOfVectorStore)} does not support writing '{format}' format."); } writer.WriteStartObject(); @@ -59,19 +59,19 @@ void IJsonModel.Write(Utf8JsonWriter wr writer.WriteEndObject(); } - InternalOpenAIPageableListOfMessageFile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + OpenAIPageableListOfVectorStore IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalOpenAIPageableListOfMessageFile)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(OpenAIPageableListOfVectorStore)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalOpenAIPageableListOfMessageFile(document.RootElement, options); + return DeserializeOpenAIPageableListOfVectorStore(document.RootElement, options); } - internal static InternalOpenAIPageableListOfMessageFile DeserializeInternalOpenAIPageableListOfMessageFile(JsonElement element, ModelReaderWriterOptions options = null) + internal static OpenAIPageableListOfVectorStore DeserializeOpenAIPageableListOfVectorStore(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -79,8 +79,8 @@ internal static InternalOpenAIPageableListOfMessageFile DeserializeInternalOpenA { return null; } - OpenAIPageableListOfMessageFileObject @object = default; - IReadOnlyList data = default; + OpenAIPageableListOfVectorStoreObject @object = default; + IReadOnlyList data = default; string firstId = default; string lastId = default; bool hasMore = default; @@ -90,15 +90,15 @@ internal static InternalOpenAIPageableListOfMessageFile DeserializeInternalOpenA { if (property.NameEquals("object"u8)) { - @object = new OpenAIPageableListOfMessageFileObject(property.Value.GetString()); + @object = new OpenAIPageableListOfVectorStoreObject(property.Value.GetString()); continue; } if (property.NameEquals("data"u8)) { - List array = new List(); + List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(MessageFile.DeserializeMessageFile(item, options)); + array.Add(VectorStore.DeserializeVectorStore(item, options)); } data = array; continue; @@ -124,7 +124,7 @@ internal static InternalOpenAIPageableListOfMessageFile DeserializeInternalOpenA } } serializedAdditionalRawData = rawDataDictionary; - return new InternalOpenAIPageableListOfMessageFile( + return new OpenAIPageableListOfVectorStore( @object, data, firstId, @@ -133,43 +133,43 @@ internal static InternalOpenAIPageableListOfMessageFile DeserializeInternalOpenA serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(InternalOpenAIPageableListOfMessageFile)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(OpenAIPageableListOfVectorStore)} does not support writing '{options.Format}' format."); } } - InternalOpenAIPageableListOfMessageFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + OpenAIPageableListOfVectorStore IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalOpenAIPageableListOfMessageFile(document.RootElement, options); + return DeserializeOpenAIPageableListOfVectorStore(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(InternalOpenAIPageableListOfMessageFile)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(OpenAIPageableListOfVectorStore)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static InternalOpenAIPageableListOfMessageFile FromResponse(Response response) + internal static OpenAIPageableListOfVectorStore FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalOpenAIPageableListOfMessageFile(document.RootElement); + return DeserializeOpenAIPageableListOfVectorStore(document.RootElement); } /// Convert into a . diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalOpenAIPageableListOfAssistantFile.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfVectorStore.cs similarity index 78% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalOpenAIPageableListOfAssistantFile.cs rename to sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfVectorStore.cs index 7b5f1581bf67..1cfa1fd0b07d 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalOpenAIPageableListOfAssistantFile.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfVectorStore.cs @@ -12,7 +12,7 @@ namespace Azure.AI.OpenAI.Assistants { /// The response data for a requested list of items. - internal partial class InternalOpenAIPageableListOfAssistantFile + public partial class OpenAIPageableListOfVectorStore { /// /// Keeps track of any properties unknown to the library. @@ -46,13 +46,13 @@ internal partial class InternalOpenAIPageableListOfAssistantFile /// private IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . + /// Initializes a new instance of . /// The requested list of items. /// The first ID represented in this list. /// The last ID represented in this list. /// A value indicating whether there are additional values available not captured in this list. /// , or is null. - internal InternalOpenAIPageableListOfAssistantFile(IEnumerable data, string firstId, string lastId, bool hasMore) + internal OpenAIPageableListOfVectorStore(IEnumerable data, string firstId, string lastId, bool hasMore) { Argument.AssertNotNull(data, nameof(data)); Argument.AssertNotNull(firstId, nameof(firstId)); @@ -64,14 +64,14 @@ internal InternalOpenAIPageableListOfAssistantFile(IEnumerable da HasMore = hasMore; } - /// Initializes a new instance of . + /// Initializes a new instance of . /// The object type, which is always list. /// The requested list of items. /// The first ID represented in this list. /// The last ID represented in this list. /// A value indicating whether there are additional values available not captured in this list. /// Keeps track of any properties unknown to the library. - internal InternalOpenAIPageableListOfAssistantFile(OpenAIPageableListOfAssistantFileObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) + internal OpenAIPageableListOfVectorStore(OpenAIPageableListOfVectorStoreObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) { Object = @object; Data = data; @@ -81,16 +81,16 @@ internal InternalOpenAIPageableListOfAssistantFile(OpenAIPageableListOfAssistant _serializedAdditionalRawData = serializedAdditionalRawData; } - /// Initializes a new instance of for deserialization. - internal InternalOpenAIPageableListOfAssistantFile() + /// Initializes a new instance of for deserialization. + internal OpenAIPageableListOfVectorStore() { } /// The object type, which is always list. - public OpenAIPageableListOfAssistantFileObject Object { get; } = OpenAIPageableListOfAssistantFileObject.List; + public OpenAIPageableListOfVectorStoreObject Object { get; } = OpenAIPageableListOfVectorStoreObject.List; /// The requested list of items. - public IReadOnlyList Data { get; } + public IReadOnlyList Data { get; } /// The first ID represented in this list. public string FirstId { get; } /// The last ID represented in this list. diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalOpenAIPageableListOfAssistantFile.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfVectorStoreFile.Serialization.cs similarity index 63% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalOpenAIPageableListOfAssistantFile.Serialization.cs rename to sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfVectorStoreFile.Serialization.cs index cd37f4181261..b388e3fa26fb 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalOpenAIPageableListOfAssistantFile.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfVectorStoreFile.Serialization.cs @@ -13,16 +13,16 @@ namespace Azure.AI.OpenAI.Assistants { - internal partial class InternalOpenAIPageableListOfAssistantFile : IUtf8JsonSerializable, IJsonModel + public partial class OpenAIPageableListOfVectorStoreFile : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalOpenAIPageableListOfAssistantFile)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(OpenAIPageableListOfVectorStoreFile)} does not support writing '{format}' format."); } writer.WriteStartObject(); @@ -59,19 +59,19 @@ void IJsonModel.Write(Utf8JsonWriter writer.WriteEndObject(); } - InternalOpenAIPageableListOfAssistantFile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + OpenAIPageableListOfVectorStoreFile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalOpenAIPageableListOfAssistantFile)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(OpenAIPageableListOfVectorStoreFile)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalOpenAIPageableListOfAssistantFile(document.RootElement, options); + return DeserializeOpenAIPageableListOfVectorStoreFile(document.RootElement, options); } - internal static InternalOpenAIPageableListOfAssistantFile DeserializeInternalOpenAIPageableListOfAssistantFile(JsonElement element, ModelReaderWriterOptions options = null) + internal static OpenAIPageableListOfVectorStoreFile DeserializeOpenAIPageableListOfVectorStoreFile(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -79,8 +79,8 @@ internal static InternalOpenAIPageableListOfAssistantFile DeserializeInternalOpe { return null; } - OpenAIPageableListOfAssistantFileObject @object = default; - IReadOnlyList data = default; + OpenAIPageableListOfVectorStoreFileObject @object = default; + IReadOnlyList data = default; string firstId = default; string lastId = default; bool hasMore = default; @@ -90,15 +90,15 @@ internal static InternalOpenAIPageableListOfAssistantFile DeserializeInternalOpe { if (property.NameEquals("object"u8)) { - @object = new OpenAIPageableListOfAssistantFileObject(property.Value.GetString()); + @object = new OpenAIPageableListOfVectorStoreFileObject(property.Value.GetString()); continue; } if (property.NameEquals("data"u8)) { - List array = new List(); + List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(AssistantFile.DeserializeAssistantFile(item, options)); + array.Add(VectorStoreFile.DeserializeVectorStoreFile(item, options)); } data = array; continue; @@ -124,7 +124,7 @@ internal static InternalOpenAIPageableListOfAssistantFile DeserializeInternalOpe } } serializedAdditionalRawData = rawDataDictionary; - return new InternalOpenAIPageableListOfAssistantFile( + return new OpenAIPageableListOfVectorStoreFile( @object, data, firstId, @@ -133,43 +133,43 @@ internal static InternalOpenAIPageableListOfAssistantFile DeserializeInternalOpe serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(InternalOpenAIPageableListOfAssistantFile)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(OpenAIPageableListOfVectorStoreFile)} does not support writing '{options.Format}' format."); } } - InternalOpenAIPageableListOfAssistantFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + OpenAIPageableListOfVectorStoreFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalOpenAIPageableListOfAssistantFile(document.RootElement, options); + return DeserializeOpenAIPageableListOfVectorStoreFile(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(InternalOpenAIPageableListOfAssistantFile)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(OpenAIPageableListOfVectorStoreFile)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static InternalOpenAIPageableListOfAssistantFile FromResponse(Response response) + internal static OpenAIPageableListOfVectorStoreFile FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalOpenAIPageableListOfAssistantFile(document.RootElement); + return DeserializeOpenAIPageableListOfVectorStoreFile(document.RootElement); } /// Convert into a . diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalOpenAIPageableListOfMessageFile.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfVectorStoreFile.cs similarity index 78% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalOpenAIPageableListOfMessageFile.cs rename to sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfVectorStoreFile.cs index 591f029940a1..8f4e487d59ad 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalOpenAIPageableListOfMessageFile.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfVectorStoreFile.cs @@ -12,7 +12,7 @@ namespace Azure.AI.OpenAI.Assistants { /// The response data for a requested list of items. - internal partial class InternalOpenAIPageableListOfMessageFile + public partial class OpenAIPageableListOfVectorStoreFile { /// /// Keeps track of any properties unknown to the library. @@ -46,13 +46,13 @@ internal partial class InternalOpenAIPageableListOfMessageFile /// private IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . + /// Initializes a new instance of . /// The requested list of items. /// The first ID represented in this list. /// The last ID represented in this list. /// A value indicating whether there are additional values available not captured in this list. /// , or is null. - internal InternalOpenAIPageableListOfMessageFile(IEnumerable data, string firstId, string lastId, bool hasMore) + internal OpenAIPageableListOfVectorStoreFile(IEnumerable data, string firstId, string lastId, bool hasMore) { Argument.AssertNotNull(data, nameof(data)); Argument.AssertNotNull(firstId, nameof(firstId)); @@ -64,14 +64,14 @@ internal InternalOpenAIPageableListOfMessageFile(IEnumerable data, HasMore = hasMore; } - /// Initializes a new instance of . + /// Initializes a new instance of . /// The object type, which is always list. /// The requested list of items. /// The first ID represented in this list. /// The last ID represented in this list. /// A value indicating whether there are additional values available not captured in this list. /// Keeps track of any properties unknown to the library. - internal InternalOpenAIPageableListOfMessageFile(OpenAIPageableListOfMessageFileObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) + internal OpenAIPageableListOfVectorStoreFile(OpenAIPageableListOfVectorStoreFileObject @object, IReadOnlyList data, string firstId, string lastId, bool hasMore, IDictionary serializedAdditionalRawData) { Object = @object; Data = data; @@ -81,16 +81,16 @@ internal InternalOpenAIPageableListOfMessageFile(OpenAIPageableListOfMessageFile _serializedAdditionalRawData = serializedAdditionalRawData; } - /// Initializes a new instance of for deserialization. - internal InternalOpenAIPageableListOfMessageFile() + /// Initializes a new instance of for deserialization. + internal OpenAIPageableListOfVectorStoreFile() { } /// The object type, which is always list. - public OpenAIPageableListOfMessageFileObject Object { get; } = OpenAIPageableListOfMessageFileObject.List; + public OpenAIPageableListOfVectorStoreFileObject Object { get; } = OpenAIPageableListOfVectorStoreFileObject.List; /// The requested list of items. - public IReadOnlyList Data { get; } + public IReadOnlyList Data { get; } /// The first ID represented in this list. public string FirstId { get; } /// The last ID represented in this list. diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfVectorStoreFileObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfVectorStoreFileObject.cs new file mode 100644 index 000000000000..9fea4860cb71 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfVectorStoreFileObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The OpenAIPageableListOfVectorStoreFile_object. + public readonly partial struct OpenAIPageableListOfVectorStoreFileObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public OpenAIPageableListOfVectorStoreFileObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ListValue = "list"; + + /// list. + public static OpenAIPageableListOfVectorStoreFileObject List { get; } = new OpenAIPageableListOfVectorStoreFileObject(ListValue); + /// Determines if two values are the same. + public static bool operator ==(OpenAIPageableListOfVectorStoreFileObject left, OpenAIPageableListOfVectorStoreFileObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OpenAIPageableListOfVectorStoreFileObject left, OpenAIPageableListOfVectorStoreFileObject right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator OpenAIPageableListOfVectorStoreFileObject(string value) => new OpenAIPageableListOfVectorStoreFileObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is OpenAIPageableListOfVectorStoreFileObject other && Equals(other); + /// + public bool Equals(OpenAIPageableListOfVectorStoreFileObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfMessageFileObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfVectorStoreObject.cs similarity index 56% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfMessageFileObject.cs rename to sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfVectorStoreObject.cs index 3fe2e03e3e68..ebabb0a4b304 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfMessageFileObject.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/OpenAIPageableListOfVectorStoreObject.cs @@ -10,14 +10,14 @@ namespace Azure.AI.OpenAI.Assistants { - /// The OpenAIPageableListOfMessageFile_object. - internal readonly partial struct OpenAIPageableListOfMessageFileObject : IEquatable + /// The OpenAIPageableListOfVectorStore_object. + public readonly partial struct OpenAIPageableListOfVectorStoreObject : IEquatable { private readonly string _value; - /// Initializes a new instance of . + /// Initializes a new instance of . /// is null. - public OpenAIPageableListOfMessageFileObject(string value) + public OpenAIPageableListOfVectorStoreObject(string value) { _value = value ?? throw new ArgumentNullException(nameof(value)); } @@ -25,19 +25,19 @@ public OpenAIPageableListOfMessageFileObject(string value) private const string ListValue = "list"; /// list. - public static OpenAIPageableListOfMessageFileObject List { get; } = new OpenAIPageableListOfMessageFileObject(ListValue); - /// Determines if two values are the same. - public static bool operator ==(OpenAIPageableListOfMessageFileObject left, OpenAIPageableListOfMessageFileObject right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(OpenAIPageableListOfMessageFileObject left, OpenAIPageableListOfMessageFileObject right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator OpenAIPageableListOfMessageFileObject(string value) => new OpenAIPageableListOfMessageFileObject(value); + public static OpenAIPageableListOfVectorStoreObject List { get; } = new OpenAIPageableListOfVectorStoreObject(ListValue); + /// Determines if two values are the same. + public static bool operator ==(OpenAIPageableListOfVectorStoreObject left, OpenAIPageableListOfVectorStoreObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(OpenAIPageableListOfVectorStoreObject left, OpenAIPageableListOfVectorStoreObject right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator OpenAIPageableListOfVectorStoreObject(string value) => new OpenAIPageableListOfVectorStoreObject(value); /// [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is OpenAIPageableListOfMessageFileObject other && Equals(other); + public override bool Equals(object obj) => obj is OpenAIPageableListOfVectorStoreObject other && Equals(other); /// - public bool Equals(OpenAIPageableListOfMessageFileObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + public bool Equals(OpenAIPageableListOfVectorStoreObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); /// [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RetrievalToolDefinition.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RetrievalToolDefinition.cs deleted file mode 100644 index f2f39855b348..000000000000 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RetrievalToolDefinition.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Assistants -{ - /// The input definition information for a retrieval tool as used to configure an assistant. - public partial class RetrievalToolDefinition : ToolDefinition - { - /// Initializes a new instance of . - public RetrievalToolDefinition() - { - Type = "retrieval"; - } - - /// Initializes a new instance of . - /// The object type. - /// Keeps track of any properties unknown to the library. - internal RetrievalToolDefinition(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) - { - } - } -} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunCompletionUsage.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunCompletionUsage.Serialization.cs new file mode 100644 index 000000000000..c7a00fd70182 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunCompletionUsage.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunCompletionUsage : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunCompletionUsage)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("completion_tokens"u8); + writer.WriteNumberValue(CompletionTokens); + writer.WritePropertyName("prompt_tokens"u8); + writer.WriteNumberValue(PromptTokens); + writer.WritePropertyName("total_tokens"u8); + writer.WriteNumberValue(TotalTokens); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunCompletionUsage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunCompletionUsage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunCompletionUsage(document.RootElement, options); + } + + internal static RunCompletionUsage DeserializeRunCompletionUsage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + long completionTokens = default; + long promptTokens = default; + long totalTokens = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("completion_tokens"u8)) + { + completionTokens = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("prompt_tokens"u8)) + { + promptTokens = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("total_tokens"u8)) + { + totalTokens = property.Value.GetInt64(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunCompletionUsage(completionTokens, promptTokens, totalTokens, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunCompletionUsage)} does not support writing '{options.Format}' format."); + } + } + + RunCompletionUsage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunCompletionUsage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunCompletionUsage)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunCompletionUsage FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunCompletionUsage(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunCompletionUsage.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunCompletionUsage.cs new file mode 100644 index 000000000000..2dfd3c2ee2c8 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunCompletionUsage.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + public partial class RunCompletionUsage + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Number of completion tokens used over the course of the run. + /// Number of prompt tokens used over the course of the run. + /// Total number of tokens used (prompt + completion). + internal RunCompletionUsage(long completionTokens, long promptTokens, long totalTokens) + { + CompletionTokens = completionTokens; + PromptTokens = promptTokens; + TotalTokens = totalTokens; + } + + /// Initializes a new instance of . + /// Number of completion tokens used over the course of the run. + /// Number of prompt tokens used over the course of the run. + /// Total number of tokens used (prompt + completion). + /// Keeps track of any properties unknown to the library. + internal RunCompletionUsage(long completionTokens, long promptTokens, long totalTokens, IDictionary serializedAdditionalRawData) + { + CompletionTokens = completionTokens; + PromptTokens = promptTokens; + TotalTokens = totalTokens; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RunCompletionUsage() + { + } + + /// Number of completion tokens used over the course of the run. + public long CompletionTokens { get; } + /// Number of prompt tokens used over the course of the run. + public long PromptTokens { get; } + /// Total number of tokens used (prompt + completion). + public long TotalTokens { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStep.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStep.Serialization.cs index d1e90dfd8187..a1118659acac 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStep.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStep.Serialization.cs @@ -89,6 +89,18 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions o { writer.WriteNull("failed_at"); } + if (Optional.IsDefined(Usage)) + { + if (Usage != null) + { + writer.WritePropertyName("usage"u8); + writer.WriteObjectValue(Usage, options); + } + else + { + writer.WriteNull("usage"); + } + } if (Metadata != null && Optional.IsCollectionDefined(Metadata)) { writer.WritePropertyName("metadata"u8); @@ -156,6 +168,7 @@ internal static RunStep DeserializeRunStep(JsonElement element, ModelReaderWrite DateTimeOffset? completedAt = default; DateTimeOffset? cancelledAt = default; DateTimeOffset? failedAt = default; + RunStepCompletionUsage usage = default; IReadOnlyDictionary metadata = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); @@ -236,6 +249,16 @@ internal static RunStep DeserializeRunStep(JsonElement element, ModelReaderWrite DeserializeNullableDateTimeOffset(property, ref failedAt); continue; } + if (property.NameEquals("usage"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + usage = null; + continue; + } + usage = RunStepCompletionUsage.DeserializeRunStepCompletionUsage(property.Value, options); + continue; + } if (property.NameEquals("metadata"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -272,6 +295,7 @@ internal static RunStep DeserializeRunStep(JsonElement element, ModelReaderWrite completedAt, cancelledAt, failedAt, + usage, metadata, serializedAdditionalRawData); } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStep.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStep.cs index 9d8d21d55457..3b622f261eb6 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStep.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStep.cs @@ -108,9 +108,10 @@ internal RunStep(string id, RunStepType type, string assistantId, string threadI /// The Unix timestamp, in seconds, representing when this completed. /// The Unix timestamp, in seconds, representing when this was cancelled. /// The Unix timestamp, in seconds, representing when this failed. + /// Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// Keeps track of any properties unknown to the library. - internal RunStep(string id, string @object, RunStepType type, string assistantId, string threadId, string runId, RunStepStatus status, RunStepDetails stepDetails, RunStepError lastError, DateTimeOffset createdAt, DateTimeOffset? expiredAt, DateTimeOffset? completedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + internal RunStep(string id, string @object, RunStepType type, string assistantId, string threadId, string runId, RunStepStatus status, RunStepDetails stepDetails, RunStepError lastError, DateTimeOffset createdAt, DateTimeOffset? expiredAt, DateTimeOffset? completedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, RunStepCompletionUsage usage, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) { Id = id; Object = @object; @@ -126,6 +127,7 @@ internal RunStep(string id, string @object, RunStepType type, string assistantId CompletedAt = completedAt; CancelledAt = cancelledAt; FailedAt = failedAt; + Usage = usage; Metadata = metadata; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -166,6 +168,8 @@ internal RunStep() public DateTimeOffset? CancelledAt { get; } /// The Unix timestamp, in seconds, representing when this failed. public DateTimeOffset? FailedAt { get; } + /// Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. + public RunStepCompletionUsage Usage { get; } /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. public IReadOnlyDictionary Metadata { get; } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCompletionUsage.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCompletionUsage.Serialization.cs new file mode 100644 index 000000000000..11af2fe4c1ef --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCompletionUsage.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepCompletionUsage : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCompletionUsage)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("completion_tokens"u8); + writer.WriteNumberValue(CompletionTokens); + writer.WritePropertyName("prompt_tokens"u8); + writer.WriteNumberValue(PromptTokens); + writer.WritePropertyName("total_tokens"u8); + writer.WriteNumberValue(TotalTokens); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunStepCompletionUsage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepCompletionUsage)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepCompletionUsage(document.RootElement, options); + } + + internal static RunStepCompletionUsage DeserializeRunStepCompletionUsage(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + long completionTokens = default; + long promptTokens = default; + long totalTokens = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("completion_tokens"u8)) + { + completionTokens = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("prompt_tokens"u8)) + { + promptTokens = property.Value.GetInt64(); + continue; + } + if (property.NameEquals("total_tokens"u8)) + { + totalTokens = property.Value.GetInt64(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepCompletionUsage(completionTokens, promptTokens, totalTokens, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepCompletionUsage)} does not support writing '{options.Format}' format."); + } + } + + RunStepCompletionUsage IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepCompletionUsage(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepCompletionUsage)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepCompletionUsage FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepCompletionUsage(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCompletionUsage.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCompletionUsage.cs new file mode 100644 index 000000000000..738d57f0df80 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepCompletionUsage.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Usage statistics related to the run step. + public partial class RunStepCompletionUsage + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Number of completion tokens used over the course of the run step. + /// Number of prompt tokens used over the course of the run step. + /// Total number of tokens used (prompt + completion). + internal RunStepCompletionUsage(long completionTokens, long promptTokens, long totalTokens) + { + CompletionTokens = completionTokens; + PromptTokens = promptTokens; + TotalTokens = totalTokens; + } + + /// Initializes a new instance of . + /// Number of completion tokens used over the course of the run step. + /// Number of prompt tokens used over the course of the run step. + /// Total number of tokens used (prompt + completion). + /// Keeps track of any properties unknown to the library. + internal RunStepCompletionUsage(long completionTokens, long promptTokens, long totalTokens, IDictionary serializedAdditionalRawData) + { + CompletionTokens = completionTokens; + PromptTokens = promptTokens; + TotalTokens = totalTokens; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RunStepCompletionUsage() + { + } + + /// Number of completion tokens used over the course of the run step. + public long CompletionTokens { get; } + /// Number of prompt tokens used over the course of the run step. + public long PromptTokens { get; } + /// Total number of tokens used (prompt + completion). + public long TotalTokens { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDelta.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDelta.Serialization.cs new file mode 100644 index 000000000000..aa432bbe3d8d --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDelta.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepDelta : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDelta)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(StepDetails)) + { + writer.WritePropertyName("step_details"u8); + writer.WriteObjectValue(StepDetails, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunStepDelta IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDelta)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDelta(document.RootElement, options); + } + + internal static RunStepDelta DeserializeRunStepDelta(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepDeltaDetail stepDetails = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("step_details"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + stepDetails = RunStepDeltaDetail.DeserializeRunStepDeltaDetail(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDelta(stepDetails, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDelta)} does not support writing '{options.Format}' format."); + } + } + + RunStepDelta IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepDelta(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDelta)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepDelta FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepDelta(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDelta.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDelta.cs new file mode 100644 index 000000000000..9b28f292c68b --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDelta.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents the delta payload in a streaming run step delta chunk. + public partial class RunStepDelta + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal RunStepDelta() + { + } + + /// Initializes a new instance of . + /// + /// The details of the run step. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// Keeps track of any properties unknown to the library. + internal RunStepDelta(RunStepDeltaDetail stepDetails, IDictionary serializedAdditionalRawData) + { + StepDetails = stepDetails; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// The details of the run step. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public RunStepDeltaDetail StepDetails { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaChunk.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaChunk.Serialization.cs new file mode 100644 index 000000000000..2aa656e530bb --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaChunk.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepDeltaChunk : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaChunk)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("delta"u8); + writer.WriteObjectValue(Delta, options); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunStepDeltaChunk IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaChunk)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaChunk(document.RootElement, options); + } + + internal static RunStepDeltaChunk DeserializeRunStepDeltaChunk(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + RunStepDeltaChunkObject @object = default; + RunStepDelta delta = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new RunStepDeltaChunkObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("delta"u8)) + { + delta = RunStepDelta.DeserializeRunStepDelta(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaChunk(id, @object, delta, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaChunk)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaChunk IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepDeltaChunk(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaChunk)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepDeltaChunk FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepDeltaChunk(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantFile.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaChunk.cs similarity index 51% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantFile.cs rename to sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaChunk.cs index 119a216efc63..b577dd0a9f7d 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantFile.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaChunk.cs @@ -10,8 +10,8 @@ namespace Azure.AI.OpenAI.Assistants { - /// Information about a file attached to an assistant, as used by tools that can read files. - public partial class AssistantFile + /// Represents a run step delta i.e. any changed fields on a run step during streaming. + public partial class RunStepDeltaChunk { /// /// Keeps track of any properties unknown to the library. @@ -45,47 +45,43 @@ public partial class AssistantFile /// private IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . - /// The identifier, which can be referenced in API endpoints. - /// The Unix timestamp, in seconds, representing when this object was created. - /// The assistant ID that the file is attached to. - /// or is null. - internal AssistantFile(string id, DateTimeOffset createdAt, string assistantId) + /// Initializes a new instance of . + /// The identifier of the run step, which can be referenced in API endpoints. + /// The delta containing the fields that have changed on the run step. + /// or is null. + internal RunStepDeltaChunk(string id, RunStepDelta delta) { Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(assistantId, nameof(assistantId)); + Argument.AssertNotNull(delta, nameof(delta)); Id = id; - CreatedAt = createdAt; - AssistantId = assistantId; + Delta = delta; } - /// Initializes a new instance of . - /// The identifier, which can be referenced in API endpoints. - /// The object type, which is always 'assistant.file'. - /// The Unix timestamp, in seconds, representing when this object was created. - /// The assistant ID that the file is attached to. + /// Initializes a new instance of . + /// The identifier of the run step, which can be referenced in API endpoints. + /// The object type, which is always `thread.run.step.delta`. + /// The delta containing the fields that have changed on the run step. /// Keeps track of any properties unknown to the library. - internal AssistantFile(string id, string @object, DateTimeOffset createdAt, string assistantId, IDictionary serializedAdditionalRawData) + internal RunStepDeltaChunk(string id, RunStepDeltaChunkObject @object, RunStepDelta delta, IDictionary serializedAdditionalRawData) { Id = id; Object = @object; - CreatedAt = createdAt; - AssistantId = assistantId; + Delta = delta; _serializedAdditionalRawData = serializedAdditionalRawData; } - /// Initializes a new instance of for deserialization. - internal AssistantFile() + /// Initializes a new instance of for deserialization. + internal RunStepDeltaChunk() { } - /// The identifier, which can be referenced in API endpoints. + /// The identifier of the run step, which can be referenced in API endpoints. public string Id { get; } + /// The object type, which is always `thread.run.step.delta`. + public RunStepDeltaChunkObject Object { get; } = RunStepDeltaChunkObject.ThreadRunStepDelta; - /// The Unix timestamp, in seconds, representing when this object was created. - public DateTimeOffset CreatedAt { get; } - /// The assistant ID that the file is attached to. - public string AssistantId { get; } + /// The delta containing the fields that have changed on the run step. + public RunStepDelta Delta { get; } } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaChunkObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaChunkObject.cs new file mode 100644 index 000000000000..ad9ba4d22034 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaChunkObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The RunStepDeltaChunk_object. + public readonly partial struct RunStepDeltaChunkObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RunStepDeltaChunkObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadRunStepDeltaValue = "thread.run.step.delta"; + + /// thread.run.step.delta. + public static RunStepDeltaChunkObject ThreadRunStepDelta { get; } = new RunStepDeltaChunkObject(ThreadRunStepDeltaValue); + /// Determines if two values are the same. + public static bool operator ==(RunStepDeltaChunkObject left, RunStepDeltaChunkObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RunStepDeltaChunkObject left, RunStepDeltaChunkObject right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator RunStepDeltaChunkObject(string value) => new RunStepDeltaChunkObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunStepDeltaChunkObject other && Equals(other); + /// + public bool Equals(RunStepDeltaChunkObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.Serialization.cs new file mode 100644 index 000000000000..5e994dae2f13 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.Serialization.cs @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepDeltaCodeInterpreterDetailItemObject : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterDetailItemObject)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Input)) + { + writer.WritePropertyName("input"u8); + writer.WriteStringValue(Input); + } + if (Optional.IsCollectionDefined(Outputs)) + { + writer.WritePropertyName("outputs"u8); + writer.WriteStartArray(); + foreach (var item in Outputs) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunStepDeltaCodeInterpreterDetailItemObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterDetailItemObject)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaCodeInterpreterDetailItemObject(document.RootElement, options); + } + + internal static RunStepDeltaCodeInterpreterDetailItemObject DeserializeRunStepDeltaCodeInterpreterDetailItemObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string input = default; + IReadOnlyList outputs = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("input"u8)) + { + input = property.Value.GetString(); + continue; + } + if (property.NameEquals("outputs"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RunStepDeltaCodeInterpreterOutput.DeserializeRunStepDeltaCodeInterpreterOutput(item, options)); + } + outputs = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaCodeInterpreterDetailItemObject(input, outputs ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterDetailItemObject)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaCodeInterpreterDetailItemObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepDeltaCodeInterpreterDetailItemObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterDetailItemObject)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepDeltaCodeInterpreterDetailItemObject FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepDeltaCodeInterpreterDetailItemObject(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.cs new file mode 100644 index 000000000000..d3a655d903d0 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterDetailItemObject.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents the Code Interpreter tool call data in a streaming run step's tool calls. + public partial class RunStepDeltaCodeInterpreterDetailItemObject + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal RunStepDeltaCodeInterpreterDetailItemObject() + { + Outputs = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The input into the Code Interpreter tool call. + /// + /// The outputs from the Code Interpreter tool call. Code Interpreter can output one or more + /// items, including text (`logs`) or images (`image`). Each of these are represented by a + /// different object type. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// Keeps track of any properties unknown to the library. + internal RunStepDeltaCodeInterpreterDetailItemObject(string input, IReadOnlyList outputs, IDictionary serializedAdditionalRawData) + { + Input = input; + Outputs = outputs; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The input into the Code Interpreter tool call. + public string Input { get; } + /// + /// The outputs from the Code Interpreter tool call. Code Interpreter can output one or more + /// items, including text (`logs`) or images (`image`). Each of these are represented by a + /// different object type. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public IReadOnlyList Outputs { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterImageOutput.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterImageOutput.Serialization.cs new file mode 100644 index 000000000000..d04aca3ea636 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterImageOutput.Serialization.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepDeltaCodeInterpreterImageOutput : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterImageOutput)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Image)) + { + writer.WritePropertyName("image"u8); + writer.WriteObjectValue(Image, options); + } + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunStepDeltaCodeInterpreterImageOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterImageOutput)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaCodeInterpreterImageOutput(document.RootElement, options); + } + + internal static RunStepDeltaCodeInterpreterImageOutput DeserializeRunStepDeltaCodeInterpreterImageOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepDeltaCodeInterpreterImageOutputObject image = default; + int index = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("image"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + image = RunStepDeltaCodeInterpreterImageOutputObject.DeserializeRunStepDeltaCodeInterpreterImageOutputObject(property.Value, options); + continue; + } + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaCodeInterpreterImageOutput(index, type, serializedAdditionalRawData, image); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterImageOutput)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaCodeInterpreterImageOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepDeltaCodeInterpreterImageOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterImageOutput)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepDeltaCodeInterpreterImageOutput FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepDeltaCodeInterpreterImageOutput(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterImageOutput.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterImageOutput.cs new file mode 100644 index 000000000000..0d80fac4887c --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterImageOutput.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents an image output as produced the Code interpreter tool and as represented in a streaming run step's delta tool calls collection. + public partial class RunStepDeltaCodeInterpreterImageOutput : RunStepDeltaCodeInterpreterOutput + { + /// Initializes a new instance of . + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + internal RunStepDeltaCodeInterpreterImageOutput(int index) : base(index) + { + Type = "image"; + } + + /// Initializes a new instance of . + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + /// The type of the streaming run step tool call's Code Interpreter output. + /// Keeps track of any properties unknown to the library. + /// The image data for the Code Interpreter tool call output. + internal RunStepDeltaCodeInterpreterImageOutput(int index, string type, IDictionary serializedAdditionalRawData, RunStepDeltaCodeInterpreterImageOutputObject image) : base(index, type, serializedAdditionalRawData) + { + Image = image; + } + + /// Initializes a new instance of for deserialization. + internal RunStepDeltaCodeInterpreterImageOutput() + { + } + + /// The image data for the Code Interpreter tool call output. + public RunStepDeltaCodeInterpreterImageOutputObject Image { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.Serialization.cs new file mode 100644 index 000000000000..9322d0b4b1ee --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.Serialization.cs @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepDeltaCodeInterpreterImageOutputObject : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterImageOutputObject)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(FileId)) + { + writer.WritePropertyName("file_id"u8); + writer.WriteStringValue(FileId); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunStepDeltaCodeInterpreterImageOutputObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterImageOutputObject)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaCodeInterpreterImageOutputObject(document.RootElement, options); + } + + internal static RunStepDeltaCodeInterpreterImageOutputObject DeserializeRunStepDeltaCodeInterpreterImageOutputObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string fileId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_id"u8)) + { + fileId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaCodeInterpreterImageOutputObject(fileId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterImageOutputObject)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaCodeInterpreterImageOutputObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepDeltaCodeInterpreterImageOutputObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterImageOutputObject)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepDeltaCodeInterpreterImageOutputObject FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepDeltaCodeInterpreterImageOutputObject(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.cs new file mode 100644 index 000000000000..35c4bf8d080b --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterImageOutputObject.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents the data for a streaming run step's Code Interpreter tool call image output. + public partial class RunStepDeltaCodeInterpreterImageOutputObject + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal RunStepDeltaCodeInterpreterImageOutputObject() + { + } + + /// Initializes a new instance of . + /// The file ID for the image. + /// Keeps track of any properties unknown to the library. + internal RunStepDeltaCodeInterpreterImageOutputObject(string fileId, IDictionary serializedAdditionalRawData) + { + FileId = fileId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The file ID for the image. + public string FileId { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterLogOutput.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterLogOutput.Serialization.cs new file mode 100644 index 000000000000..bb764ac22b70 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterLogOutput.Serialization.cs @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepDeltaCodeInterpreterLogOutput : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterLogOutput)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Logs)) + { + writer.WritePropertyName("logs"u8); + writer.WriteStringValue(Logs); + } + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunStepDeltaCodeInterpreterLogOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterLogOutput)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaCodeInterpreterLogOutput(document.RootElement, options); + } + + internal static RunStepDeltaCodeInterpreterLogOutput DeserializeRunStepDeltaCodeInterpreterLogOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string logs = default; + int index = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("logs"u8)) + { + logs = property.Value.GetString(); + continue; + } + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaCodeInterpreterLogOutput(index, type, serializedAdditionalRawData, logs); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterLogOutput)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaCodeInterpreterLogOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepDeltaCodeInterpreterLogOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterLogOutput)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepDeltaCodeInterpreterLogOutput FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepDeltaCodeInterpreterLogOutput(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterLogOutput.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterLogOutput.cs new file mode 100644 index 000000000000..96eaa7b38dc3 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterLogOutput.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents a log output as produced by the Code Interpreter tool and as represented in a streaming run step's delta tool calls collection. + public partial class RunStepDeltaCodeInterpreterLogOutput : RunStepDeltaCodeInterpreterOutput + { + /// Initializes a new instance of . + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + internal RunStepDeltaCodeInterpreterLogOutput(int index) : base(index) + { + Type = "logs"; + } + + /// Initializes a new instance of . + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + /// The type of the streaming run step tool call's Code Interpreter output. + /// Keeps track of any properties unknown to the library. + /// The text output from the Code Interpreter tool call. + internal RunStepDeltaCodeInterpreterLogOutput(int index, string type, IDictionary serializedAdditionalRawData, string logs) : base(index, type, serializedAdditionalRawData) + { + Logs = logs; + } + + /// Initializes a new instance of for deserialization. + internal RunStepDeltaCodeInterpreterLogOutput() + { + } + + /// The text output from the Code Interpreter tool call. + public string Logs { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterOutput.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterOutput.Serialization.cs new file mode 100644 index 000000000000..6e213cb7d63f --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterOutput.Serialization.cs @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + [PersistableModelProxy(typeof(UnknownRunStepDeltaCodeInterpreterOutput))] + public partial class RunStepDeltaCodeInterpreterOutput : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterOutput)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunStepDeltaCodeInterpreterOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterOutput)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaCodeInterpreterOutput(document.RootElement, options); + } + + internal static RunStepDeltaCodeInterpreterOutput DeserializeRunStepDeltaCodeInterpreterOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "image": return RunStepDeltaCodeInterpreterImageOutput.DeserializeRunStepDeltaCodeInterpreterImageOutput(element, options); + case "logs": return RunStepDeltaCodeInterpreterLogOutput.DeserializeRunStepDeltaCodeInterpreterLogOutput(element, options); + } + } + return UnknownRunStepDeltaCodeInterpreterOutput.DeserializeUnknownRunStepDeltaCodeInterpreterOutput(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterOutput)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaCodeInterpreterOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepDeltaCodeInterpreterOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterOutput)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepDeltaCodeInterpreterOutput FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepDeltaCodeInterpreterOutput(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterOutput.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterOutput.cs new file mode 100644 index 000000000000..396e993239ce --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterOutput.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// + /// The abstract base representation of a streaming run step tool call's Code Interpreter tool output. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public abstract partial class RunStepDeltaCodeInterpreterOutput + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + protected RunStepDeltaCodeInterpreterOutput(int index) + { + Index = index; + } + + /// Initializes a new instance of . + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + /// The type of the streaming run step tool call's Code Interpreter output. + /// Keeps track of any properties unknown to the library. + internal RunStepDeltaCodeInterpreterOutput(int index, string type, IDictionary serializedAdditionalRawData) + { + Index = index; + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RunStepDeltaCodeInterpreterOutput() + { + } + + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + public int Index { get; } + /// The type of the streaming run step tool call's Code Interpreter output. + internal string Type { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterToolCall.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterToolCall.Serialization.cs new file mode 100644 index 000000000000..1daa8feffe07 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterToolCall.Serialization.cs @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepDeltaCodeInterpreterToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterToolCall)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(CodeInterpreter)) + { + writer.WritePropertyName("code_interpreter"u8); + writer.WriteObjectValue(CodeInterpreter, options); + } + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunStepDeltaCodeInterpreterToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaCodeInterpreterToolCall(document.RootElement, options); + } + + internal static RunStepDeltaCodeInterpreterToolCall DeserializeRunStepDeltaCodeInterpreterToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepDeltaCodeInterpreterDetailItemObject codeInterpreter = default; + int index = default; + string id = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code_interpreter"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + codeInterpreter = RunStepDeltaCodeInterpreterDetailItemObject.DeserializeRunStepDeltaCodeInterpreterDetailItemObject(property.Value, options); + continue; + } + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaCodeInterpreterToolCall(index, id, type, serializedAdditionalRawData, codeInterpreter); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaCodeInterpreterToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepDeltaCodeInterpreterToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepDeltaCodeInterpreterToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepDeltaCodeInterpreterToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterToolCall.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterToolCall.cs new file mode 100644 index 000000000000..059c30cbca81 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaCodeInterpreterToolCall.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents a Code Interpreter tool call within a streaming run step's tool call details. + public partial class RunStepDeltaCodeInterpreterToolCall : RunStepDeltaToolCall + { + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// is null. + internal RunStepDeltaCodeInterpreterToolCall(int index, string id) : base(index, id) + { + Argument.AssertNotNull(id, nameof(id)); + + Type = "code_interpreter"; + } + + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// The type of the tool call detail item in a streaming run step's details. + /// Keeps track of any properties unknown to the library. + /// The Code Interpreter data for the tool call. + internal RunStepDeltaCodeInterpreterToolCall(int index, string id, string type, IDictionary serializedAdditionalRawData, RunStepDeltaCodeInterpreterDetailItemObject codeInterpreter) : base(index, id, type, serializedAdditionalRawData) + { + CodeInterpreter = codeInterpreter; + } + + /// Initializes a new instance of for deserialization. + internal RunStepDeltaCodeInterpreterToolCall() + { + } + + /// The Code Interpreter data for the tool call. + public RunStepDeltaCodeInterpreterDetailItemObject CodeInterpreter { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaDetail.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaDetail.Serialization.cs new file mode 100644 index 000000000000..274b792c2227 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaDetail.Serialization.cs @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + [PersistableModelProxy(typeof(UnknownRunStepDeltaDetail))] + public partial class RunStepDeltaDetail : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunStepDeltaDetail IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaDetail(document.RootElement, options); + } + + internal static RunStepDeltaDetail DeserializeRunStepDeltaDetail(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "message_creation": return RunStepDeltaMessageCreation.DeserializeRunStepDeltaMessageCreation(element, options); + case "tool_calls": return RunStepDeltaToolCallObject.DeserializeRunStepDeltaToolCallObject(element, options); + } + } + return UnknownRunStepDeltaDetail.DeserializeUnknownRunStepDeltaDetail(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaDetail IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepDeltaDetail(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepDeltaDetail FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepDeltaDetail(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaDetail.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaDetail.cs new file mode 100644 index 000000000000..508fac38660c --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaDetail.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// + /// Represents a single run step detail item in a streaming run step's delta payload. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public abstract partial class RunStepDeltaDetail + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected RunStepDeltaDetail() + { + } + + /// Initializes a new instance of . + /// The object type for the run step detail object. + /// Keeps track of any properties unknown to the library. + internal RunStepDeltaDetail(string type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The object type for the run step detail object. + internal string Type { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFileSearchToolCall.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFileSearchToolCall.Serialization.cs new file mode 100644 index 000000000000..bfbb55ddae92 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFileSearchToolCall.Serialization.cs @@ -0,0 +1,177 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepDeltaFileSearchToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaFileSearchToolCall)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(FileSearch)) + { + writer.WritePropertyName("file_search"u8); + writer.WriteStartObject(); + foreach (var item in FileSearch) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunStepDeltaFileSearchToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaFileSearchToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaFileSearchToolCall(document.RootElement, options); + } + + internal static RunStepDeltaFileSearchToolCall DeserializeRunStepDeltaFileSearchToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyDictionary fileSearch = default; + int index = default; + string id = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_search"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + fileSearch = dictionary; + continue; + } + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaFileSearchToolCall(index, id, type, serializedAdditionalRawData, fileSearch ?? new ChangeTrackingDictionary()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaFileSearchToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaFileSearchToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepDeltaFileSearchToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaFileSearchToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepDeltaFileSearchToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepDeltaFileSearchToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFileSearchToolCall.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFileSearchToolCall.cs new file mode 100644 index 000000000000..7be515d9cc76 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFileSearchToolCall.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents a file search tool call within a streaming run step's tool call details. + public partial class RunStepDeltaFileSearchToolCall : RunStepDeltaToolCall + { + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// is null. + internal RunStepDeltaFileSearchToolCall(int index, string id) : base(index, id) + { + Argument.AssertNotNull(id, nameof(id)); + + Type = "file_search"; + FileSearch = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// The type of the tool call detail item in a streaming run step's details. + /// Keeps track of any properties unknown to the library. + /// Reserved for future use. + internal RunStepDeltaFileSearchToolCall(int index, string id, string type, IDictionary serializedAdditionalRawData, IReadOnlyDictionary fileSearch) : base(index, id, type, serializedAdditionalRawData) + { + FileSearch = fileSearch; + } + + /// Initializes a new instance of for deserialization. + internal RunStepDeltaFileSearchToolCall() + { + } + + /// Reserved for future use. + public IReadOnlyDictionary FileSearch { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFunction.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFunction.Serialization.cs new file mode 100644 index 000000000000..e1f73cd20f39 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFunction.Serialization.cs @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepDeltaFunction : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaFunction)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Arguments)) + { + writer.WritePropertyName("arguments"u8); + writer.WriteStringValue(Arguments); + } + if (Optional.IsDefined(Output)) + { + if (Output != null) + { + writer.WritePropertyName("output"u8); + writer.WriteStringValue(Output); + } + else + { + writer.WriteNull("output"); + } + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunStepDeltaFunction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaFunction)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaFunction(document.RootElement, options); + } + + internal static RunStepDeltaFunction DeserializeRunStepDeltaFunction(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + string arguments = default; + string output = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("arguments"u8)) + { + arguments = property.Value.GetString(); + continue; + } + if (property.NameEquals("output"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + output = null; + continue; + } + output = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaFunction(name, arguments, output, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaFunction)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaFunction IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepDeltaFunction(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaFunction)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepDeltaFunction FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepDeltaFunction(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFunction.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFunction.cs new file mode 100644 index 000000000000..df34c88e6f43 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFunction.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents the function data in a streaming run step delta's function tool call. + public partial class RunStepDeltaFunction + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal RunStepDeltaFunction() + { + } + + /// Initializes a new instance of . + /// The name of the function. + /// The arguments passed to the function as input. + /// The output of the function, null if outputs have not yet been submitted. + /// Keeps track of any properties unknown to the library. + internal RunStepDeltaFunction(string name, string arguments, string output, IDictionary serializedAdditionalRawData) + { + Name = name; + Arguments = arguments; + Output = output; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The name of the function. + public string Name { get; } + /// The arguments passed to the function as input. + public string Arguments { get; } + /// The output of the function, null if outputs have not yet been submitted. + public string Output { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFunctionToolCall.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFunctionToolCall.Serialization.cs new file mode 100644 index 000000000000..43ebba310262 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFunctionToolCall.Serialization.cs @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepDeltaFunctionToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaFunctionToolCall)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Function)) + { + writer.WritePropertyName("function"u8); + writer.WriteObjectValue(Function, options); + } + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunStepDeltaFunctionToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaFunctionToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaFunctionToolCall(document.RootElement, options); + } + + internal static RunStepDeltaFunctionToolCall DeserializeRunStepDeltaFunctionToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepDeltaFunction function = default; + int index = default; + string id = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("function"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + function = RunStepDeltaFunction.DeserializeRunStepDeltaFunction(property.Value, options); + continue; + } + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaFunctionToolCall(index, id, type, serializedAdditionalRawData, function); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaFunctionToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaFunctionToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepDeltaFunctionToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaFunctionToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepDeltaFunctionToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepDeltaFunctionToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFunctionToolCall.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFunctionToolCall.cs new file mode 100644 index 000000000000..ce9d9486ef82 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaFunctionToolCall.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents a function tool call within a streaming run step's tool call details. + public partial class RunStepDeltaFunctionToolCall : RunStepDeltaToolCall + { + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// is null. + internal RunStepDeltaFunctionToolCall(int index, string id) : base(index, id) + { + Argument.AssertNotNull(id, nameof(id)); + + Type = "function"; + } + + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// The type of the tool call detail item in a streaming run step's details. + /// Keeps track of any properties unknown to the library. + /// The function data for the tool call. + internal RunStepDeltaFunctionToolCall(int index, string id, string type, IDictionary serializedAdditionalRawData, RunStepDeltaFunction function) : base(index, id, type, serializedAdditionalRawData) + { + Function = function; + } + + /// Initializes a new instance of for deserialization. + internal RunStepDeltaFunctionToolCall() + { + } + + /// The function data for the tool call. + public RunStepDeltaFunction Function { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaMessageCreation.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaMessageCreation.Serialization.cs new file mode 100644 index 000000000000..e526f0766540 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaMessageCreation.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepDeltaMessageCreation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaMessageCreation)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(MessageCreation)) + { + writer.WritePropertyName("message_creation"u8); + writer.WriteObjectValue(MessageCreation, options); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunStepDeltaMessageCreation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaMessageCreation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaMessageCreation(document.RootElement, options); + } + + internal static RunStepDeltaMessageCreation DeserializeRunStepDeltaMessageCreation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RunStepDeltaMessageCreationObject messageCreation = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("message_creation"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + messageCreation = RunStepDeltaMessageCreationObject.DeserializeRunStepDeltaMessageCreationObject(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaMessageCreation(type, serializedAdditionalRawData, messageCreation); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaMessageCreation)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaMessageCreation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepDeltaMessageCreation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaMessageCreation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepDeltaMessageCreation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepDeltaMessageCreation(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaMessageCreation.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaMessageCreation.cs new file mode 100644 index 000000000000..38f8a808eeac --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaMessageCreation.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents a message creation within a streaming run step delta. + public partial class RunStepDeltaMessageCreation : RunStepDeltaDetail + { + /// Initializes a new instance of . + internal RunStepDeltaMessageCreation() + { + Type = "message_creation"; + } + + /// Initializes a new instance of . + /// The object type for the run step detail object. + /// Keeps track of any properties unknown to the library. + /// The message creation data. + internal RunStepDeltaMessageCreation(string type, IDictionary serializedAdditionalRawData, RunStepDeltaMessageCreationObject messageCreation) : base(type, serializedAdditionalRawData) + { + MessageCreation = messageCreation; + } + + /// The message creation data. + public RunStepDeltaMessageCreationObject MessageCreation { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaMessageCreationObject.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaMessageCreationObject.Serialization.cs new file mode 100644 index 000000000000..58a72a5f6dc7 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaMessageCreationObject.Serialization.cs @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepDeltaMessageCreationObject : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaMessageCreationObject)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(MessageId)) + { + writer.WritePropertyName("message_id"u8); + writer.WriteStringValue(MessageId); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunStepDeltaMessageCreationObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaMessageCreationObject)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaMessageCreationObject(document.RootElement, options); + } + + internal static RunStepDeltaMessageCreationObject DeserializeRunStepDeltaMessageCreationObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string messageId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("message_id"u8)) + { + messageId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaMessageCreationObject(messageId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaMessageCreationObject)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaMessageCreationObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepDeltaMessageCreationObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaMessageCreationObject)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepDeltaMessageCreationObject FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepDeltaMessageCreationObject(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaMessageCreationObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaMessageCreationObject.cs new file mode 100644 index 000000000000..15aaccdbc60c --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaMessageCreationObject.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents the data within a streaming run step message creation response object. + public partial class RunStepDeltaMessageCreationObject + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal RunStepDeltaMessageCreationObject() + { + } + + /// Initializes a new instance of . + /// The ID of the newly-created message. + /// Keeps track of any properties unknown to the library. + internal RunStepDeltaMessageCreationObject(string messageId, IDictionary serializedAdditionalRawData) + { + MessageId = messageId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The ID of the newly-created message. + public string MessageId { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaToolCall.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaToolCall.Serialization.cs new file mode 100644 index 000000000000..90c180755ad5 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaToolCall.Serialization.cs @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + [PersistableModelProxy(typeof(UnknownRunStepDeltaToolCall))] + public partial class RunStepDeltaToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaToolCall)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunStepDeltaToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaToolCall(document.RootElement, options); + } + + internal static RunStepDeltaToolCall DeserializeRunStepDeltaToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "code_interpreter": return RunStepDeltaCodeInterpreterToolCall.DeserializeRunStepDeltaCodeInterpreterToolCall(element, options); + case "file_search": return RunStepDeltaFileSearchToolCall.DeserializeRunStepDeltaFileSearchToolCall(element, options); + case "function": return RunStepDeltaFunctionToolCall.DeserializeRunStepDeltaFunctionToolCall(element, options); + } + } + return UnknownRunStepDeltaToolCall.DeserializeUnknownRunStepDeltaToolCall(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepDeltaToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static RunStepDeltaToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepDeltaToolCall(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaToolCall.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaToolCall.cs new file mode 100644 index 000000000000..c056ec5693c5 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaToolCall.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// + /// The abstract base representation of a single tool call within a streaming run step's delta tool call details. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public abstract partial class RunStepDeltaToolCall + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// is null. + protected RunStepDeltaToolCall(int index, string id) + { + Argument.AssertNotNull(id, nameof(id)); + + Index = index; + Id = id; + } + + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// The type of the tool call detail item in a streaming run step's details. + /// Keeps track of any properties unknown to the library. + internal RunStepDeltaToolCall(int index, string id, string type, IDictionary serializedAdditionalRawData) + { + Index = index; + Id = id; + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal RunStepDeltaToolCall() + { + } + + /// The index of the tool call detail in the run step's tool_calls array. + public int Index { get; } + /// The ID of the tool call, used when submitting outputs to the run. + public string Id { get; } + /// The type of the tool call detail item in a streaming run step's details. + internal string Type { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaToolCallObject.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaToolCallObject.Serialization.cs new file mode 100644 index 000000000000..19a2a33bf278 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaToolCallObject.Serialization.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class RunStepDeltaToolCallObject : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaToolCallObject)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(ToolCalls)) + { + writer.WritePropertyName("tool_calls"u8); + writer.WriteStartArray(); + foreach (var item in ToolCalls) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunStepDeltaToolCallObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaToolCallObject)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaToolCallObject(document.RootElement, options); + } + + internal static RunStepDeltaToolCallObject DeserializeRunStepDeltaToolCallObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList toolCalls = default; + string type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("tool_calls"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(RunStepDeltaToolCall.DeserializeRunStepDeltaToolCall(item, options)); + } + toolCalls = array; + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new RunStepDeltaToolCallObject(type, serializedAdditionalRawData, toolCalls ?? new ChangeTrackingList()); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaToolCallObject)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaToolCallObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepDeltaToolCallObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaToolCallObject)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new RunStepDeltaToolCallObject FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeRunStepDeltaToolCallObject(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaToolCallObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaToolCallObject.cs new file mode 100644 index 000000000000..77d87fe333e1 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepDeltaToolCallObject.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Represents an invocation of tool calls as part of a streaming run step. + public partial class RunStepDeltaToolCallObject : RunStepDeltaDetail + { + /// Initializes a new instance of . + internal RunStepDeltaToolCallObject() + { + Type = "tool_calls"; + ToolCalls = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The object type for the run step detail object. + /// Keeps track of any properties unknown to the library. + /// + /// The collection of tool calls for the tool call detail item. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + internal RunStepDeltaToolCallObject(string type, IDictionary serializedAdditionalRawData, IReadOnlyList toolCalls) : base(type, serializedAdditionalRawData) + { + ToolCalls = toolCalls; + } + + /// + /// The collection of tool calls for the tool call detail item. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public IReadOnlyList ToolCalls { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepRetrievalToolCall.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepFileSearchToolCall.Serialization.cs similarity index 66% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepRetrievalToolCall.Serialization.cs rename to sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepFileSearchToolCall.Serialization.cs index ab165de44e9d..cd7d7b80f371 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepRetrievalToolCall.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepFileSearchToolCall.Serialization.cs @@ -13,22 +13,22 @@ namespace Azure.AI.OpenAI.Assistants { - public partial class RunStepRetrievalToolCall : IUtf8JsonSerializable, IJsonModel + public partial class RunStepFileSearchToolCall : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RunStepRetrievalToolCall)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(RunStepFileSearchToolCall)} does not support writing '{format}' format."); } writer.WriteStartObject(); - writer.WritePropertyName("retrieval"u8); + writer.WritePropertyName("file_search"u8); writer.WriteStartObject(); - foreach (var item in Retrieval) + foreach (var item in FileSearch) { writer.WritePropertyName(item.Key); writer.WriteStringValue(item.Value); @@ -56,19 +56,19 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead writer.WriteEndObject(); } - RunStepRetrievalToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + RunStepFileSearchToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RunStepRetrievalToolCall)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(RunStepFileSearchToolCall)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRunStepRetrievalToolCall(document.RootElement, options); + return DeserializeRunStepFileSearchToolCall(document.RootElement, options); } - internal static RunStepRetrievalToolCall DeserializeRunStepRetrievalToolCall(JsonElement element, ModelReaderWriterOptions options = null) + internal static RunStepFileSearchToolCall DeserializeRunStepFileSearchToolCall(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -76,21 +76,21 @@ internal static RunStepRetrievalToolCall DeserializeRunStepRetrievalToolCall(Jso { return null; } - IReadOnlyDictionary retrieval = default; + IReadOnlyDictionary fileSearch = default; string type = default; string id = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("retrieval"u8)) + if (property.NameEquals("file_search"u8)) { Dictionary dictionary = new Dictionary(); foreach (var property0 in property.Value.EnumerateObject()) { dictionary.Add(property0.Name, property0.Value.GetString()); } - retrieval = dictionary; + fileSearch = dictionary; continue; } if (property.NameEquals("type"u8)) @@ -109,46 +109,46 @@ internal static RunStepRetrievalToolCall DeserializeRunStepRetrievalToolCall(Jso } } serializedAdditionalRawData = rawDataDictionary; - return new RunStepRetrievalToolCall(type, id, serializedAdditionalRawData, retrieval); + return new RunStepFileSearchToolCall(type, id, serializedAdditionalRawData, fileSearch); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(RunStepRetrievalToolCall)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(RunStepFileSearchToolCall)} does not support writing '{options.Format}' format."); } } - RunStepRetrievalToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + RunStepFileSearchToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRunStepRetrievalToolCall(document.RootElement, options); + return DeserializeRunStepFileSearchToolCall(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(RunStepRetrievalToolCall)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(RunStepFileSearchToolCall)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static new RunStepRetrievalToolCall FromResponse(Response response) + internal static new RunStepFileSearchToolCall FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content); - return DeserializeRunStepRetrievalToolCall(document.RootElement); + return DeserializeRunStepFileSearchToolCall(document.RootElement); } /// Convert into a . diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepFileSearchToolCall.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepFileSearchToolCall.cs new file mode 100644 index 000000000000..0b3014e92127 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepFileSearchToolCall.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// + /// A record of a call to a file search tool, issued by the model in evaluation of a defined tool, that represents + /// executed file search. + /// + public partial class RunStepFileSearchToolCall : RunStepToolCall + { + /// Initializes a new instance of . + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Reserved for future use. + /// or is null. + internal RunStepFileSearchToolCall(string id, IReadOnlyDictionary fileSearch) : base(id) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(fileSearch, nameof(fileSearch)); + + Type = "file_search"; + FileSearch = fileSearch; + } + + /// Initializes a new instance of . + /// The object type. + /// The ID of the tool call. This ID must be referenced when you submit tool outputs. + /// Keeps track of any properties unknown to the library. + /// Reserved for future use. + internal RunStepFileSearchToolCall(string type, string id, IDictionary serializedAdditionalRawData, IReadOnlyDictionary fileSearch) : base(type, id, serializedAdditionalRawData) + { + FileSearch = fileSearch; + } + + /// Initializes a new instance of for deserialization. + internal RunStepFileSearchToolCall() + { + } + + /// Reserved for future use. + public IReadOnlyDictionary FileSearch { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepRetrievalToolCall.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepRetrievalToolCall.cs deleted file mode 100644 index 5f119347d5f3..000000000000 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepRetrievalToolCall.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Azure.AI.OpenAI.Assistants -{ - /// - /// A record of a call to a retrieval tool, issued by the model in evaluation of a defined tool, that represents - /// executed retrieval actions. - /// - public partial class RunStepRetrievalToolCall : RunStepToolCall - { - /// Initializes a new instance of . - /// The ID of the tool call. This ID must be referenced when you submit tool outputs. - /// The key/value pairs produced by the retrieval tool. - /// or is null. - internal RunStepRetrievalToolCall(string id, IReadOnlyDictionary retrieval) : base(id) - { - Argument.AssertNotNull(id, nameof(id)); - Argument.AssertNotNull(retrieval, nameof(retrieval)); - - Type = "retrieval"; - Retrieval = retrieval; - } - - /// Initializes a new instance of . - /// The object type. - /// The ID of the tool call. This ID must be referenced when you submit tool outputs. - /// Keeps track of any properties unknown to the library. - /// The key/value pairs produced by the retrieval tool. - internal RunStepRetrievalToolCall(string type, string id, IDictionary serializedAdditionalRawData, IReadOnlyDictionary retrieval) : base(type, id, serializedAdditionalRawData) - { - Retrieval = retrieval; - } - - /// Initializes a new instance of for deserialization. - internal RunStepRetrievalToolCall() - { - } - - /// The key/value pairs produced by the retrieval tool. - public IReadOnlyDictionary Retrieval { get; } - } -} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepStreamEvent.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepStreamEvent.cs new file mode 100644 index 000000000000..57f5998602ce --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepStreamEvent.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Run step operation related streaming events. + public readonly partial struct RunStepStreamEvent : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RunStepStreamEvent(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadRunStepCreatedValue = "thread.run.step.created"; + private const string ThreadRunStepInProgressValue = "thread.run.step.in_progress"; + private const string ThreadRunStepDeltaValue = "thread.run.step.delta"; + private const string ThreadRunStepCompletedValue = "thread.run.step.completed"; + private const string ThreadRunStepFailedValue = "thread.run.step.failed"; + private const string ThreadRunStepCancelledValue = "thread.run.step.cancelled"; + private const string ThreadRunStepExpiredValue = "thread.run.step.expired"; + + /// Event sent when a new thread run step is created. The data of this event is of type RunStep. + public static RunStepStreamEvent ThreadRunStepCreated { get; } = new RunStepStreamEvent(ThreadRunStepCreatedValue); + /// Event sent when a run step moves to `in_progress` status. The data of this event is of type RunStep. + public static RunStepStreamEvent ThreadRunStepInProgress { get; } = new RunStepStreamEvent(ThreadRunStepInProgressValue); + /// Event sent when a run stepis being streamed. The data of this event is of type RunStepDeltaChunk. + public static RunStepStreamEvent ThreadRunStepDelta { get; } = new RunStepStreamEvent(ThreadRunStepDeltaValue); + /// Event sent when a run step is completed. The data of this event is of type RunStep. + public static RunStepStreamEvent ThreadRunStepCompleted { get; } = new RunStepStreamEvent(ThreadRunStepCompletedValue); + /// Event sent when a run step fails. The data of this event is of type RunStep. + public static RunStepStreamEvent ThreadRunStepFailed { get; } = new RunStepStreamEvent(ThreadRunStepFailedValue); + /// Event sent when a run step is cancelled. The data of this event is of type RunStep. + public static RunStepStreamEvent ThreadRunStepCancelled { get; } = new RunStepStreamEvent(ThreadRunStepCancelledValue); + /// Event sent when a run step is expired. The data of this event is of type RunStep. + public static RunStepStreamEvent ThreadRunStepExpired { get; } = new RunStepStreamEvent(ThreadRunStepExpiredValue); + /// Determines if two values are the same. + public static bool operator ==(RunStepStreamEvent left, RunStepStreamEvent right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RunStepStreamEvent left, RunStepStreamEvent right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator RunStepStreamEvent(string value) => new RunStepStreamEvent(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunStepStreamEvent other && Equals(other); + /// + public bool Equals(RunStepStreamEvent other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCall.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCall.Serialization.cs index 59c11de06377..b9329fd5c499 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCall.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCall.Serialization.cs @@ -73,8 +73,8 @@ internal static RunStepToolCall DeserializeRunStepToolCall(JsonElement element, switch (discriminator.GetString()) { case "code_interpreter": return RunStepCodeInterpreterToolCall.DeserializeRunStepCodeInterpreterToolCall(element, options); + case "file_search": return RunStepFileSearchToolCall.DeserializeRunStepFileSearchToolCall(element, options); case "function": return RunStepFunctionToolCall.DeserializeRunStepFunctionToolCall(element, options); - case "retrieval": return RunStepRetrievalToolCall.DeserializeRunStepRetrievalToolCall(element, options); } } return UnknownRunStepToolCall.DeserializeUnknownRunStepToolCall(element, options); diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCall.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCall.cs index a1f39c74d40e..b458fd4827e9 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCall.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCall.cs @@ -13,7 +13,7 @@ namespace Azure.AI.OpenAI.Assistants /// /// An abstract representation of a detailed tool call as recorded within a run step for an existing run. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . /// public abstract partial class RunStepToolCall { diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCallDetails.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCallDetails.cs index dedd295f4d8a..1d55d40ac096 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCallDetails.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStepToolCallDetails.cs @@ -18,7 +18,7 @@ public partial class RunStepToolCallDetails : RunStepDetails /// /// A list of tool call details for this run step. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . /// /// is null. internal RunStepToolCallDetails(IEnumerable toolCalls) @@ -35,7 +35,7 @@ internal RunStepToolCallDetails(IEnumerable toolCalls) /// /// A list of tool call details for this run step. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . /// internal RunStepToolCallDetails(RunStepType type, IDictionary serializedAdditionalRawData, IReadOnlyList toolCalls) : base(type, serializedAdditionalRawData) { @@ -50,7 +50,7 @@ internal RunStepToolCallDetails() /// /// A list of tool call details for this run step. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . /// public IReadOnlyList ToolCalls { get; } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStreamEvent.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStreamEvent.cs new file mode 100644 index 000000000000..0ea194a7a51e --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RunStreamEvent.cs @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Run operation related streaming events. + public readonly partial struct RunStreamEvent : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RunStreamEvent(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadRunCreatedValue = "thread.run.created"; + private const string ThreadRunQueuedValue = "thread.run.queued"; + private const string ThreadRunInProgressValue = "thread.run.in_progress"; + private const string ThreadRunRequiresActionValue = "thread.run.requires_action"; + private const string ThreadRunCompletedValue = "thread.run.completed"; + private const string ThreadRunFailedValue = "thread.run.failed"; + private const string ThreadRunCancellingValue = "thread.run.cancelling"; + private const string ThreadRunCancelledValue = "thread.run.cancelled"; + private const string ThreadRunExpiredValue = "thread.run.expired"; + + /// Event sent when a new run is created. The data of this event is of type ThreadRun. + public static RunStreamEvent ThreadRunCreated { get; } = new RunStreamEvent(ThreadRunCreatedValue); + /// Event sent when a run moves to `queued` status. The data of this event is of type ThreadRun. + public static RunStreamEvent ThreadRunQueued { get; } = new RunStreamEvent(ThreadRunQueuedValue); + /// Event sent when a run moves to `in_progress` status. The data of this event is of type ThreadRun. + public static RunStreamEvent ThreadRunInProgress { get; } = new RunStreamEvent(ThreadRunInProgressValue); + /// Event sent when a run moves to `requires_action` status. The data of this event is of type ThreadRun. + public static RunStreamEvent ThreadRunRequiresAction { get; } = new RunStreamEvent(ThreadRunRequiresActionValue); + /// Event sent when a run is completed. The data of this event is of type ThreadRun. + public static RunStreamEvent ThreadRunCompleted { get; } = new RunStreamEvent(ThreadRunCompletedValue); + /// Event sent when a run fails. The data of this event is of type ThreadRun. + public static RunStreamEvent ThreadRunFailed { get; } = new RunStreamEvent(ThreadRunFailedValue); + /// Event sent when a run moves to `cancelling` status. The data of this event is of type ThreadRun. + public static RunStreamEvent ThreadRunCancelling { get; } = new RunStreamEvent(ThreadRunCancellingValue); + /// Event sent when a run is cancelled. The data of this event is of type ThreadRun. + public static RunStreamEvent ThreadRunCancelled { get; } = new RunStreamEvent(ThreadRunCancelledValue); + /// Event sent when a run is expired. The data of this event is of type ThreadRun. + public static RunStreamEvent ThreadRunExpired { get; } = new RunStreamEvent(ThreadRunExpiredValue); + /// Determines if two values are the same. + public static bool operator ==(RunStreamEvent left, RunStreamEvent right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RunStreamEvent left, RunStreamEvent right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator RunStreamEvent(string value) => new RunStreamEvent(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RunStreamEvent other && Equals(other); + /// + public bool Equals(RunStreamEvent other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsToRunRequest.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsToRunRequest.Serialization.cs index 142824a48025..c62ed0007517 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsToRunRequest.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsToRunRequest.Serialization.cs @@ -33,6 +33,18 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode writer.WriteObjectValue(item, options); } writer.WriteEndArray(); + if (Optional.IsDefined(Stream)) + { + if (Stream != null) + { + writer.WritePropertyName("stream"u8); + writer.WriteBooleanValue(Stream.Value); + } + else + { + writer.WriteNull("stream"); + } + } if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -72,6 +84,7 @@ internal static SubmitToolOutputsToRunRequest DeserializeSubmitToolOutputsToRunR return null; } IReadOnlyList toolOutputs = default; + bool? stream = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -86,13 +99,23 @@ internal static SubmitToolOutputsToRunRequest DeserializeSubmitToolOutputsToRunR toolOutputs = array; continue; } + if (property.NameEquals("stream"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + stream = null; + continue; + } + stream = property.Value.GetBoolean(); + continue; + } if (options.Format != "W") { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } serializedAdditionalRawData = rawDataDictionary; - return new SubmitToolOutputsToRunRequest(toolOutputs, serializedAdditionalRawData); + return new SubmitToolOutputsToRunRequest(toolOutputs, stream, serializedAdditionalRawData); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsToRunRequest.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsToRunRequest.cs index 7fc21ab959a6..2971598450d1 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsToRunRequest.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/SubmitToolOutputsToRunRequest.cs @@ -47,7 +47,7 @@ internal partial class SubmitToolOutputsToRunRequest private IDictionary _serializedAdditionalRawData; /// Initializes a new instance of . - /// The list of tool outputs requested by tool calls from the specified run. + /// A list of tools for which the outputs are being submitted. /// is null. internal SubmitToolOutputsToRunRequest(IEnumerable toolOutputs) { @@ -57,11 +57,13 @@ internal SubmitToolOutputsToRunRequest(IEnumerable toolOutputs) } /// Initializes a new instance of . - /// The list of tool outputs requested by tool calls from the specified run. + /// A list of tools for which the outputs are being submitted. + /// If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message. /// Keeps track of any properties unknown to the library. - internal SubmitToolOutputsToRunRequest(IReadOnlyList toolOutputs, IDictionary serializedAdditionalRawData) + internal SubmitToolOutputsToRunRequest(IReadOnlyList toolOutputs, bool? stream, IDictionary serializedAdditionalRawData) { ToolOutputs = toolOutputs; + Stream = stream; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -70,7 +72,9 @@ internal SubmitToolOutputsToRunRequest() { } - /// The list of tool outputs requested by tool calls from the specified run. + /// A list of tools for which the outputs are being submitted. public IReadOnlyList ToolOutputs { get; } + /// If `true`, returns a stream of events that happen during the Run as server-sent events, terminating when the Run enters a terminal state with a `data: [DONE]` message. + public bool? Stream { get; } } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessage.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessage.Serialization.cs index 940a42cf9293..da88c63f2836 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessage.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessage.Serialization.cs @@ -34,6 +34,35 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt writer.WriteNumberValue(CreatedAt, "U"); writer.WritePropertyName("thread_id"u8); writer.WriteStringValue(ThreadId); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + if (IncompleteDetails != null) + { + writer.WritePropertyName("incomplete_details"u8); + writer.WriteObjectValue(IncompleteDetails, options); + } + else + { + writer.WriteNull("incomplete_details"); + } + if (CompletedAt != null) + { + writer.WritePropertyName("completed_at"u8); + writer.WriteNumberValue(CompletedAt.Value, "U"); + } + else + { + writer.WriteNull("completed_at"); + } + if (IncompleteAt != null) + { + writer.WritePropertyName("incomplete_at"u8); + writer.WriteNumberValue(IncompleteAt.Value, "U"); + } + else + { + writer.WriteNull("incomplete_at"); + } writer.WritePropertyName("role"u8); writer.WriteStringValue(Role.ToString()); writer.WritePropertyName("content"u8); @@ -43,23 +72,38 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt writer.WriteObjectValue(item, options); } writer.WriteEndArray(); - if (Optional.IsDefined(AssistantId)) + if (AssistantId != null) { writer.WritePropertyName("assistant_id"u8); writer.WriteStringValue(AssistantId); } - if (Optional.IsDefined(RunId)) + else + { + writer.WriteNull("assistant_id"); + } + if (RunId != null) { writer.WritePropertyName("run_id"u8); writer.WriteStringValue(RunId); } - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) + else { - writer.WriteStringValue(item); + writer.WriteNull("run_id"); + } + if (Attachments != null && Optional.IsCollectionDefined(Attachments)) + { + writer.WritePropertyName("attachments"u8); + writer.WriteStartArray(); + foreach (var item in Attachments) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("attachments"); } - writer.WriteEndArray(); if (Metadata != null && Optional.IsCollectionDefined(Metadata)) { writer.WritePropertyName("metadata"u8); @@ -117,12 +161,16 @@ internal static ThreadMessage DeserializeThreadMessage(JsonElement element, Mode string @object = default; DateTimeOffset createdAt = default; string threadId = default; + MessageStatus status = default; + MessageIncompleteDetails incompleteDetails = default; + DateTimeOffset? completedAt = default; + DateTimeOffset? incompleteAt = default; MessageRole role = default; - IReadOnlyList content = default; + IList content = default; string assistantId = default; string runId = default; - IReadOnlyList fileIds = default; - IReadOnlyDictionary metadata = default; + IList attachments = default; + IDictionary metadata = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -147,6 +195,41 @@ internal static ThreadMessage DeserializeThreadMessage(JsonElement element, Mode threadId = property.Value.GetString(); continue; } + if (property.NameEquals("status"u8)) + { + status = new MessageStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("incomplete_details"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + incompleteDetails = null; + continue; + } + incompleteDetails = MessageIncompleteDetails.DeserializeMessageIncompleteDetails(property.Value, options); + continue; + } + if (property.NameEquals("completed_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + completedAt = null; + continue; + } + completedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("incomplete_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + incompleteAt = null; + continue; + } + incompleteAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } if (property.NameEquals("role"u8)) { role = new MessageRole(property.Value.GetString()); @@ -164,22 +247,37 @@ internal static ThreadMessage DeserializeThreadMessage(JsonElement element, Mode } if (property.NameEquals("assistant_id"u8)) { + if (property.Value.ValueKind == JsonValueKind.Null) + { + assistantId = null; + continue; + } assistantId = property.Value.GetString(); continue; } if (property.NameEquals("run_id"u8)) { + if (property.Value.ValueKind == JsonValueKind.Null) + { + runId = null; + continue; + } runId = property.Value.GetString(); continue; } - if (property.NameEquals("file_ids"u8)) + if (property.NameEquals("attachments"u8)) { - List array = new List(); + if (property.Value.ValueKind == JsonValueKind.Null) + { + attachments = new ChangeTrackingList(); + continue; + } + List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(item.GetString()); + array.Add(MessageAttachment.DeserializeMessageAttachment(item, options)); } - fileIds = array; + attachments = array; continue; } if (property.NameEquals("metadata"u8)) @@ -208,11 +306,15 @@ internal static ThreadMessage DeserializeThreadMessage(JsonElement element, Mode @object, createdAt, threadId, + status, + incompleteDetails, + completedAt, + incompleteAt, role, content, assistantId, runId, - fileIds, + attachments, metadata, serializedAdditionalRawData); } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessage.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessage.cs index 8bc5a7e7779b..c730b23b4dcf 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessage.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessage.cs @@ -50,31 +50,39 @@ public partial class ThreadMessage /// The identifier, which can be referenced in API endpoints. /// The Unix timestamp, in seconds, representing when this object was created. /// The ID of the thread that this message belongs to. + /// The status of the message. + /// On an incomplete message, details about why the message is incomplete. + /// The Unix timestamp (in seconds) for when the message was completed. + /// The Unix timestamp (in seconds) for when the message was marked as incomplete. /// The role associated with the assistant thread message. /// /// The list of content items associated with the assistant thread message. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. /// The available derived classes include and . /// - /// - /// A list of file IDs that the assistant should use. Useful for tools like retrieval and code_interpreter that can - /// access files. - /// + /// If applicable, the ID of the assistant that authored this message. + /// If applicable, the ID of the run associated with the authoring of this message. + /// A list of files attached to the message, and the tools they were added to. /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// , , or is null. - internal ThreadMessage(string id, DateTimeOffset createdAt, string threadId, MessageRole role, IEnumerable contentItems, IEnumerable fileIds, IReadOnlyDictionary metadata) + /// , or is null. + public ThreadMessage(string id, DateTimeOffset createdAt, string threadId, MessageStatus status, MessageIncompleteDetails incompleteDetails, DateTimeOffset? completedAt, DateTimeOffset? incompleteAt, MessageRole role, IEnumerable contentItems, string assistantId, string runId, IEnumerable attachments, IDictionary metadata) { Argument.AssertNotNull(id, nameof(id)); Argument.AssertNotNull(threadId, nameof(threadId)); Argument.AssertNotNull(contentItems, nameof(contentItems)); - Argument.AssertNotNull(fileIds, nameof(fileIds)); Id = id; CreatedAt = createdAt; ThreadId = threadId; + Status = status; + IncompleteDetails = incompleteDetails; + CompletedAt = completedAt; + IncompleteAt = incompleteAt; Role = role; ContentItems = contentItems.ToList(); - FileIds = fileIds.ToList(); + AssistantId = assistantId; + RunId = runId; + Attachments = attachments?.ToList(); Metadata = metadata; } @@ -83,6 +91,10 @@ internal ThreadMessage(string id, DateTimeOffset createdAt, string threadId, Mes /// The object type, which is always 'thread.message'. /// The Unix timestamp, in seconds, representing when this object was created. /// The ID of the thread that this message belongs to. + /// The status of the message. + /// On an incomplete message, details about why the message is incomplete. + /// The Unix timestamp (in seconds) for when the message was completed. + /// The Unix timestamp (in seconds) for when the message was marked as incomplete. /// The role associated with the assistant thread message. /// /// The list of content items associated with the assistant thread message. @@ -91,23 +103,24 @@ internal ThreadMessage(string id, DateTimeOffset createdAt, string threadId, Mes /// /// If applicable, the ID of the assistant that authored this message. /// If applicable, the ID of the run associated with the authoring of this message. - /// - /// A list of file IDs that the assistant should use. Useful for tools like retrieval and code_interpreter that can - /// access files. - /// + /// A list of files attached to the message, and the tools they were added to. /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// Keeps track of any properties unknown to the library. - internal ThreadMessage(string id, string @object, DateTimeOffset createdAt, string threadId, MessageRole role, IReadOnlyList contentItems, string assistantId, string runId, IReadOnlyList fileIds, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + internal ThreadMessage(string id, string @object, DateTimeOffset createdAt, string threadId, MessageStatus status, MessageIncompleteDetails incompleteDetails, DateTimeOffset? completedAt, DateTimeOffset? incompleteAt, MessageRole role, IList contentItems, string assistantId, string runId, IList attachments, IDictionary metadata, IDictionary serializedAdditionalRawData) { Id = id; Object = @object; CreatedAt = createdAt; ThreadId = threadId; + Status = status; + IncompleteDetails = incompleteDetails; + CompletedAt = completedAt; + IncompleteAt = incompleteAt; Role = role; ContentItems = contentItems; AssistantId = assistantId; RunId = runId; - FileIds = fileIds; + Attachments = attachments; Metadata = metadata; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -118,30 +131,35 @@ internal ThreadMessage() } /// The identifier, which can be referenced in API endpoints. - public string Id { get; } + public string Id { get; set; } /// The Unix timestamp, in seconds, representing when this object was created. - public DateTimeOffset CreatedAt { get; } + public DateTimeOffset CreatedAt { get; set; } /// The ID of the thread that this message belongs to. - public string ThreadId { get; } + public string ThreadId { get; set; } + /// The status of the message. + public MessageStatus Status { get; set; } + /// On an incomplete message, details about why the message is incomplete. + public MessageIncompleteDetails IncompleteDetails { get; set; } + /// The Unix timestamp (in seconds) for when the message was completed. + public DateTimeOffset? CompletedAt { get; set; } + /// The Unix timestamp (in seconds) for when the message was marked as incomplete. + public DateTimeOffset? IncompleteAt { get; set; } /// The role associated with the assistant thread message. - public MessageRole Role { get; } + public MessageRole Role { get; set; } /// /// The list of content items associated with the assistant thread message. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. /// The available derived classes include and . /// - public IReadOnlyList ContentItems { get; } + public IList ContentItems { get; } /// If applicable, the ID of the assistant that authored this message. - public string AssistantId { get; } + public string AssistantId { get; set; } /// If applicable, the ID of the run associated with the authoring of this message. - public string RunId { get; } - /// - /// A list of file IDs that the assistant should use. Useful for tools like retrieval and code_interpreter that can - /// access files. - /// - public IReadOnlyList FileIds { get; } + public string RunId { get; set; } + /// A list of files attached to the message, and the tools they were added to. + public IList Attachments { get; set; } /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IReadOnlyDictionary Metadata { get; } + public IDictionary Metadata { get; set; } } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateMessageRequest.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessageOptions.Serialization.cs similarity index 69% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateMessageRequest.Serialization.cs rename to sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessageOptions.Serialization.cs index dd7625e2b011..7d6727044483 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateMessageRequest.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessageOptions.Serialization.cs @@ -13,16 +13,16 @@ namespace Azure.AI.OpenAI.Assistants { - internal partial class CreateMessageRequest : IUtf8JsonSerializable, IJsonModel + public partial class ThreadMessageOptions : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(CreateMessageRequest)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(ThreadMessageOptions)} does not support writing '{format}' format."); } writer.WriteStartObject(); @@ -30,15 +30,22 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr writer.WriteStringValue(Role.ToString()); writer.WritePropertyName("content"u8); writer.WriteStringValue(Content); - if (Optional.IsCollectionDefined(FileIds)) + if (Optional.IsCollectionDefined(Attachments)) { - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) + if (Attachments != null) { - writer.WriteStringValue(item); + writer.WritePropertyName("attachments"u8); + writer.WriteStartArray(); + foreach (var item in Attachments) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + else + { + writer.WriteNull("attachments"); } - writer.WriteEndArray(); } if (Optional.IsCollectionDefined(Metadata)) { @@ -76,19 +83,19 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr writer.WriteEndObject(); } - CreateMessageRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ThreadMessageOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(CreateMessageRequest)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(ThreadMessageOptions)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeCreateMessageRequest(document.RootElement, options); + return DeserializeThreadMessageOptions(document.RootElement, options); } - internal static CreateMessageRequest DeserializeCreateMessageRequest(JsonElement element, ModelReaderWriterOptions options = null) + internal static ThreadMessageOptions DeserializeThreadMessageOptions(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -98,8 +105,8 @@ internal static CreateMessageRequest DeserializeCreateMessageRequest(JsonElement } MessageRole role = default; string content = default; - IReadOnlyList fileIds = default; - IReadOnlyDictionary metadata = default; + IList attachments = default; + IDictionary metadata = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -114,18 +121,18 @@ internal static CreateMessageRequest DeserializeCreateMessageRequest(JsonElement content = property.Value.GetString(); continue; } - if (property.NameEquals("file_ids"u8)) + if (property.NameEquals("attachments"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } - List array = new List(); + List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(item.GetString()); + array.Add(MessageAttachment.DeserializeMessageAttachment(item, options)); } - fileIds = array; + attachments = array; continue; } if (property.NameEquals("metadata"u8)) @@ -148,46 +155,46 @@ internal static CreateMessageRequest DeserializeCreateMessageRequest(JsonElement } } serializedAdditionalRawData = rawDataDictionary; - return new CreateMessageRequest(role, content, fileIds ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + return new ThreadMessageOptions(role, content, attachments ?? new ChangeTrackingList(), metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(CreateMessageRequest)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(ThreadMessageOptions)} does not support writing '{options.Format}' format."); } } - CreateMessageRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + ThreadMessageOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data); - return DeserializeCreateMessageRequest(document.RootElement, options); + return DeserializeThreadMessageOptions(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(CreateMessageRequest)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(ThreadMessageOptions)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static CreateMessageRequest FromResponse(Response response) + internal static ThreadMessageOptions FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content); - return DeserializeCreateMessageRequest(document.RootElement); + return DeserializeThreadMessageOptions(document.RootElement); } /// Convert into a . diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadInitializationMessage.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessageOptions.cs similarity index 53% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadInitializationMessage.cs rename to sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessageOptions.cs index 5ce61588505d..6487c1ad7bf4 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadInitializationMessage.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadMessageOptions.cs @@ -11,7 +11,7 @@ namespace Azure.AI.OpenAI.Assistants { /// A single message within an assistant thread, as provided during that thread's creation for its initial state. - public partial class ThreadInitializationMessage + public partial class ThreadMessageOptions { /// /// Keeps track of any properties unknown to the library. @@ -45,52 +45,70 @@ public partial class ThreadInitializationMessage /// private IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . - /// The role associated with the assistant thread message. Currently, only 'user' is supported when providing initial messages to a new thread. - /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via a separate call to the create message API. + /// Initializes a new instance of . + /// + /// The role of the entity that is creating the message. Allowed values include: + /// - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages. + /// - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into + /// the conversation. + /// + /// + /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via + /// a separate call to the create message API. + /// /// is null. - public ThreadInitializationMessage(MessageRole role, string content) + public ThreadMessageOptions(MessageRole role, string content) { Argument.AssertNotNull(content, nameof(content)); Role = role; Content = content; - FileIds = new ChangeTrackingList(); + Attachments = new ChangeTrackingList(); Metadata = new ChangeTrackingDictionary(); } - /// Initializes a new instance of . - /// The role associated with the assistant thread message. Currently, only 'user' is supported when providing initial messages to a new thread. - /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via a separate call to the create message API. - /// - /// A list of file IDs that the assistant should use. Useful for tools like retrieval and code_interpreter that can - /// access files. + /// Initializes a new instance of . + /// + /// The role of the entity that is creating the message. Allowed values include: + /// - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages. + /// - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into + /// the conversation. /// + /// + /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via + /// a separate call to the create message API. + /// + /// A list of files attached to the message, and the tools they should be added to. /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// Keeps track of any properties unknown to the library. - internal ThreadInitializationMessage(MessageRole role, string content, IList fileIds, IDictionary metadata, IDictionary serializedAdditionalRawData) + internal ThreadMessageOptions(MessageRole role, string content, IList attachments, IDictionary metadata, IDictionary serializedAdditionalRawData) { Role = role; Content = content; - FileIds = fileIds; + Attachments = attachments; Metadata = metadata; _serializedAdditionalRawData = serializedAdditionalRawData; } - /// Initializes a new instance of for deserialization. - internal ThreadInitializationMessage() + /// Initializes a new instance of for deserialization. + internal ThreadMessageOptions() { } - /// The role associated with the assistant thread message. Currently, only 'user' is supported when providing initial messages to a new thread. + /// + /// The role of the entity that is creating the message. Allowed values include: + /// - `user`: Indicates the message is sent by an actual user and should be used in most cases to represent user-generated messages. + /// - `assistant`: Indicates the message is generated by the assistant. Use this value to insert messages from the assistant into + /// the conversation. + /// public MessageRole Role { get; } - /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via a separate call to the create message API. - public string Content { get; } /// - /// A list of file IDs that the assistant should use. Useful for tools like retrieval and code_interpreter that can - /// access files. + /// The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via + /// a separate call to the create message API. /// - public IList FileIds { get; } + public string Content { get; } + /// A list of files attached to the message, and the tools they should be added to. + public IList Attachments { get; set; } /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. public IDictionary Metadata { get; set; } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadRun.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadRun.Serialization.cs index e8b809e7542c..b7a0ffb9e1f1 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadRun.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadRun.Serialization.cs @@ -68,13 +68,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions writer.WriteObjectValue(item, options); } writer.WriteEndArray(); - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) - { - writer.WriteStringValue(item); - } - writer.WriteEndArray(); writer.WritePropertyName("created_at"u8); writer.WriteNumberValue(CreatedAt, "U"); if (ExpiresAt != null) @@ -122,6 +115,107 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions { writer.WriteNull("failed_at"); } + if (IncompleteDetails != null) + { + writer.WritePropertyName("incomplete_details"u8); + writer.WriteStringValue(IncompleteDetails.Value.ToString()); + } + else + { + writer.WriteNull("incomplete_details"); + } + if (Usage != null) + { + writer.WritePropertyName("usage"u8); + writer.WriteObjectValue(Usage, options); + } + else + { + writer.WriteNull("usage"); + } + if (Optional.IsDefined(Temperature)) + { + if (Temperature != null) + { + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + else + { + writer.WriteNull("temperature"); + } + } + if (Optional.IsDefined(TopP)) + { + if (TopP != null) + { + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(TopP.Value); + } + else + { + writer.WriteNull("top_p"); + } + } + if (MaxPromptTokens != null) + { + writer.WritePropertyName("max_prompt_tokens"u8); + writer.WriteNumberValue(MaxPromptTokens.Value); + } + else + { + writer.WriteNull("max_prompt_tokens"); + } + if (MaxCompletionTokens != null) + { + writer.WritePropertyName("max_completion_tokens"u8); + writer.WriteNumberValue(MaxCompletionTokens.Value); + } + else + { + writer.WriteNull("max_completion_tokens"); + } + if (TruncationStrategy != null) + { + writer.WritePropertyName("truncation_strategy"u8); + writer.WriteObjectValue(TruncationStrategy, options); + } + else + { + writer.WriteNull("truncation_strategy"); + } + if (ToolChoice != null) + { + writer.WritePropertyName("tool_choice"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ToolChoice); +#else + using (JsonDocument document = JsonDocument.Parse(ToolChoice)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else + { + writer.WriteNull("tool_choice"); + } + if (ResponseFormat != null) + { + writer.WritePropertyName("response_format"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ResponseFormat); +#else + using (JsonDocument document = JsonDocument.Parse(ResponseFormat)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else + { + writer.WriteNull("response_format"); + } if (Metadata != null && Optional.IsCollectionDefined(Metadata)) { writer.WritePropertyName("metadata"u8); @@ -185,13 +279,21 @@ internal static ThreadRun DeserializeThreadRun(JsonElement element, ModelReaderW string model = default; string instructions = default; IReadOnlyList tools = default; - IReadOnlyList fileIds = default; DateTimeOffset createdAt = default; DateTimeOffset? expiresAt = default; DateTimeOffset? startedAt = default; DateTimeOffset? completedAt = default; DateTimeOffset? cancelledAt = default; DateTimeOffset? failedAt = default; + IncompleteRunDetails? incompleteDetails = default; + RunCompletionUsage usage = default; + float? temperature = default; + float? topP = default; + int? maxPromptTokens = default; + int? maxCompletionTokens = default; + TruncationObject truncationStrategy = default; + BinaryData toolChoice = default; + BinaryData responseFormat = default; IReadOnlyDictionary metadata = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); @@ -262,16 +364,6 @@ internal static ThreadRun DeserializeThreadRun(JsonElement element, ModelReaderW tools = array; continue; } - if (property.NameEquals("file_ids"u8)) - { - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) - { - array.Add(item.GetString()); - } - fileIds = array; - continue; - } if (property.NameEquals("created_at"u8)) { createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); @@ -302,6 +394,96 @@ internal static ThreadRun DeserializeThreadRun(JsonElement element, ModelReaderW DeserializeNullableDateTimeOffset(property, ref failedAt); continue; } + if (property.NameEquals("incomplete_details"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + incompleteDetails = null; + continue; + } + incompleteDetails = new IncompleteRunDetails(property.Value.GetString()); + continue; + } + if (property.NameEquals("usage"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + usage = null; + continue; + } + usage = RunCompletionUsage.DeserializeRunCompletionUsage(property.Value, options); + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + temperature = null; + continue; + } + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("top_p"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + topP = null; + continue; + } + topP = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("max_prompt_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + maxPromptTokens = null; + continue; + } + maxPromptTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("max_completion_tokens"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + maxCompletionTokens = null; + continue; + } + maxCompletionTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("truncation_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + truncationStrategy = null; + continue; + } + truncationStrategy = TruncationObject.DeserializeTruncationObject(property.Value, options); + continue; + } + if (property.NameEquals("tool_choice"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + toolChoice = null; + continue; + } + toolChoice = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + responseFormat = null; + continue; + } + responseFormat = BinaryData.FromString(property.Value.GetRawText()); + continue; + } if (property.NameEquals("metadata"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -334,13 +516,21 @@ internal static ThreadRun DeserializeThreadRun(JsonElement element, ModelReaderW model, instructions, tools, - fileIds, createdAt, expiresAt, startedAt, completedAt, cancelledAt, failedAt, + incompleteDetails, + usage, + temperature, + topP, + maxPromptTokens, + maxCompletionTokens, + truncationStrategy, + toolChoice, + responseFormat, metadata, serializedAdditionalRawData); } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadRun.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadRun.cs index 31c97e45b559..49a0eedc1b1e 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadRun.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadRun.cs @@ -57,18 +57,24 @@ public partial class ThreadRun /// /// The overridden enabled tools used for this assistant thread run. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . /// - /// A list of attached file IDs, ordered by creation date in ascending order. /// The Unix timestamp, in seconds, representing when this object was created. /// The Unix timestamp, in seconds, representing when this item expires. /// The Unix timestamp, in seconds, representing when this item was started. /// The Unix timestamp, in seconds, representing when this completed. /// The Unix timestamp, in seconds, representing when this was cancelled. /// The Unix timestamp, in seconds, representing when this failed. + /// Details on why the run is incomplete. Will be `null` if the run is not incomplete. + /// Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + /// The maximum number of prompt tokens specified to have been used over the course of the run. + /// The maximum number of completion tokens specified to have been used over the course of the run. + /// The strategy to use for dropping messages as the context windows moves forward. + /// Controls whether or not and which tool is called by the model. + /// The response format of the tool calls used in this run. /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - /// , , , , , or is null. - internal ThreadRun(string id, string threadId, string assistantId, RunStatus status, RunError lastError, string model, string instructions, IEnumerable tools, IEnumerable fileIds, DateTimeOffset createdAt, DateTimeOffset? expiresAt, DateTimeOffset? startedAt, DateTimeOffset? completedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, IReadOnlyDictionary metadata) + /// , , , , or is null. + internal ThreadRun(string id, string threadId, string assistantId, RunStatus status, RunError lastError, string model, string instructions, IEnumerable tools, DateTimeOffset createdAt, DateTimeOffset? expiresAt, DateTimeOffset? startedAt, DateTimeOffset? completedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, IncompleteRunDetails? incompleteDetails, RunCompletionUsage usage, int? maxPromptTokens, int? maxCompletionTokens, TruncationObject truncationStrategy, BinaryData toolChoice, BinaryData responseFormat, IReadOnlyDictionary metadata) { Argument.AssertNotNull(id, nameof(id)); Argument.AssertNotNull(threadId, nameof(threadId)); @@ -76,7 +82,6 @@ internal ThreadRun(string id, string threadId, string assistantId, RunStatus sta Argument.AssertNotNull(model, nameof(model)); Argument.AssertNotNull(instructions, nameof(instructions)); Argument.AssertNotNull(tools, nameof(tools)); - Argument.AssertNotNull(fileIds, nameof(fileIds)); Id = id; ThreadId = threadId; @@ -86,13 +91,19 @@ internal ThreadRun(string id, string threadId, string assistantId, RunStatus sta Model = model; Instructions = instructions; Tools = tools.ToList(); - FileIds = fileIds.ToList(); CreatedAt = createdAt; ExpiresAt = expiresAt; StartedAt = startedAt; CompletedAt = completedAt; CancelledAt = cancelledAt; FailedAt = failedAt; + IncompleteDetails = incompleteDetails; + Usage = usage; + MaxPromptTokens = maxPromptTokens; + MaxCompletionTokens = maxCompletionTokens; + TruncationStrategy = truncationStrategy; + ToolChoice = toolChoice; + ResponseFormat = responseFormat; Metadata = metadata; } @@ -113,18 +124,26 @@ internal ThreadRun(string id, string threadId, string assistantId, RunStatus sta /// /// The overridden enabled tools used for this assistant thread run. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . /// - /// A list of attached file IDs, ordered by creation date in ascending order. /// The Unix timestamp, in seconds, representing when this object was created. /// The Unix timestamp, in seconds, representing when this item expires. /// The Unix timestamp, in seconds, representing when this item was started. /// The Unix timestamp, in seconds, representing when this completed. /// The Unix timestamp, in seconds, representing when this was cancelled. /// The Unix timestamp, in seconds, representing when this failed. + /// Details on why the run is incomplete. Will be `null` if the run is not incomplete. + /// Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + /// The sampling temperature used for this run. If not set, defaults to 1. + /// The nucleus sampling value used for this run. If not set, defaults to 1. + /// The maximum number of prompt tokens specified to have been used over the course of the run. + /// The maximum number of completion tokens specified to have been used over the course of the run. + /// The strategy to use for dropping messages as the context windows moves forward. + /// Controls whether or not and which tool is called by the model. + /// The response format of the tool calls used in this run. /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// Keeps track of any properties unknown to the library. - internal ThreadRun(string id, string @object, string threadId, string assistantId, RunStatus status, RequiredAction requiredAction, RunError lastError, string model, string instructions, IReadOnlyList tools, IReadOnlyList fileIds, DateTimeOffset createdAt, DateTimeOffset? expiresAt, DateTimeOffset? startedAt, DateTimeOffset? completedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + internal ThreadRun(string id, string @object, string threadId, string assistantId, RunStatus status, RequiredAction requiredAction, RunError lastError, string model, string instructions, IReadOnlyList tools, DateTimeOffset createdAt, DateTimeOffset? expiresAt, DateTimeOffset? startedAt, DateTimeOffset? completedAt, DateTimeOffset? cancelledAt, DateTimeOffset? failedAt, IncompleteRunDetails? incompleteDetails, RunCompletionUsage usage, float? temperature, float? topP, int? maxPromptTokens, int? maxCompletionTokens, TruncationObject truncationStrategy, BinaryData toolChoice, BinaryData responseFormat, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) { Id = id; Object = @object; @@ -136,13 +155,21 @@ internal ThreadRun(string id, string @object, string threadId, string assistantI Model = model; Instructions = instructions; Tools = tools; - FileIds = fileIds; CreatedAt = createdAt; ExpiresAt = expiresAt; StartedAt = startedAt; CompletedAt = completedAt; CancelledAt = cancelledAt; FailedAt = failedAt; + IncompleteDetails = incompleteDetails; + Usage = usage; + Temperature = temperature; + TopP = topP; + MaxPromptTokens = maxPromptTokens; + MaxCompletionTokens = maxCompletionTokens; + TruncationStrategy = truncationStrategy; + ToolChoice = toolChoice; + ResponseFormat = responseFormat; Metadata = metadata; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -176,11 +203,9 @@ internal ThreadRun() /// /// The overridden enabled tools used for this assistant thread run. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . /// public IReadOnlyList Tools { get; } - /// A list of attached file IDs, ordered by creation date in ascending order. - public IReadOnlyList FileIds { get; } /// The Unix timestamp, in seconds, representing when this object was created. public DateTimeOffset CreatedAt { get; } /// The Unix timestamp, in seconds, representing when this item expires. @@ -193,6 +218,110 @@ internal ThreadRun() public DateTimeOffset? CancelledAt { get; } /// The Unix timestamp, in seconds, representing when this failed. public DateTimeOffset? FailedAt { get; } + /// Details on why the run is incomplete. Will be `null` if the run is not incomplete. + public IncompleteRunDetails? IncompleteDetails { get; } + /// Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + public RunCompletionUsage Usage { get; } + /// The sampling temperature used for this run. If not set, defaults to 1. + public float? Temperature { get; } + /// The nucleus sampling value used for this run. If not set, defaults to 1. + public float? TopP { get; } + /// The maximum number of prompt tokens specified to have been used over the course of the run. + public int? MaxPromptTokens { get; } + /// The maximum number of completion tokens specified to have been used over the course of the run. + public int? MaxCompletionTokens { get; } + /// The strategy to use for dropping messages as the context windows moves forward. + public TruncationObject TruncationStrategy { get; } + /// + /// Controls whether or not and which tool is called by the model. + /// + /// To assign an object to this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// + /// Supported types: + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData ToolChoice { get; } + /// + /// The response format of the tool calls used in this run. + /// + /// To assign an object to this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// + /// Supported types: + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData ResponseFormat { get; } /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. public IReadOnlyDictionary Metadata { get; } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadStreamEvent.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadStreamEvent.cs new file mode 100644 index 000000000000..b3d849b88dd7 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ThreadStreamEvent.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Thread operation related streaming events. + public readonly partial struct ThreadStreamEvent : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ThreadStreamEvent(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ThreadCreatedValue = "thread.created"; + + /// Event sent when a new thread is created. The data of this event is of type AssistantThread. + public static ThreadStreamEvent ThreadCreated { get; } = new ThreadStreamEvent(ThreadCreatedValue); + /// Determines if two values are the same. + public static bool operator ==(ThreadStreamEvent left, ThreadStreamEvent right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ThreadStreamEvent left, ThreadStreamEvent right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator ThreadStreamEvent(string value) => new ThreadStreamEvent(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ThreadStreamEvent other && Equals(other); + /// + public bool Equals(ThreadStreamEvent other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ToolDefinition.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ToolDefinition.Serialization.cs index e5bbd9e2b0cb..9ea0b740ff1a 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ToolDefinition.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ToolDefinition.Serialization.cs @@ -71,8 +71,8 @@ internal static ToolDefinition DeserializeToolDefinition(JsonElement element, Mo switch (discriminator.GetString()) { case "code_interpreter": return CodeInterpreterToolDefinition.DeserializeCodeInterpreterToolDefinition(element, options); + case "file_search": return FileSearchToolDefinition.DeserializeFileSearchToolDefinition(element, options); case "function": return FunctionToolDefinition.DeserializeFunctionToolDefinition(element, options); - case "retrieval": return RetrievalToolDefinition.DeserializeRetrievalToolDefinition(element, options); } } return UnknownToolDefinition.DeserializeUnknownToolDefinition(element, options); diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ToolDefinition.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ToolDefinition.cs index b9d063fe1c0c..be4c9b0d6cbf 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ToolDefinition.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ToolDefinition.cs @@ -13,7 +13,7 @@ namespace Azure.AI.OpenAI.Assistants /// /// An abstract representation of an input tool definition that an assistant can use. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . /// public abstract partial class ToolDefinition { diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantFile.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ToolResources.Serialization.cs similarity index 59% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantFile.Serialization.cs rename to sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ToolResources.Serialization.cs index ea4cf4b4c062..044ce4d7c443 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/AssistantFile.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ToolResources.Serialization.cs @@ -13,27 +13,29 @@ namespace Azure.AI.OpenAI.Assistants { - public partial class AssistantFile : IUtf8JsonSerializable, IJsonModel + public partial class ToolResources : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(AssistantFile)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(ToolResources)} does not support writing '{format}' format."); } writer.WriteStartObject(); - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - writer.WritePropertyName("object"u8); - writer.WriteStringValue(Object); - writer.WritePropertyName("created_at"u8); - writer.WriteNumberValue(CreatedAt, "U"); - writer.WritePropertyName("assistant_id"u8); - writer.WriteStringValue(AssistantId); + if (Optional.IsDefined(CodeInterpreter)) + { + writer.WritePropertyName("code_interpreter"u8); + writer.WriteObjectValue(CodeInterpreter, options); + } + if (Optional.IsDefined(FileSearch)) + { + writer.WritePropertyName("file_search"u8); + writer.WriteObjectValue(FileSearch, options); + } if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -52,19 +54,19 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt writer.WriteEndObject(); } - AssistantFile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + ToolResources IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(AssistantFile)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(ToolResources)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeAssistantFile(document.RootElement, options); + return DeserializeToolResources(document.RootElement, options); } - internal static AssistantFile DeserializeAssistantFile(JsonElement element, ModelReaderWriterOptions options = null) + internal static ToolResources DeserializeToolResources(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -72,32 +74,28 @@ internal static AssistantFile DeserializeAssistantFile(JsonElement element, Mode { return null; } - string id = default; - string @object = default; - DateTimeOffset createdAt = default; - string assistantId = default; + CodeInterpreterToolResource codeInterpreter = default; + FileSearchToolResource fileSearch = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { - if (property.NameEquals("id"u8)) - { - id = property.Value.GetString(); - continue; - } - if (property.NameEquals("object"u8)) + if (property.NameEquals("code_interpreter"u8)) { - @object = property.Value.GetString(); - continue; - } - if (property.NameEquals("created_at"u8)) - { - createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + codeInterpreter = CodeInterpreterToolResource.DeserializeCodeInterpreterToolResource(property.Value, options); continue; } - if (property.NameEquals("assistant_id"u8)) + if (property.NameEquals("file_search"u8)) { - assistantId = property.Value.GetString(); + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fileSearch = FileSearchToolResource.DeserializeFileSearchToolResource(property.Value, options); continue; } if (options.Format != "W") @@ -106,46 +104,46 @@ internal static AssistantFile DeserializeAssistantFile(JsonElement element, Mode } } serializedAdditionalRawData = rawDataDictionary; - return new AssistantFile(id, @object, createdAt, assistantId, serializedAdditionalRawData); + return new ToolResources(codeInterpreter, fileSearch, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(AssistantFile)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(ToolResources)} does not support writing '{options.Format}' format."); } } - AssistantFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + ToolResources IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data); - return DeserializeAssistantFile(document.RootElement, options); + return DeserializeToolResources(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(AssistantFile)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(ToolResources)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static AssistantFile FromResponse(Response response) + internal static ToolResources FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content); - return DeserializeAssistantFile(document.RootElement); + return DeserializeToolResources(document.RootElement); } /// Convert into a . diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ToolResources.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ToolResources.cs new file mode 100644 index 000000000000..408316763e48 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/ToolResources.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// + /// A set of resources that are used by the assistant's tools. The resources are specific to the type of + /// tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` + /// tool requires a list of vector store IDs. + /// + public partial class ToolResources + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal ToolResources() + { + } + + /// Initializes a new instance of . + /// Resources to be used by the `code_interpreter tool` consisting of file IDs. + /// Resources to be used by the `file_search` tool consisting of vector store IDs. + /// Keeps track of any properties unknown to the library. + internal ToolResources(CodeInterpreterToolResource codeInterpreter, FileSearchToolResource fileSearch, IDictionary serializedAdditionalRawData) + { + CodeInterpreter = codeInterpreter; + FileSearch = fileSearch; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Resources to be used by the `code_interpreter tool` consisting of file IDs. + public CodeInterpreterToolResource CodeInterpreter { get; } + /// Resources to be used by the `file_search` tool consisting of vector store IDs. + public FileSearchToolResource FileSearch { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/TruncationObject.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/TruncationObject.Serialization.cs new file mode 100644 index 000000000000..d6f67e7b80e1 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/TruncationObject.Serialization.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class TruncationObject : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TruncationObject)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (Optional.IsDefined(LastMessages)) + { + if (LastMessages != null) + { + writer.WritePropertyName("last_messages"u8); + writer.WriteNumberValue(LastMessages.Value); + } + else + { + writer.WriteNull("last_messages"); + } + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + TruncationObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(TruncationObject)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeTruncationObject(document.RootElement, options); + } + + internal static TruncationObject DeserializeTruncationObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + TruncationStrategy type = default; + int? lastMessages = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new TruncationStrategy(property.Value.GetString()); + continue; + } + if (property.NameEquals("last_messages"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + lastMessages = null; + continue; + } + lastMessages = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new TruncationObject(type, lastMessages, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(TruncationObject)} does not support writing '{options.Format}' format."); + } + } + + TruncationObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeTruncationObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(TruncationObject)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static TruncationObject FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeTruncationObject(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/TruncationObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/TruncationObject.cs new file mode 100644 index 000000000000..a662e1b7761f --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/TruncationObject.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// + /// Controls for how a thread will be truncated prior to the run. Use this to control the initial + /// context window of the run. + /// + public partial class TruncationObject + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// + /// The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will + /// be truncated to the `lastMessages` count most recent messages in the thread. When set to `auto`, messages in the middle of the thread + /// will be dropped to fit the context length of the model, `max_prompt_tokens`. + /// + public TruncationObject(TruncationStrategy type) + { + Type = type; + } + + /// Initializes a new instance of . + /// + /// The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will + /// be truncated to the `lastMessages` count most recent messages in the thread. When set to `auto`, messages in the middle of the thread + /// will be dropped to fit the context length of the model, `max_prompt_tokens`. + /// + /// The number of most recent messages from the thread when constructing the context for the run. + /// Keeps track of any properties unknown to the library. + internal TruncationObject(TruncationStrategy type, int? lastMessages, IDictionary serializedAdditionalRawData) + { + Type = type; + LastMessages = lastMessages; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal TruncationObject() + { + } + + /// + /// The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will + /// be truncated to the `lastMessages` count most recent messages in the thread. When set to `auto`, messages in the middle of the thread + /// will be dropped to fit the context length of the model, `max_prompt_tokens`. + /// + public TruncationStrategy Type { get; set; } + /// The number of most recent messages from the thread when constructing the context for the run. + public int? LastMessages { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/TruncationStrategy.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/TruncationStrategy.cs new file mode 100644 index 000000000000..318fa1a7bb10 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/TruncationStrategy.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Possible truncation strategies for the thread. + public readonly partial struct TruncationStrategy : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public TruncationStrategy(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AutoValue = "auto"; + private const string LastMessagesValue = "last_messages"; + + /// Default value. Messages in the middle of the thread will be dropped to fit the context length of the model. + public static TruncationStrategy Auto { get; } = new TruncationStrategy(AutoValue); + /// The thread will truncate to the `lastMessages` count of recent messages. + public static TruncationStrategy LastMessages { get; } = new TruncationStrategy(LastMessagesValue); + /// Determines if two values are the same. + public static bool operator ==(TruncationStrategy left, TruncationStrategy right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(TruncationStrategy left, TruncationStrategy right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator TruncationStrategy(string value) => new TruncationStrategy(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is TruncationStrategy other && Equals(other); + /// + public bool Equals(TruncationStrategy other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageDeltaContent.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageDeltaContent.Serialization.cs new file mode 100644 index 000000000000..5a261b509b46 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageDeltaContent.Serialization.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class UnknownMessageDeltaContent : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaContent)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + MessageDeltaContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaContent)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaContent(document.RootElement, options); + } + + internal static UnknownMessageDeltaContent DeserializeUnknownMessageDeltaContent(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownMessageDeltaContent(index, type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaContent)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaContent IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageDeltaContent(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaContent)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownMessageDeltaContent FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUnknownMessageDeltaContent(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageDeltaContent.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageDeltaContent.cs new file mode 100644 index 000000000000..7b50c79a9122 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageDeltaContent.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Unknown version of MessageDeltaContent. + internal partial class UnknownMessageDeltaContent : MessageDeltaContent + { + /// Initializes a new instance of . + /// The index of the content part of the message. + /// The type of content for this content part. + /// Keeps track of any properties unknown to the library. + internal UnknownMessageDeltaContent(int index, string type, IDictionary serializedAdditionalRawData) : base(index, type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownMessageDeltaContent() + { + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageDeltaTextAnnotation.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageDeltaTextAnnotation.Serialization.cs new file mode 100644 index 000000000000..649bf2346f43 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageDeltaTextAnnotation.Serialization.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class UnknownMessageDeltaTextAnnotation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextAnnotation)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + MessageDeltaTextAnnotation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MessageDeltaTextAnnotation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMessageDeltaTextAnnotation(document.RootElement, options); + } + + internal static UnknownMessageDeltaTextAnnotation DeserializeUnknownMessageDeltaTextAnnotation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownMessageDeltaTextAnnotation(index, type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MessageDeltaTextAnnotation)} does not support writing '{options.Format}' format."); + } + } + + MessageDeltaTextAnnotation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeMessageDeltaTextAnnotation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MessageDeltaTextAnnotation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownMessageDeltaTextAnnotation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUnknownMessageDeltaTextAnnotation(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageDeltaTextAnnotation.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageDeltaTextAnnotation.cs new file mode 100644 index 000000000000..3a65e8f866b4 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageDeltaTextAnnotation.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Unknown version of MessageDeltaTextAnnotation. + internal partial class UnknownMessageDeltaTextAnnotation : MessageDeltaTextAnnotation + { + /// Initializes a new instance of . + /// The index of the annotation within a text content part. + /// The type of the text content annotation. + /// Keeps track of any properties unknown to the library. + internal UnknownMessageDeltaTextAnnotation(int index, string type, IDictionary serializedAdditionalRawData) : base(index, type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownMessageDeltaTextAnnotation() + { + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageTextAnnotation.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageTextAnnotation.Serialization.cs index f3ca2a8097cf..5c84db7d15dc 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageTextAnnotation.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageTextAnnotation.Serialization.cs @@ -30,10 +30,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW writer.WriteStringValue(Type); writer.WritePropertyName("text"u8); writer.WriteStringValue(Text); - writer.WritePropertyName("start_index"u8); - writer.WriteNumberValue(StartIndex); - writer.WritePropertyName("end_index"u8); - writer.WriteNumberValue(EndIndex); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -74,8 +70,6 @@ internal static UnknownMessageTextAnnotation DeserializeUnknownMessageTextAnnota } string type = "Unknown"; string text = default; - int startIndex = default; - int endIndex = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -90,23 +84,13 @@ internal static UnknownMessageTextAnnotation DeserializeUnknownMessageTextAnnota text = property.Value.GetString(); continue; } - if (property.NameEquals("start_index"u8)) - { - startIndex = property.Value.GetInt32(); - continue; - } - if (property.NameEquals("end_index"u8)) - { - endIndex = property.Value.GetInt32(); - continue; - } if (options.Format != "W") { rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); } } serializedAdditionalRawData = rawDataDictionary; - return new UnknownMessageTextAnnotation(type, text, startIndex, endIndex, serializedAdditionalRawData); + return new UnknownMessageTextAnnotation(type, text, serializedAdditionalRawData); } BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageTextAnnotation.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageTextAnnotation.cs index 707b99138307..8df46b4ee1f3 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageTextAnnotation.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownMessageTextAnnotation.cs @@ -16,10 +16,8 @@ internal partial class UnknownMessageTextAnnotation : MessageTextAnnotation /// Initializes a new instance of . /// The object type. /// The textual content associated with this text annotation item. - /// The first text index associated with this text annotation. - /// The last text index associated with this text annotation. /// Keeps track of any properties unknown to the library. - internal UnknownMessageTextAnnotation(string type, string text, int startIndex, int endIndex, IDictionary serializedAdditionalRawData) : base(type, text, startIndex, endIndex, serializedAdditionalRawData) + internal UnknownMessageTextAnnotation(string type, string text, IDictionary serializedAdditionalRawData) : base(type, text, serializedAdditionalRawData) { } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.Serialization.cs new file mode 100644 index 000000000000..c7cdadff6c72 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.Serialization.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class UnknownRunStepDeltaCodeInterpreterOutput : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterOutput)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunStepDeltaCodeInterpreterOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterOutput)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaCodeInterpreterOutput(document.RootElement, options); + } + + internal static UnknownRunStepDeltaCodeInterpreterOutput DeserializeUnknownRunStepDeltaCodeInterpreterOutput(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownRunStepDeltaCodeInterpreterOutput(index, type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterOutput)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaCodeInterpreterOutput IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepDeltaCodeInterpreterOutput(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaCodeInterpreterOutput)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownRunStepDeltaCodeInterpreterOutput FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUnknownRunStepDeltaCodeInterpreterOutput(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.cs new file mode 100644 index 000000000000..cda7227367bc --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaCodeInterpreterOutput.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Unknown version of RunStepDeltaCodeInterpreterOutput. + internal partial class UnknownRunStepDeltaCodeInterpreterOutput : RunStepDeltaCodeInterpreterOutput + { + /// Initializes a new instance of . + /// The index of the output in the streaming run step tool call's Code Interpreter outputs array. + /// The type of the streaming run step tool call's Code Interpreter output. + /// Keeps track of any properties unknown to the library. + internal UnknownRunStepDeltaCodeInterpreterOutput(int index, string type, IDictionary serializedAdditionalRawData) : base(index, type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownRunStepDeltaCodeInterpreterOutput() + { + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RetrievalToolDefinition.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaDetail.Serialization.cs similarity index 60% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RetrievalToolDefinition.Serialization.cs rename to sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaDetail.Serialization.cs index dd67f9ec7c3e..5bad8ffd2844 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/RetrievalToolDefinition.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaDetail.Serialization.cs @@ -13,16 +13,16 @@ namespace Azure.AI.OpenAI.Assistants { - public partial class RetrievalToolDefinition : IUtf8JsonSerializable, IJsonModel + internal partial class UnknownRunStepDeltaDetail : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RetrievalToolDefinition)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support writing '{format}' format."); } writer.WriteStartObject(); @@ -46,19 +46,19 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade writer.WriteEndObject(); } - RetrievalToolDefinition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + RunStepDeltaDetail IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(RetrievalToolDefinition)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeRetrievalToolDefinition(document.RootElement, options); + return DeserializeRunStepDeltaDetail(document.RootElement, options); } - internal static RetrievalToolDefinition DeserializeRetrievalToolDefinition(JsonElement element, ModelReaderWriterOptions options = null) + internal static UnknownRunStepDeltaDetail DeserializeUnknownRunStepDeltaDetail(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -66,7 +66,7 @@ internal static RetrievalToolDefinition DeserializeRetrievalToolDefinition(JsonE { return null; } - string type = default; + string type = "Unknown"; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -82,53 +82,53 @@ internal static RetrievalToolDefinition DeserializeRetrievalToolDefinition(JsonE } } serializedAdditionalRawData = rawDataDictionary; - return new RetrievalToolDefinition(type, serializedAdditionalRawData); + return new UnknownRunStepDeltaDetail(type, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(RetrievalToolDefinition)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support writing '{options.Format}' format."); } } - RetrievalToolDefinition IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + RunStepDeltaDetail IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data); - return DeserializeRetrievalToolDefinition(document.RootElement, options); + return DeserializeRunStepDeltaDetail(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(RetrievalToolDefinition)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(RunStepDeltaDetail)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static new RetrievalToolDefinition FromResponse(Response response) + internal static new UnknownRunStepDeltaDetail FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content); - return DeserializeRetrievalToolDefinition(document.RootElement); + return DeserializeUnknownRunStepDeltaDetail(document.RootElement); } /// Convert into a . internal override RequestContent ToRequestContent() { var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); return content; } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaDetail.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaDetail.cs new file mode 100644 index 000000000000..bf9efec7d936 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaDetail.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Unknown version of RunStepDeltaDetail. + internal partial class UnknownRunStepDeltaDetail : RunStepDeltaDetail + { + /// Initializes a new instance of . + /// The object type for the run step detail object. + /// Keeps track of any properties unknown to the library. + internal UnknownRunStepDeltaDetail(string type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownRunStepDeltaDetail() + { + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaToolCall.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaToolCall.Serialization.cs new file mode 100644 index 000000000000..a23cb38bcab1 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaToolCall.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class UnknownRunStepDeltaToolCall : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaToolCall)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("index"u8); + writer.WriteNumberValue(Index); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + RunStepDeltaToolCall IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(RunStepDeltaToolCall)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeRunStepDeltaToolCall(document.RootElement, options); + } + + internal static UnknownRunStepDeltaToolCall DeserializeUnknownRunStepDeltaToolCall(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int index = default; + string id = default; + string type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("index"u8)) + { + index = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownRunStepDeltaToolCall(index, id, type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(RunStepDeltaToolCall)} does not support writing '{options.Format}' format."); + } + } + + RunStepDeltaToolCall IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeRunStepDeltaToolCall(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(RunStepDeltaToolCall)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownRunStepDeltaToolCall FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUnknownRunStepDeltaToolCall(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaToolCall.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaToolCall.cs new file mode 100644 index 000000000000..01e29a7c3518 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownRunStepDeltaToolCall.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Unknown version of RunStepDeltaToolCall. + internal partial class UnknownRunStepDeltaToolCall : RunStepDeltaToolCall + { + /// Initializes a new instance of . + /// The index of the tool call detail in the run step's tool_calls array. + /// The ID of the tool call, used when submitting outputs to the run. + /// The type of the tool call detail item in a streaming run step's details. + /// Keeps track of any properties unknown to the library. + internal UnknownRunStepDeltaToolCall(int index, string id, string type, IDictionary serializedAdditionalRawData) : base(index, id, type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownRunStepDeltaToolCall() + { + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownVectorStoreChunkingStrategyRequest.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownVectorStoreChunkingStrategyRequest.Serialization.cs new file mode 100644 index 000000000000..a6bd403223af --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownVectorStoreChunkingStrategyRequest.Serialization.cs @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class UnknownVectorStoreChunkingStrategyRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyRequest)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VectorStoreChunkingStrategyRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreChunkingStrategyRequest(document.RootElement, options); + } + + internal static UnknownVectorStoreChunkingStrategyRequest DeserializeUnknownVectorStoreChunkingStrategyRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VectorStoreChunkingStrategyRequestType type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new VectorStoreChunkingStrategyRequestType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownVectorStoreChunkingStrategyRequest(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyRequest)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreChunkingStrategyRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreChunkingStrategyRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownVectorStoreChunkingStrategyRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUnknownVectorStoreChunkingStrategyRequest(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownVectorStoreChunkingStrategyRequest.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownVectorStoreChunkingStrategyRequest.cs new file mode 100644 index 000000000000..287e2c3a3496 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownVectorStoreChunkingStrategyRequest.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Unknown version of VectorStoreChunkingStrategyRequest. + internal partial class UnknownVectorStoreChunkingStrategyRequest : VectorStoreChunkingStrategyRequest + { + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal UnknownVectorStoreChunkingStrategyRequest(VectorStoreChunkingStrategyRequestType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownVectorStoreChunkingStrategyRequest() + { + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownVectorStoreChunkingStrategyResponse.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownVectorStoreChunkingStrategyResponse.Serialization.cs new file mode 100644 index 000000000000..1e409c04654c --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownVectorStoreChunkingStrategyResponse.Serialization.cs @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + internal partial class UnknownVectorStoreChunkingStrategyResponse : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyResponse)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VectorStoreChunkingStrategyResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyResponse)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreChunkingStrategyResponse(document.RootElement, options); + } + + internal static UnknownVectorStoreChunkingStrategyResponse DeserializeUnknownVectorStoreChunkingStrategyResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VectorStoreChunkingStrategyResponseType type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new VectorStoreChunkingStrategyResponseType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownVectorStoreChunkingStrategyResponse(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyResponse)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreChunkingStrategyResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreChunkingStrategyResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyResponse)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownVectorStoreChunkingStrategyResponse FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUnknownVectorStoreChunkingStrategyResponse(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownVectorStoreChunkingStrategyResponse.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownVectorStoreChunkingStrategyResponse.cs new file mode 100644 index 000000000000..d81dc4925d3c --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UnknownVectorStoreChunkingStrategyResponse.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Unknown version of VectorStoreChunkingStrategyResponse. + internal partial class UnknownVectorStoreChunkingStrategyResponse : VectorStoreChunkingStrategyResponse + { + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal UnknownVectorStoreChunkingStrategyResponse(VectorStoreChunkingStrategyResponseType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownVectorStoreChunkingStrategyResponse() + { + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantOptions.Serialization.cs index c9b296e27af2..05de83029fa0 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantOptions.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantOptions.Serialization.cs @@ -77,15 +77,53 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader } writer.WriteEndArray(); } - if (Optional.IsCollectionDefined(FileIds)) + if (Optional.IsDefined(ToolResources)) { - writer.WritePropertyName("file_ids"u8); - writer.WriteStartArray(); - foreach (var item in FileIds) + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); + } + if (Optional.IsDefined(Temperature)) + { + if (Temperature != null) { - writer.WriteStringValue(item); + writer.WritePropertyName("temperature"u8); + writer.WriteNumberValue(Temperature.Value); + } + else + { + writer.WriteNull("temperature"); + } + } + if (Optional.IsDefined(TopP)) + { + if (TopP != null) + { + writer.WritePropertyName("top_p"u8); + writer.WriteNumberValue(TopP.Value); + } + else + { + writer.WriteNull("top_p"); + } + } + if (Optional.IsDefined(ResponseFormat)) + { + if (ResponseFormat != null) + { + writer.WritePropertyName("response_format"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(ResponseFormat); +#else + using (JsonDocument document = JsonDocument.Parse(ResponseFormat)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + else + { + writer.WriteNull("response_format"); } - writer.WriteEndArray(); } if (Optional.IsCollectionDefined(Metadata)) { @@ -148,7 +186,10 @@ internal static UpdateAssistantOptions DeserializeUpdateAssistantOptions(JsonEle string description = default; string instructions = default; IList tools = default; - IList fileIds = default; + UpdateToolResourcesOptions toolResources = default; + float? temperature = default; + float? topP = default; + BinaryData responseFormat = default; IDictionary metadata = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); @@ -203,18 +244,43 @@ internal static UpdateAssistantOptions DeserializeUpdateAssistantOptions(JsonEle tools = array; continue; } - if (property.NameEquals("file_ids"u8)) + if (property.NameEquals("tool_resources"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } - List array = new List(); - foreach (var item in property.Value.EnumerateArray()) + toolResources = UpdateToolResourcesOptions.DeserializeUpdateToolResourcesOptions(property.Value, options); + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) { - array.Add(item.GetString()); + temperature = null; + continue; + } + temperature = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("top_p"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + topP = null; + continue; + } + topP = property.Value.GetSingle(); + continue; + } + if (property.NameEquals("response_format"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + responseFormat = null; + continue; } - fileIds = array; + responseFormat = BinaryData.FromString(property.Value.GetRawText()); continue; } if (property.NameEquals("metadata"u8)) @@ -243,7 +309,10 @@ internal static UpdateAssistantOptions DeserializeUpdateAssistantOptions(JsonEle description, instructions, tools ?? new ChangeTrackingList(), - fileIds ?? new ChangeTrackingList(), + toolResources, + temperature, + topP, + responseFormat, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantOptions.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantOptions.cs index 85770c825c21..b3b50cb3bb79 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantOptions.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantOptions.cs @@ -49,7 +49,6 @@ public partial class UpdateAssistantOptions public UpdateAssistantOptions() { Tools = new ChangeTrackingList(); - FileIds = new ChangeTrackingList(); Metadata = new ChangeTrackingDictionary(); } @@ -61,19 +60,36 @@ public UpdateAssistantOptions() /// /// The modified collection of tools to enable for the assistant. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . /// - /// The modified list of previously uploaded fileIDs to attach to the assistant. + /// + /// A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, + /// the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + /// + /// + /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, + /// while lower values like 0.2 will make it more focused and deterministic. + /// + /// + /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. + /// So 0.1 means only the tokens comprising the top 10% probability mass are considered. + /// + /// We generally recommend altering this or temperature but not both. + /// + /// The response format of the tool calls used by this assistant. /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// Keeps track of any properties unknown to the library. - internal UpdateAssistantOptions(string model, string name, string description, string instructions, IList tools, IList fileIds, IDictionary metadata, IDictionary serializedAdditionalRawData) + internal UpdateAssistantOptions(string model, string name, string description, string instructions, IList tools, UpdateToolResourcesOptions toolResources, float? temperature, float? topP, BinaryData responseFormat, IDictionary metadata, IDictionary serializedAdditionalRawData) { Model = model; Name = name; Description = description; Instructions = instructions; Tools = tools; - FileIds = fileIds; + ToolResources = toolResources; + Temperature = temperature; + TopP = topP; + ResponseFormat = responseFormat; Metadata = metadata; _serializedAdditionalRawData = serializedAdditionalRawData; } @@ -89,11 +105,71 @@ internal UpdateAssistantOptions(string model, string name, string description, s /// /// The modified collection of tools to enable for the assistant. /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. - /// The available derived classes include , and . + /// The available derived classes include , and . /// public IList Tools { get; } - /// The modified list of previously uploaded fileIDs to attach to the assistant. - public IList FileIds { get; } + /// + /// A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. For example, + /// the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. + /// + public UpdateToolResourcesOptions ToolResources { get; set; } + /// + /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, + /// while lower values like 0.2 will make it more focused and deterministic. + /// + public float? Temperature { get; set; } + /// + /// An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. + /// So 0.1 means only the tokens comprising the top 10% probability mass are considered. + /// + /// We generally recommend altering this or temperature but not both. + /// + public float? TopP { get; set; } + /// + /// The response format of the tool calls used by this assistant. + /// + /// To assign an object to this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// + /// Supported types: + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData ResponseFormat { get; set; } /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. public IDictionary Metadata { get; set; } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateThreadRequest.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantThreadOptions.Serialization.cs similarity index 59% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateThreadRequest.Serialization.cs rename to sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantThreadOptions.Serialization.cs index efb58bc378ae..d9faa3c9ac02 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateThreadRequest.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantThreadOptions.Serialization.cs @@ -13,19 +13,31 @@ namespace Azure.AI.OpenAI.Assistants { - internal partial class UpdateThreadRequest : IUtf8JsonSerializable, IJsonModel + public partial class UpdateAssistantThreadOptions : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(UpdateThreadRequest)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(UpdateAssistantThreadOptions)} does not support writing '{format}' format."); } writer.WriteStartObject(); + if (Optional.IsDefined(ToolResources)) + { + if (ToolResources != null) + { + writer.WritePropertyName("tool_resources"u8); + writer.WriteObjectValue(ToolResources, options); + } + else + { + writer.WriteNull("tool_resources"); + } + } if (Optional.IsCollectionDefined(Metadata)) { if (Metadata != null) @@ -62,19 +74,19 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri writer.WriteEndObject(); } - UpdateThreadRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + UpdateAssistantThreadOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(UpdateThreadRequest)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(UpdateAssistantThreadOptions)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeUpdateThreadRequest(document.RootElement, options); + return DeserializeUpdateAssistantThreadOptions(document.RootElement, options); } - internal static UpdateThreadRequest DeserializeUpdateThreadRequest(JsonElement element, ModelReaderWriterOptions options = null) + internal static UpdateAssistantThreadOptions DeserializeUpdateAssistantThreadOptions(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -82,11 +94,22 @@ internal static UpdateThreadRequest DeserializeUpdateThreadRequest(JsonElement e { return null; } - IReadOnlyDictionary metadata = default; + UpdateToolResourcesOptions toolResources = default; + IDictionary metadata = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) { + if (property.NameEquals("tool_resources"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + toolResources = null; + continue; + } + toolResources = UpdateToolResourcesOptions.DeserializeUpdateToolResourcesOptions(property.Value, options); + continue; + } if (property.NameEquals("metadata"u8)) { if (property.Value.ValueKind == JsonValueKind.Null) @@ -107,46 +130,46 @@ internal static UpdateThreadRequest DeserializeUpdateThreadRequest(JsonElement e } } serializedAdditionalRawData = rawDataDictionary; - return new UpdateThreadRequest(metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + return new UpdateAssistantThreadOptions(toolResources, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(UpdateThreadRequest)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(UpdateAssistantThreadOptions)} does not support writing '{options.Format}' format."); } } - UpdateThreadRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + UpdateAssistantThreadOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data); - return DeserializeUpdateThreadRequest(document.RootElement, options); + return DeserializeUpdateAssistantThreadOptions(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(UpdateThreadRequest)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(UpdateAssistantThreadOptions)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static UpdateThreadRequest FromResponse(Response response) + internal static UpdateAssistantThreadOptions FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content); - return DeserializeUpdateThreadRequest(document.RootElement); + return DeserializeUpdateAssistantThreadOptions(document.RootElement); } /// Convert into a . diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateMessageRequest.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantThreadOptions.cs similarity index 53% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateMessageRequest.cs rename to sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantThreadOptions.cs index b58f5b245234..6b7141de049b 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/CreateMessageRequest.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateAssistantThreadOptions.cs @@ -10,8 +10,8 @@ namespace Azure.AI.OpenAI.Assistants { - /// The CreateMessageRequest. - internal partial class CreateMessageRequest + /// The details used to update an existing assistant thread. + public partial class UpdateAssistantThreadOptions { /// /// Keeps track of any properties unknown to the library. @@ -45,47 +45,34 @@ internal partial class CreateMessageRequest /// private IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . - /// The role to associate with the new message. - /// The textual content for the new message. - /// is null. - internal CreateMessageRequest(MessageRole role, string content) + /// Initializes a new instance of . + public UpdateAssistantThreadOptions() { - Argument.AssertNotNull(content, nameof(content)); - - Role = role; - Content = content; - FileIds = new ChangeTrackingList(); Metadata = new ChangeTrackingDictionary(); } - /// Initializes a new instance of . - /// The role to associate with the new message. - /// The textual content for the new message. - /// A list of up to 10 file IDs to associate with the message, as used by tools like 'code_interpreter' or 'retrieval' that can read files. + /// Initializes a new instance of . + /// + /// A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the + /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires + /// a list of vector store IDs + /// /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// Keeps track of any properties unknown to the library. - internal CreateMessageRequest(MessageRole role, string content, IReadOnlyList fileIds, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + internal UpdateAssistantThreadOptions(UpdateToolResourcesOptions toolResources, IDictionary metadata, IDictionary serializedAdditionalRawData) { - Role = role; - Content = content; - FileIds = fileIds; + ToolResources = toolResources; Metadata = metadata; _serializedAdditionalRawData = serializedAdditionalRawData; } - /// Initializes a new instance of for deserialization. - internal CreateMessageRequest() - { - } - - /// The role to associate with the new message. - public MessageRole Role { get; } - /// The textual content for the new message. - public string Content { get; } - /// A list of up to 10 file IDs to associate with the message, as used by tools like 'code_interpreter' or 'retrieval' that can read files. - public IReadOnlyList FileIds { get; } + /// + /// A set of resources that are made available to the assistant's tools in this thread. The resources are specific to the + /// type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires + /// a list of vector store IDs + /// + public UpdateToolResourcesOptions ToolResources { get; set; } /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IReadOnlyDictionary Metadata { get; } + public IDictionary Metadata { get; set; } } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateCodeInterpreterToolResourceOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateCodeInterpreterToolResourceOptions.Serialization.cs new file mode 100644 index 000000000000..465ea22d89ba --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateCodeInterpreterToolResourceOptions.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class UpdateCodeInterpreterToolResourceOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateCodeInterpreterToolResourceOptions)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + UpdateCodeInterpreterToolResourceOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateCodeInterpreterToolResourceOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpdateCodeInterpreterToolResourceOptions(document.RootElement, options); + } + + internal static UpdateCodeInterpreterToolResourceOptions DeserializeUpdateCodeInterpreterToolResourceOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList fileIds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_ids"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + fileIds = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UpdateCodeInterpreterToolResourceOptions(fileIds ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(UpdateCodeInterpreterToolResourceOptions)} does not support writing '{options.Format}' format."); + } + } + + UpdateCodeInterpreterToolResourceOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeUpdateCodeInterpreterToolResourceOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpdateCodeInterpreterToolResourceOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static UpdateCodeInterpreterToolResourceOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUpdateCodeInterpreterToolResourceOptions(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateCodeInterpreterToolResourceOptions.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateCodeInterpreterToolResourceOptions.cs new file mode 100644 index 000000000000..8c09267cd78d --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateCodeInterpreterToolResourceOptions.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Request object to update `code_interpreted` tool resources. + public partial class UpdateCodeInterpreterToolResourceOptions + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public UpdateCodeInterpreterToolResourceOptions() + { + FileIds = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// A list of file IDs to override the current list of the assistant. + /// Keeps track of any properties unknown to the library. + internal UpdateCodeInterpreterToolResourceOptions(IList fileIds, IDictionary serializedAdditionalRawData) + { + FileIds = fileIds; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// A list of file IDs to override the current list of the assistant. + public IList FileIds { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateFileSearchToolResourceOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateFileSearchToolResourceOptions.Serialization.cs new file mode 100644 index 000000000000..8e5ab556eb60 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateFileSearchToolResourceOptions.Serialization.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class UpdateFileSearchToolResourceOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateFileSearchToolResourceOptions)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(VectorStoreIds)) + { + writer.WritePropertyName("vector_store_ids"u8); + writer.WriteStartArray(); + foreach (var item in VectorStoreIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + UpdateFileSearchToolResourceOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateFileSearchToolResourceOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpdateFileSearchToolResourceOptions(document.RootElement, options); + } + + internal static UpdateFileSearchToolResourceOptions DeserializeUpdateFileSearchToolResourceOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList vectorStoreIds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("vector_store_ids"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + vectorStoreIds = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UpdateFileSearchToolResourceOptions(vectorStoreIds ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(UpdateFileSearchToolResourceOptions)} does not support writing '{options.Format}' format."); + } + } + + UpdateFileSearchToolResourceOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeUpdateFileSearchToolResourceOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpdateFileSearchToolResourceOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static UpdateFileSearchToolResourceOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUpdateFileSearchToolResourceOptions(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateFileSearchToolResourceOptions.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateFileSearchToolResourceOptions.cs new file mode 100644 index 000000000000..8742c5cd1b07 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateFileSearchToolResourceOptions.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Request object to update `file_search` tool resources. + public partial class UpdateFileSearchToolResourceOptions + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public UpdateFileSearchToolResourceOptions() + { + VectorStoreIds = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// A list of vector store IDs to override the current list of the assistant. + /// Keeps track of any properties unknown to the library. + internal UpdateFileSearchToolResourceOptions(IList vectorStoreIds, IDictionary serializedAdditionalRawData) + { + VectorStoreIds = vectorStoreIds; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// A list of vector store IDs to override the current list of the assistant. + public IList VectorStoreIds { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateToolResourcesOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateToolResourcesOptions.Serialization.cs new file mode 100644 index 000000000000..38dbde3243f4 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateToolResourcesOptions.Serialization.cs @@ -0,0 +1,157 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class UpdateToolResourcesOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateToolResourcesOptions)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(CodeInterpreter)) + { + writer.WritePropertyName("code_interpreter"u8); + writer.WriteObjectValue(CodeInterpreter, options); + } + if (Optional.IsDefined(FileSearch)) + { + writer.WritePropertyName("file_search"u8); + writer.WriteObjectValue(FileSearch, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + UpdateToolResourcesOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(UpdateToolResourcesOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeUpdateToolResourcesOptions(document.RootElement, options); + } + + internal static UpdateToolResourcesOptions DeserializeUpdateToolResourcesOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + UpdateCodeInterpreterToolResourceOptions codeInterpreter = default; + UpdateFileSearchToolResourceOptions fileSearch = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code_interpreter"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + codeInterpreter = UpdateCodeInterpreterToolResourceOptions.DeserializeUpdateCodeInterpreterToolResourceOptions(property.Value, options); + continue; + } + if (property.NameEquals("file_search"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + fileSearch = UpdateFileSearchToolResourceOptions.DeserializeUpdateFileSearchToolResourceOptions(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UpdateToolResourcesOptions(codeInterpreter, fileSearch, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(UpdateToolResourcesOptions)} does not support writing '{options.Format}' format."); + } + } + + UpdateToolResourcesOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeUpdateToolResourcesOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(UpdateToolResourcesOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static UpdateToolResourcesOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeUpdateToolResourcesOptions(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateToolResourcesOptions.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateToolResourcesOptions.cs new file mode 100644 index 000000000000..919e93c57f1f --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateToolResourcesOptions.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// + /// Request object. A set of resources that are used by the assistant's tools. The resources are specific to the type of tool. + /// For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of + /// vector store IDs. + /// + public partial class UpdateToolResourcesOptions + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public UpdateToolResourcesOptions() + { + } + + /// Initializes a new instance of . + /// + /// Overrides the list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files + /// associated with the tool. + /// + /// Overrides the vector store attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. + /// Keeps track of any properties unknown to the library. + internal UpdateToolResourcesOptions(UpdateCodeInterpreterToolResourceOptions codeInterpreter, UpdateFileSearchToolResourceOptions fileSearch, IDictionary serializedAdditionalRawData) + { + CodeInterpreter = codeInterpreter; + FileSearch = fileSearch; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// Overrides the list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files + /// associated with the tool. + /// + public UpdateCodeInterpreterToolResourceOptions CodeInterpreter { get; set; } + /// Overrides the vector store attached to this assistant. There can be a maximum of 1 vector store attached to the assistant. + public UpdateFileSearchToolResourceOptions FileSearch { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStore.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStore.Serialization.cs new file mode 100644 index 000000000000..131a35e56010 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStore.Serialization.cs @@ -0,0 +1,284 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class VectorStore : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStore)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + writer.WritePropertyName("usage_bytes"u8); + writer.WriteNumberValue(UsageBytes); + writer.WritePropertyName("file_counts"u8); + writer.WriteObjectValue(FileCounts, options); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + if (Optional.IsDefined(ExpiresAfter)) + { + writer.WritePropertyName("expires_after"u8); + writer.WriteObjectValue(ExpiresAfter, options); + } + if (Optional.IsDefined(ExpiresAt)) + { + if (ExpiresAt != null) + { + writer.WritePropertyName("expires_at"u8); + writer.WriteNumberValue(ExpiresAt.Value, "U"); + } + else + { + writer.WriteNull("expires_at"); + } + } + if (LastActiveAt != null) + { + writer.WritePropertyName("last_active_at"u8); + writer.WriteNumberValue(LastActiveAt.Value, "U"); + } + else + { + writer.WriteNull("last_active_at"); + } + if (Metadata != null && Optional.IsCollectionDefined(Metadata)) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VectorStore IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStore)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStore(document.RootElement, options); + } + + internal static VectorStore DeserializeVectorStore(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + VectorStoreObject @object = default; + DateTimeOffset createdAt = default; + string name = default; + int usageBytes = default; + VectorStoreFileCount fileCounts = default; + VectorStoreStatus status = default; + VectorStoreExpirationPolicy expiresAfter = default; + DateTimeOffset? expiresAt = default; + DateTimeOffset? lastActiveAt = default; + IReadOnlyDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new VectorStoreObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("usage_bytes"u8)) + { + usageBytes = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("file_counts"u8)) + { + fileCounts = VectorStoreFileCount.DeserializeVectorStoreFileCount(property.Value, options); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new VectorStoreStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("expires_after"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expiresAfter = VectorStoreExpirationPolicy.DeserializeVectorStoreExpirationPolicy(property.Value, options); + continue; + } + if (property.NameEquals("expires_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + expiresAt = null; + continue; + } + expiresAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("last_active_at"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + lastActiveAt = null; + continue; + } + lastActiveAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + metadata = new ChangeTrackingDictionary(); + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStore( + id, + @object, + createdAt, + name, + usageBytes, + fileCounts, + status, + expiresAfter, + expiresAt, + lastActiveAt, + metadata, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStore)} does not support writing '{options.Format}' format."); + } + } + + VectorStore IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStore(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStore)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStore FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStore(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStore.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStore.cs new file mode 100644 index 000000000000..bd3231e10fc6 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStore.cs @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// A vector store is a collection of processed files can be used by the `file_search` tool. + public partial class VectorStore + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The Unix timestamp (in seconds) for when the vector store was created. + /// The name of the vector store. + /// The total number of bytes used by the files in the vector store. + /// Files count grouped by status processed or being processed by this vector store. + /// The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use. + /// The Unix timestamp (in seconds) for when the vector store was last active. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// , or is null. + internal VectorStore(string id, DateTimeOffset createdAt, string name, int usageBytes, VectorStoreFileCount fileCounts, VectorStoreStatus status, DateTimeOffset? lastActiveAt, IReadOnlyDictionary metadata) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(fileCounts, nameof(fileCounts)); + + Id = id; + CreatedAt = createdAt; + Name = name; + UsageBytes = usageBytes; + FileCounts = fileCounts; + Status = status; + LastActiveAt = lastActiveAt; + Metadata = metadata; + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always `vector_store`. + /// The Unix timestamp (in seconds) for when the vector store was created. + /// The name of the vector store. + /// The total number of bytes used by the files in the vector store. + /// Files count grouped by status processed or being processed by this vector store. + /// The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use. + /// Details on when this vector store expires. + /// The Unix timestamp (in seconds) for when the vector store will expire. + /// The Unix timestamp (in seconds) for when the vector store was last active. + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal VectorStore(string id, VectorStoreObject @object, DateTimeOffset createdAt, string name, int usageBytes, VectorStoreFileCount fileCounts, VectorStoreStatus status, VectorStoreExpirationPolicy expiresAfter, DateTimeOffset? expiresAt, DateTimeOffset? lastActiveAt, IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + CreatedAt = createdAt; + Name = name; + UsageBytes = usageBytes; + FileCounts = fileCounts; + Status = status; + ExpiresAfter = expiresAfter; + ExpiresAt = expiresAt; + LastActiveAt = lastActiveAt; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorStore() + { + } + + /// The identifier, which can be referenced in API endpoints. + public string Id { get; } + /// The object type, which is always `vector_store`. + public VectorStoreObject Object { get; } = VectorStoreObject.VectorStore; + + /// The Unix timestamp (in seconds) for when the vector store was created. + public DateTimeOffset CreatedAt { get; } + /// The name of the vector store. + public string Name { get; } + /// The total number of bytes used by the files in the vector store. + public int UsageBytes { get; } + /// Files count grouped by status processed or being processed by this vector store. + public VectorStoreFileCount FileCounts { get; } + /// The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use. + public VectorStoreStatus Status { get; } + /// Details on when this vector store expires. + public VectorStoreExpirationPolicy ExpiresAfter { get; } + /// The Unix timestamp (in seconds) for when the vector store will expire. + public DateTimeOffset? ExpiresAt { get; } + /// The Unix timestamp (in seconds) for when the vector store was last active. + public DateTimeOffset? LastActiveAt { get; } + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IReadOnlyDictionary Metadata { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreAutoChunkingStrategyRequest.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreAutoChunkingStrategyRequest.Serialization.cs new file mode 100644 index 000000000000..0502f7a71655 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreAutoChunkingStrategyRequest.Serialization.cs @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class VectorStoreAutoChunkingStrategyRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreAutoChunkingStrategyRequest)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VectorStoreAutoChunkingStrategyRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreAutoChunkingStrategyRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreAutoChunkingStrategyRequest(document.RootElement, options); + } + + internal static VectorStoreAutoChunkingStrategyRequest DeserializeVectorStoreAutoChunkingStrategyRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VectorStoreChunkingStrategyRequestType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new VectorStoreChunkingStrategyRequestType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreAutoChunkingStrategyRequest(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreAutoChunkingStrategyRequest)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreAutoChunkingStrategyRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreAutoChunkingStrategyRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreAutoChunkingStrategyRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new VectorStoreAutoChunkingStrategyRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreAutoChunkingStrategyRequest(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreAutoChunkingStrategyRequest.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreAutoChunkingStrategyRequest.cs new file mode 100644 index 000000000000..54ccde180223 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreAutoChunkingStrategyRequest.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The default strategy. This strategy currently uses a max_chunk_size_tokens of 800 and chunk_overlap_tokens of 400. + public partial class VectorStoreAutoChunkingStrategyRequest : VectorStoreChunkingStrategyRequest + { + /// Initializes a new instance of . + public VectorStoreAutoChunkingStrategyRequest() + { + Type = VectorStoreChunkingStrategyRequestType.Auto; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal VectorStoreAutoChunkingStrategyRequest(VectorStoreChunkingStrategyRequestType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreAutoChunkingStrategyResponse.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreAutoChunkingStrategyResponse.Serialization.cs new file mode 100644 index 000000000000..b7858733008e --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreAutoChunkingStrategyResponse.Serialization.cs @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class VectorStoreAutoChunkingStrategyResponse : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreAutoChunkingStrategyResponse)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VectorStoreAutoChunkingStrategyResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreAutoChunkingStrategyResponse)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreAutoChunkingStrategyResponse(document.RootElement, options); + } + + internal static VectorStoreAutoChunkingStrategyResponse DeserializeVectorStoreAutoChunkingStrategyResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VectorStoreChunkingStrategyResponseType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new VectorStoreChunkingStrategyResponseType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreAutoChunkingStrategyResponse(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreAutoChunkingStrategyResponse)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreAutoChunkingStrategyResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreAutoChunkingStrategyResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreAutoChunkingStrategyResponse)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new VectorStoreAutoChunkingStrategyResponse FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreAutoChunkingStrategyResponse(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreAutoChunkingStrategyResponse.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreAutoChunkingStrategyResponse.cs new file mode 100644 index 000000000000..17218eca2365 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreAutoChunkingStrategyResponse.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the chunking_strategy concept was introduced in the API. + public partial class VectorStoreAutoChunkingStrategyResponse : VectorStoreChunkingStrategyResponse + { + /// Initializes a new instance of . + internal VectorStoreAutoChunkingStrategyResponse() + { + Type = VectorStoreChunkingStrategyResponseType.Other; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal VectorStoreAutoChunkingStrategyResponse(VectorStoreChunkingStrategyResponseType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyRequest.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyRequest.Serialization.cs new file mode 100644 index 000000000000..74503df2a436 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyRequest.Serialization.cs @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + [PersistableModelProxy(typeof(UnknownVectorStoreChunkingStrategyRequest))] + public partial class VectorStoreChunkingStrategyRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyRequest)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VectorStoreChunkingStrategyRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreChunkingStrategyRequest(document.RootElement, options); + } + + internal static VectorStoreChunkingStrategyRequest DeserializeVectorStoreChunkingStrategyRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "auto": return VectorStoreAutoChunkingStrategyRequest.DeserializeVectorStoreAutoChunkingStrategyRequest(element, options); + case "static": return VectorStoreStaticChunkingStrategyRequest.DeserializeVectorStoreStaticChunkingStrategyRequest(element, options); + } + } + return UnknownVectorStoreChunkingStrategyRequest.DeserializeUnknownVectorStoreChunkingStrategyRequest(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyRequest)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreChunkingStrategyRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreChunkingStrategyRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreChunkingStrategyRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreChunkingStrategyRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyRequest.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyRequest.cs new file mode 100644 index 000000000000..5f64bb63f131 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyRequest.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// + /// An abstract representation of a vector store chunking strategy configuration. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public abstract partial class VectorStoreChunkingStrategyRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected VectorStoreChunkingStrategyRequest() + { + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal VectorStoreChunkingStrategyRequest(VectorStoreChunkingStrategyRequestType type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The object type. + internal VectorStoreChunkingStrategyRequestType Type { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyRequestType.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyRequestType.cs new file mode 100644 index 000000000000..21116154bdb1 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyRequestType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Type of chunking strategy. + internal readonly partial struct VectorStoreChunkingStrategyRequestType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreChunkingStrategyRequestType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string AutoValue = "auto"; + private const string StaticValue = "static"; + + /// auto. + public static VectorStoreChunkingStrategyRequestType Auto { get; } = new VectorStoreChunkingStrategyRequestType(AutoValue); + /// static. + public static VectorStoreChunkingStrategyRequestType Static { get; } = new VectorStoreChunkingStrategyRequestType(StaticValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreChunkingStrategyRequestType left, VectorStoreChunkingStrategyRequestType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreChunkingStrategyRequestType left, VectorStoreChunkingStrategyRequestType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator VectorStoreChunkingStrategyRequestType(string value) => new VectorStoreChunkingStrategyRequestType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreChunkingStrategyRequestType other && Equals(other); + /// + public bool Equals(VectorStoreChunkingStrategyRequestType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyResponse.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyResponse.Serialization.cs new file mode 100644 index 000000000000..49f33ceb5990 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyResponse.Serialization.cs @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + [PersistableModelProxy(typeof(UnknownVectorStoreChunkingStrategyResponse))] + public partial class VectorStoreChunkingStrategyResponse : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyResponse)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VectorStoreChunkingStrategyResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyResponse)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreChunkingStrategyResponse(document.RootElement, options); + } + + internal static VectorStoreChunkingStrategyResponse DeserializeVectorStoreChunkingStrategyResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "other": return VectorStoreAutoChunkingStrategyResponse.DeserializeVectorStoreAutoChunkingStrategyResponse(element, options); + case "static": return VectorStoreStaticChunkingStrategyResponse.DeserializeVectorStoreStaticChunkingStrategyResponse(element, options); + } + } + return UnknownVectorStoreChunkingStrategyResponse.DeserializeUnknownVectorStoreChunkingStrategyResponse(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyResponse)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreChunkingStrategyResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreChunkingStrategyResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreChunkingStrategyResponse)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreChunkingStrategyResponse FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreChunkingStrategyResponse(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyResponse.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyResponse.cs new file mode 100644 index 000000000000..a4e4bac4d2a8 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyResponse.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// + /// An abstract representation of a vector store chunking strategy configuration. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public abstract partial class VectorStoreChunkingStrategyResponse + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected VectorStoreChunkingStrategyResponse() + { + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + internal VectorStoreChunkingStrategyResponse(VectorStoreChunkingStrategyResponseType type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The object type. + internal VectorStoreChunkingStrategyResponseType Type { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyResponseType.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyResponseType.cs new file mode 100644 index 000000000000..c5c56c31bd2c --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreChunkingStrategyResponseType.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Type of chunking strategy. + internal readonly partial struct VectorStoreChunkingStrategyResponseType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreChunkingStrategyResponseType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string OtherValue = "other"; + private const string StaticValue = "static"; + + /// other. + public static VectorStoreChunkingStrategyResponseType Other { get; } = new VectorStoreChunkingStrategyResponseType(OtherValue); + /// static. + public static VectorStoreChunkingStrategyResponseType Static { get; } = new VectorStoreChunkingStrategyResponseType(StaticValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreChunkingStrategyResponseType left, VectorStoreChunkingStrategyResponseType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreChunkingStrategyResponseType left, VectorStoreChunkingStrategyResponseType right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator VectorStoreChunkingStrategyResponseType(string value) => new VectorStoreChunkingStrategyResponseType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreChunkingStrategyResponseType other && Equals(other); + /// + public bool Equals(VectorStoreChunkingStrategyResponseType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatus.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreDeletionStatus.Serialization.cs similarity index 62% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatus.Serialization.cs rename to sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreDeletionStatus.Serialization.cs index 10bfe96c2204..4e6da1fe0c1f 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatus.Serialization.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreDeletionStatus.Serialization.cs @@ -13,16 +13,16 @@ namespace Azure.AI.OpenAI.Assistants { - internal partial class InternalAssistantFileDeletionStatus : IUtf8JsonSerializable, IJsonModel + public partial class VectorStoreDeletionStatus : IUtf8JsonSerializable, IJsonModel { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalAssistantFileDeletionStatus)} does not support writing '{format}' format."); + throw new FormatException($"The model {nameof(VectorStoreDeletionStatus)} does not support writing '{format}' format."); } writer.WriteStartObject(); @@ -50,19 +50,19 @@ void IJsonModel.Write(Utf8JsonWriter writer writer.WriteEndObject(); } - InternalAssistantFileDeletionStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + VectorStoreDeletionStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") { - throw new FormatException($"The model {nameof(InternalAssistantFileDeletionStatus)} does not support reading '{format}' format."); + throw new FormatException($"The model {nameof(VectorStoreDeletionStatus)} does not support reading '{format}' format."); } using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializeInternalAssistantFileDeletionStatus(document.RootElement, options); + return DeserializeVectorStoreDeletionStatus(document.RootElement, options); } - internal static InternalAssistantFileDeletionStatus DeserializeInternalAssistantFileDeletionStatus(JsonElement element, ModelReaderWriterOptions options = null) + internal static VectorStoreDeletionStatus DeserializeVectorStoreDeletionStatus(JsonElement element, ModelReaderWriterOptions options = null) { options ??= ModelSerializationExtensions.WireOptions; @@ -72,7 +72,7 @@ internal static InternalAssistantFileDeletionStatus DeserializeInternalAssistant } string id = default; bool deleted = default; - InternalAssistantFileDeletionStatusObject @object = default; + VectorStoreDeletionStatusObject @object = default; IDictionary serializedAdditionalRawData = default; Dictionary rawDataDictionary = new Dictionary(); foreach (var property in element.EnumerateObject()) @@ -89,7 +89,7 @@ internal static InternalAssistantFileDeletionStatus DeserializeInternalAssistant } if (property.NameEquals("object"u8)) { - @object = new InternalAssistantFileDeletionStatusObject(property.Value.GetString()); + @object = new VectorStoreDeletionStatusObject(property.Value.GetString()); continue; } if (options.Format != "W") @@ -98,46 +98,46 @@ internal static InternalAssistantFileDeletionStatus DeserializeInternalAssistant } } serializedAdditionalRawData = rawDataDictionary; - return new InternalAssistantFileDeletionStatus(id, deleted, @object, serializedAdditionalRawData); + return new VectorStoreDeletionStatus(id, deleted, @object, serializedAdditionalRawData); } - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": return ModelReaderWriter.Write(this, options); default: - throw new FormatException($"The model {nameof(InternalAssistantFileDeletionStatus)} does not support writing '{options.Format}' format."); + throw new FormatException($"The model {nameof(VectorStoreDeletionStatus)} does not support writing '{options.Format}' format."); } } - InternalAssistantFileDeletionStatus IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + VectorStoreDeletionStatus IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; switch (format) { case "J": { using JsonDocument document = JsonDocument.Parse(data); - return DeserializeInternalAssistantFileDeletionStatus(document.RootElement, options); + return DeserializeVectorStoreDeletionStatus(document.RootElement, options); } default: - throw new FormatException($"The model {nameof(InternalAssistantFileDeletionStatus)} does not support reading '{options.Format}' format."); + throw new FormatException($"The model {nameof(VectorStoreDeletionStatus)} does not support reading '{options.Format}' format."); } } - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; /// Deserializes the model from a raw response. /// The response to deserialize the model from. - internal static InternalAssistantFileDeletionStatus FromResponse(Response response) + internal static VectorStoreDeletionStatus FromResponse(Response response) { using var document = JsonDocument.Parse(response.Content); - return DeserializeInternalAssistantFileDeletionStatus(document.RootElement); + return DeserializeVectorStoreDeletionStatus(document.RootElement); } /// Convert into a . diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatus.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreDeletionStatus.cs similarity index 71% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatus.cs rename to sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreDeletionStatus.cs index 1a91eb299ceb..959f2da309e7 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/InternalAssistantFileDeletionStatus.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreDeletionStatus.cs @@ -10,8 +10,8 @@ namespace Azure.AI.OpenAI.Assistants { - /// The status of an assistant file deletion operation. - internal partial class InternalAssistantFileDeletionStatus + /// Response object for deleting a vector store. + public partial class VectorStoreDeletionStatus { /// /// Keeps track of any properties unknown to the library. @@ -45,11 +45,11 @@ internal partial class InternalAssistantFileDeletionStatus /// private IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . + /// Initializes a new instance of . /// The ID of the resource specified for deletion. /// A value indicating whether deletion was successful. /// is null. - internal InternalAssistantFileDeletionStatus(string id, bool deleted) + internal VectorStoreDeletionStatus(string id, bool deleted) { Argument.AssertNotNull(id, nameof(id)); @@ -57,12 +57,12 @@ internal InternalAssistantFileDeletionStatus(string id, bool deleted) Deleted = deleted; } - /// Initializes a new instance of . + /// Initializes a new instance of . /// The ID of the resource specified for deletion. /// A value indicating whether deletion was successful. - /// The object type, which is always 'assistant.file.deleted'. + /// The object type, which is always 'vector_store.deleted'. /// Keeps track of any properties unknown to the library. - internal InternalAssistantFileDeletionStatus(string id, bool deleted, InternalAssistantFileDeletionStatusObject @object, IDictionary serializedAdditionalRawData) + internal VectorStoreDeletionStatus(string id, bool deleted, VectorStoreDeletionStatusObject @object, IDictionary serializedAdditionalRawData) { Id = id; Deleted = deleted; @@ -70,8 +70,8 @@ internal InternalAssistantFileDeletionStatus(string id, bool deleted, InternalAs _serializedAdditionalRawData = serializedAdditionalRawData; } - /// Initializes a new instance of for deserialization. - internal InternalAssistantFileDeletionStatus() + /// Initializes a new instance of for deserialization. + internal VectorStoreDeletionStatus() { } @@ -79,7 +79,7 @@ internal InternalAssistantFileDeletionStatus() public string Id { get; } /// A value indicating whether deletion was successful. public bool Deleted { get; } - /// The object type, which is always 'assistant.file.deleted'. - public InternalAssistantFileDeletionStatusObject Object { get; } = InternalAssistantFileDeletionStatusObject.AssistantFileDeleted; + /// The object type, which is always 'vector_store.deleted'. + public VectorStoreDeletionStatusObject Object { get; } = VectorStoreDeletionStatusObject.VectorStoreDeleted; } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreDeletionStatusObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreDeletionStatusObject.cs new file mode 100644 index 000000000000..0fda56b5c6df --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreDeletionStatusObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The VectorStoreDeletionStatus_object. + public readonly partial struct VectorStoreDeletionStatusObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreDeletionStatusObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string VectorStoreDeletedValue = "vector_store.deleted"; + + /// vector_store.deleted. + public static VectorStoreDeletionStatusObject VectorStoreDeleted { get; } = new VectorStoreDeletionStatusObject(VectorStoreDeletedValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreDeletionStatusObject left, VectorStoreDeletionStatusObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreDeletionStatusObject left, VectorStoreDeletionStatusObject right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator VectorStoreDeletionStatusObject(string value) => new VectorStoreDeletionStatusObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreDeletionStatusObject other && Equals(other); + /// + public bool Equals(VectorStoreDeletionStatusObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreExpirationPolicy.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreExpirationPolicy.Serialization.cs new file mode 100644 index 000000000000..2b0f6fd8341f --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreExpirationPolicy.Serialization.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class VectorStoreExpirationPolicy : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreExpirationPolicy)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("anchor"u8); + writer.WriteStringValue(Anchor.ToString()); + writer.WritePropertyName("days"u8); + writer.WriteNumberValue(Days); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VectorStoreExpirationPolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreExpirationPolicy)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreExpirationPolicy(document.RootElement, options); + } + + internal static VectorStoreExpirationPolicy DeserializeVectorStoreExpirationPolicy(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VectorStoreExpirationPolicyAnchor anchor = default; + int days = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("anchor"u8)) + { + anchor = new VectorStoreExpirationPolicyAnchor(property.Value.GetString()); + continue; + } + if (property.NameEquals("days"u8)) + { + days = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreExpirationPolicy(anchor, days, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreExpirationPolicy)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreExpirationPolicy IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreExpirationPolicy(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreExpirationPolicy)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreExpirationPolicy FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreExpirationPolicy(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreExpirationPolicy.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreExpirationPolicy.cs new file mode 100644 index 000000000000..345d82299d9d --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreExpirationPolicy.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The expiration policy for a vector store. + public partial class VectorStoreExpirationPolicy + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`. + /// The anchor timestamp after which the expiration policy applies. + public VectorStoreExpirationPolicy(VectorStoreExpirationPolicyAnchor anchor, int days) + { + Anchor = anchor; + Days = days; + } + + /// Initializes a new instance of . + /// Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`. + /// The anchor timestamp after which the expiration policy applies. + /// Keeps track of any properties unknown to the library. + internal VectorStoreExpirationPolicy(VectorStoreExpirationPolicyAnchor anchor, int days, IDictionary serializedAdditionalRawData) + { + Anchor = anchor; + Days = days; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreExpirationPolicy() + { + } + + /// Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`. + public VectorStoreExpirationPolicyAnchor Anchor { get; set; } + /// The anchor timestamp after which the expiration policy applies. + public int Days { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreExpirationPolicyAnchor.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreExpirationPolicyAnchor.cs new file mode 100644 index 000000000000..46dfadc76c32 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreExpirationPolicyAnchor.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Describes the relationship between the days and the expiration of this vector store. + public readonly partial struct VectorStoreExpirationPolicyAnchor : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreExpirationPolicyAnchor(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string LastActiveAtValue = "last_active_at"; + + /// The expiration policy is based on the last time the vector store was active. + public static VectorStoreExpirationPolicyAnchor LastActiveAt { get; } = new VectorStoreExpirationPolicyAnchor(LastActiveAtValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreExpirationPolicyAnchor left, VectorStoreExpirationPolicyAnchor right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreExpirationPolicyAnchor left, VectorStoreExpirationPolicyAnchor right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator VectorStoreExpirationPolicyAnchor(string value) => new VectorStoreExpirationPolicyAnchor(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreExpirationPolicyAnchor other && Equals(other); + /// + public bool Equals(VectorStoreExpirationPolicyAnchor other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFile.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFile.Serialization.cs new file mode 100644 index 000000000000..c183395520a1 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFile.Serialization.cs @@ -0,0 +1,212 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class VectorStoreFile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreFile)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("usage_bytes"u8); + writer.WriteNumberValue(UsageBytes); + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + writer.WritePropertyName("vector_store_id"u8); + writer.WriteStringValue(VectorStoreId); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + if (LastError != null) + { + writer.WritePropertyName("last_error"u8); + writer.WriteObjectValue(LastError, options); + } + else + { + writer.WriteNull("last_error"); + } + writer.WritePropertyName("chunking_strategy"u8); + writer.WriteObjectValue(ChunkingStrategy, options); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VectorStoreFile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreFile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreFile(document.RootElement, options); + } + + internal static VectorStoreFile DeserializeVectorStoreFile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + VectorStoreFileObject @object = default; + int usageBytes = default; + DateTimeOffset createdAt = default; + string vectorStoreId = default; + VectorStoreFileStatus status = default; + VectorStoreFileError lastError = default; + VectorStoreChunkingStrategyResponse chunkingStrategy = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new VectorStoreFileObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("usage_bytes"u8)) + { + usageBytes = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("vector_store_id"u8)) + { + vectorStoreId = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new VectorStoreFileStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("last_error"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + lastError = null; + continue; + } + lastError = VectorStoreFileError.DeserializeVectorStoreFileError(property.Value, options); + continue; + } + if (property.NameEquals("chunking_strategy"u8)) + { + chunkingStrategy = VectorStoreChunkingStrategyResponse.DeserializeVectorStoreChunkingStrategyResponse(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreFile( + id, + @object, + usageBytes, + createdAt, + vectorStoreId, + status, + lastError, + chunkingStrategy, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreFile)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreFile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreFile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreFile FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreFile(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFile.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFile.cs new file mode 100644 index 000000000000..d7c12dbf07d8 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFile.cs @@ -0,0 +1,139 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Description of a file attached to a vector store. + public partial class VectorStoreFile + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// + /// The total vector store usage in bytes. Note that this may be different from the original file + /// size. + /// + /// The Unix timestamp (in seconds) for when the vector store file was created. + /// The ID of the vector store that the file is attached to. + /// The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use. + /// The last error associated with this vector store file. Will be `null` if there are no errors. + /// + /// The strategy used to chunk the file. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// , or is null. + internal VectorStoreFile(string id, int usageBytes, DateTimeOffset createdAt, string vectorStoreId, VectorStoreFileStatus status, VectorStoreFileError lastError, VectorStoreChunkingStrategyResponse chunkingStrategy) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(chunkingStrategy, nameof(chunkingStrategy)); + + Id = id; + UsageBytes = usageBytes; + CreatedAt = createdAt; + VectorStoreId = vectorStoreId; + Status = status; + LastError = lastError; + ChunkingStrategy = chunkingStrategy; + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always `vector_store.file`. + /// + /// The total vector store usage in bytes. Note that this may be different from the original file + /// size. + /// + /// The Unix timestamp (in seconds) for when the vector store file was created. + /// The ID of the vector store that the file is attached to. + /// The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use. + /// The last error associated with this vector store file. Will be `null` if there are no errors. + /// + /// The strategy used to chunk the file. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// Keeps track of any properties unknown to the library. + internal VectorStoreFile(string id, VectorStoreFileObject @object, int usageBytes, DateTimeOffset createdAt, string vectorStoreId, VectorStoreFileStatus status, VectorStoreFileError lastError, VectorStoreChunkingStrategyResponse chunkingStrategy, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + UsageBytes = usageBytes; + CreatedAt = createdAt; + VectorStoreId = vectorStoreId; + Status = status; + LastError = lastError; + ChunkingStrategy = chunkingStrategy; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreFile() + { + } + + /// The identifier, which can be referenced in API endpoints. + public string Id { get; } + /// The object type, which is always `vector_store.file`. + public VectorStoreFileObject Object { get; } = VectorStoreFileObject.VectorStoreFile; + + /// + /// The total vector store usage in bytes. Note that this may be different from the original file + /// size. + /// + public int UsageBytes { get; } + /// The Unix timestamp (in seconds) for when the vector store file was created. + public DateTimeOffset CreatedAt { get; } + /// The ID of the vector store that the file is attached to. + public string VectorStoreId { get; } + /// The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use. + public VectorStoreFileStatus Status { get; } + /// The last error associated with this vector store file. Will be `null` if there are no errors. + public VectorStoreFileError LastError { get; } + /// + /// The strategy used to chunk the file. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public VectorStoreChunkingStrategyResponse ChunkingStrategy { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileBatch.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileBatch.Serialization.cs new file mode 100644 index 000000000000..5b4b53d5a7b6 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileBatch.Serialization.cs @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class VectorStoreFileBatch : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreFileBatch)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + writer.WritePropertyName("created_at"u8); + writer.WriteNumberValue(CreatedAt, "U"); + writer.WritePropertyName("vector_store_id"u8); + writer.WriteStringValue(VectorStoreId); + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status.ToString()); + writer.WritePropertyName("file_counts"u8); + writer.WriteObjectValue(FileCounts, options); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VectorStoreFileBatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreFileBatch)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreFileBatch(document.RootElement, options); + } + + internal static VectorStoreFileBatch DeserializeVectorStoreFileBatch(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + VectorStoreFileBatchObject @object = default; + DateTimeOffset createdAt = default; + string vectorStoreId = default; + VectorStoreFileBatchStatus status = default; + VectorStoreFileCount fileCounts = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new VectorStoreFileBatchObject(property.Value.GetString()); + continue; + } + if (property.NameEquals("created_at"u8)) + { + createdAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64()); + continue; + } + if (property.NameEquals("vector_store_id"u8)) + { + vectorStoreId = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = new VectorStoreFileBatchStatus(property.Value.GetString()); + continue; + } + if (property.NameEquals("file_counts"u8)) + { + fileCounts = VectorStoreFileCount.DeserializeVectorStoreFileCount(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreFileBatch( + id, + @object, + createdAt, + vectorStoreId, + status, + fileCounts, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreFileBatch)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreFileBatch IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreFileBatch(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreFileBatch)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreFileBatch FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreFileBatch(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileBatch.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileBatch.cs new file mode 100644 index 000000000000..898dd2ab2b55 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileBatch.cs @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// A batch of files attached to a vector store. + public partial class VectorStoreFileBatch + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The Unix timestamp (in seconds) for when the vector store files batch was created. + /// The ID of the vector store that the file is attached to. + /// The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`. + /// Files count grouped by status processed or being processed by this vector store. + /// , or is null. + internal VectorStoreFileBatch(string id, DateTimeOffset createdAt, string vectorStoreId, VectorStoreFileBatchStatus status, VectorStoreFileCount fileCounts) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(vectorStoreId, nameof(vectorStoreId)); + Argument.AssertNotNull(fileCounts, nameof(fileCounts)); + + Id = id; + CreatedAt = createdAt; + VectorStoreId = vectorStoreId; + Status = status; + FileCounts = fileCounts; + } + + /// Initializes a new instance of . + /// The identifier, which can be referenced in API endpoints. + /// The object type, which is always `vector_store.file_batch`. + /// The Unix timestamp (in seconds) for when the vector store files batch was created. + /// The ID of the vector store that the file is attached to. + /// The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`. + /// Files count grouped by status processed or being processed by this vector store. + /// Keeps track of any properties unknown to the library. + internal VectorStoreFileBatch(string id, VectorStoreFileBatchObject @object, DateTimeOffset createdAt, string vectorStoreId, VectorStoreFileBatchStatus status, VectorStoreFileCount fileCounts, IDictionary serializedAdditionalRawData) + { + Id = id; + Object = @object; + CreatedAt = createdAt; + VectorStoreId = vectorStoreId; + Status = status; + FileCounts = fileCounts; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreFileBatch() + { + } + + /// The identifier, which can be referenced in API endpoints. + public string Id { get; } + /// The object type, which is always `vector_store.file_batch`. + public VectorStoreFileBatchObject Object { get; } = VectorStoreFileBatchObject.VectorStoreFilesBatch; + + /// The Unix timestamp (in seconds) for when the vector store files batch was created. + public DateTimeOffset CreatedAt { get; } + /// The ID of the vector store that the file is attached to. + public string VectorStoreId { get; } + /// The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`. + public VectorStoreFileBatchStatus Status { get; } + /// Files count grouped by status processed or being processed by this vector store. + public VectorStoreFileCount FileCounts { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileBatchObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileBatchObject.cs new file mode 100644 index 000000000000..b4aee05f704a --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileBatchObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The VectorStoreFileBatch_object. + public readonly partial struct VectorStoreFileBatchObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreFileBatchObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string VectorStoreFilesBatchValue = "vector_store.files_batch"; + + /// vector_store.files_batch. + public static VectorStoreFileBatchObject VectorStoreFilesBatch { get; } = new VectorStoreFileBatchObject(VectorStoreFilesBatchValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreFileBatchObject left, VectorStoreFileBatchObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreFileBatchObject left, VectorStoreFileBatchObject right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator VectorStoreFileBatchObject(string value) => new VectorStoreFileBatchObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreFileBatchObject other && Equals(other); + /// + public bool Equals(VectorStoreFileBatchObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileBatchStatus.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileBatchStatus.cs new file mode 100644 index 000000000000..e88bbe7521db --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileBatchStatus.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The status of the vector store file batch. + public readonly partial struct VectorStoreFileBatchStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreFileBatchStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InProgressValue = "in_progress"; + private const string CompletedValue = "completed"; + private const string CancelledValue = "cancelled"; + private const string FailedValue = "failed"; + + /// The vector store is still processing this file batch. + public static VectorStoreFileBatchStatus InProgress { get; } = new VectorStoreFileBatchStatus(InProgressValue); + /// the vector store file batch is ready for use. + public static VectorStoreFileBatchStatus Completed { get; } = new VectorStoreFileBatchStatus(CompletedValue); + /// The vector store file batch was cancelled. + public static VectorStoreFileBatchStatus Cancelled { get; } = new VectorStoreFileBatchStatus(CancelledValue); + /// The vector store file batch failed to process. + public static VectorStoreFileBatchStatus Failed { get; } = new VectorStoreFileBatchStatus(FailedValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreFileBatchStatus left, VectorStoreFileBatchStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreFileBatchStatus left, VectorStoreFileBatchStatus right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator VectorStoreFileBatchStatus(string value) => new VectorStoreFileBatchStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreFileBatchStatus other && Equals(other); + /// + public bool Equals(VectorStoreFileBatchStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileCount.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileCount.Serialization.cs new file mode 100644 index 000000000000..e69faa13eec3 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileCount.Serialization.cs @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class VectorStoreFileCount : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreFileCount)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("in_progress"u8); + writer.WriteNumberValue(InProgress); + writer.WritePropertyName("completed"u8); + writer.WriteNumberValue(Completed); + writer.WritePropertyName("failed"u8); + writer.WriteNumberValue(Failed); + writer.WritePropertyName("cancelled"u8); + writer.WriteNumberValue(Cancelled); + writer.WritePropertyName("total"u8); + writer.WriteNumberValue(Total); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VectorStoreFileCount IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreFileCount)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreFileCount(document.RootElement, options); + } + + internal static VectorStoreFileCount DeserializeVectorStoreFileCount(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int inProgress = default; + int completed = default; + int failed = default; + int cancelled = default; + int total = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("in_progress"u8)) + { + inProgress = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("completed"u8)) + { + completed = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("failed"u8)) + { + failed = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("cancelled"u8)) + { + cancelled = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("total"u8)) + { + total = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreFileCount( + inProgress, + completed, + failed, + cancelled, + total, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreFileCount)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreFileCount IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreFileCount(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreFileCount)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreFileCount FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreFileCount(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileCount.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileCount.cs new file mode 100644 index 000000000000..a4fe9273bff4 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileCount.cs @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Counts of files processed or being processed by this vector store grouped by status. + public partial class VectorStoreFileCount + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The number of files that are currently being processed. + /// The number of files that have been successfully processed. + /// The number of files that have failed to process. + /// The number of files that were cancelled. + /// The total number of files. + internal VectorStoreFileCount(int inProgress, int completed, int failed, int cancelled, int total) + { + InProgress = inProgress; + Completed = completed; + Failed = failed; + Cancelled = cancelled; + Total = total; + } + + /// Initializes a new instance of . + /// The number of files that are currently being processed. + /// The number of files that have been successfully processed. + /// The number of files that have failed to process. + /// The number of files that were cancelled. + /// The total number of files. + /// Keeps track of any properties unknown to the library. + internal VectorStoreFileCount(int inProgress, int completed, int failed, int cancelled, int total, IDictionary serializedAdditionalRawData) + { + InProgress = inProgress; + Completed = completed; + Failed = failed; + Cancelled = cancelled; + Total = total; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreFileCount() + { + } + + /// The number of files that are currently being processed. + public int InProgress { get; } + /// The number of files that have been successfully processed. + public int Completed { get; } + /// The number of files that have failed to process. + public int Failed { get; } + /// The number of files that were cancelled. + public int Cancelled { get; } + /// The total number of files. + public int Total { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileDeletionStatus.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileDeletionStatus.Serialization.cs new file mode 100644 index 000000000000..8ca0ff5dacf3 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileDeletionStatus.Serialization.cs @@ -0,0 +1,151 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class VectorStoreFileDeletionStatus : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreFileDeletionStatus)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("deleted"u8); + writer.WriteBooleanValue(Deleted); + writer.WritePropertyName("object"u8); + writer.WriteStringValue(Object.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VectorStoreFileDeletionStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreFileDeletionStatus)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreFileDeletionStatus(document.RootElement, options); + } + + internal static VectorStoreFileDeletionStatus DeserializeVectorStoreFileDeletionStatus(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + bool deleted = default; + VectorStoreFileDeletionStatusObject @object = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("deleted"u8)) + { + deleted = property.Value.GetBoolean(); + continue; + } + if (property.NameEquals("object"u8)) + { + @object = new VectorStoreFileDeletionStatusObject(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreFileDeletionStatus(id, deleted, @object, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreFileDeletionStatus)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreFileDeletionStatus IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreFileDeletionStatus(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreFileDeletionStatus)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreFileDeletionStatus FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreFileDeletionStatus(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileDeletionStatus.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileDeletionStatus.cs new file mode 100644 index 000000000000..009e5942a8ac --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileDeletionStatus.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Response object for deleting a vector store file relationship. + public partial class VectorStoreFileDeletionStatus + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The ID of the resource specified for deletion. + /// A value indicating whether deletion was successful. + /// is null. + internal VectorStoreFileDeletionStatus(string id, bool deleted) + { + Argument.AssertNotNull(id, nameof(id)); + + Id = id; + Deleted = deleted; + } + + /// Initializes a new instance of . + /// The ID of the resource specified for deletion. + /// A value indicating whether deletion was successful. + /// The object type, which is always 'vector_store.deleted'. + /// Keeps track of any properties unknown to the library. + internal VectorStoreFileDeletionStatus(string id, bool deleted, VectorStoreFileDeletionStatusObject @object, IDictionary serializedAdditionalRawData) + { + Id = id; + Deleted = deleted; + Object = @object; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreFileDeletionStatus() + { + } + + /// The ID of the resource specified for deletion. + public string Id { get; } + /// A value indicating whether deletion was successful. + public bool Deleted { get; } + /// The object type, which is always 'vector_store.deleted'. + public VectorStoreFileDeletionStatusObject Object { get; } = VectorStoreFileDeletionStatusObject.VectorStoreFileDeleted; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileDeletionStatusObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileDeletionStatusObject.cs new file mode 100644 index 000000000000..a3f1217aefa1 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileDeletionStatusObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The VectorStoreFileDeletionStatus_object. + public readonly partial struct VectorStoreFileDeletionStatusObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreFileDeletionStatusObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string VectorStoreFileDeletedValue = "vector_store.file.deleted"; + + /// vector_store.file.deleted. + public static VectorStoreFileDeletionStatusObject VectorStoreFileDeleted { get; } = new VectorStoreFileDeletionStatusObject(VectorStoreFileDeletedValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreFileDeletionStatusObject left, VectorStoreFileDeletionStatusObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreFileDeletionStatusObject left, VectorStoreFileDeletionStatusObject right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator VectorStoreFileDeletionStatusObject(string value) => new VectorStoreFileDeletionStatusObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreFileDeletionStatusObject other && Equals(other); + /// + public bool Equals(VectorStoreFileDeletionStatusObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileError.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileError.Serialization.cs new file mode 100644 index 000000000000..8473487e4562 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileError.Serialization.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class VectorStoreFileError : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreFileError)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("code"u8); + writer.WriteStringValue(Code.ToString()); + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VectorStoreFileError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreFileError)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreFileError(document.RootElement, options); + } + + internal static VectorStoreFileError DeserializeVectorStoreFileError(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VectorStoreFileErrorCode code = default; + string message = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("code"u8)) + { + code = new VectorStoreFileErrorCode(property.Value.GetString()); + continue; + } + if (property.NameEquals("message"u8)) + { + message = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreFileError(code, message, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreFileError)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreFileError IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreFileError(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreFileError)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreFileError FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreFileError(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileError.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileError.cs new file mode 100644 index 000000000000..5c96944e5f8e --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileError.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Details on the error that may have ocurred while processing a file for this vector store. + public partial class VectorStoreFileError + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// One of `server_error` or `rate_limit_exceeded`. + /// A human-readable description of the error. + /// is null. + internal VectorStoreFileError(VectorStoreFileErrorCode code, string message) + { + Argument.AssertNotNull(message, nameof(message)); + + Code = code; + Message = message; + } + + /// Initializes a new instance of . + /// One of `server_error` or `rate_limit_exceeded`. + /// A human-readable description of the error. + /// Keeps track of any properties unknown to the library. + internal VectorStoreFileError(VectorStoreFileErrorCode code, string message, IDictionary serializedAdditionalRawData) + { + Code = code; + Message = message; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreFileError() + { + } + + /// One of `server_error` or `rate_limit_exceeded`. + public VectorStoreFileErrorCode Code { get; } + /// A human-readable description of the error. + public string Message { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileErrorCode.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileErrorCode.cs new file mode 100644 index 000000000000..4eb9a18327cd --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileErrorCode.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Error code variants for vector store file processing. + public readonly partial struct VectorStoreFileErrorCode : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreFileErrorCode(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InternalErrorValue = "internal_error"; + private const string FileNotFoundValue = "file_not_found"; + private const string ParsingErrorValue = "parsing_error"; + private const string UnhandledMimeTypeValue = "unhandled_mime_type"; + + /// An internal error occurred. + public static VectorStoreFileErrorCode InternalError { get; } = new VectorStoreFileErrorCode(InternalErrorValue); + /// The file was not found. + public static VectorStoreFileErrorCode FileNotFound { get; } = new VectorStoreFileErrorCode(FileNotFoundValue); + /// The file could not be parsed. + public static VectorStoreFileErrorCode ParsingError { get; } = new VectorStoreFileErrorCode(ParsingErrorValue); + /// The file has an unhandled mime type. + public static VectorStoreFileErrorCode UnhandledMimeType { get; } = new VectorStoreFileErrorCode(UnhandledMimeTypeValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreFileErrorCode left, VectorStoreFileErrorCode right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreFileErrorCode left, VectorStoreFileErrorCode right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator VectorStoreFileErrorCode(string value) => new VectorStoreFileErrorCode(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreFileErrorCode other && Equals(other); + /// + public bool Equals(VectorStoreFileErrorCode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileObject.cs new file mode 100644 index 000000000000..499ff7993bb2 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The VectorStoreFile_object. + public readonly partial struct VectorStoreFileObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreFileObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string VectorStoreFileValue = "vector_store.file"; + + /// vector_store.file. + public static VectorStoreFileObject VectorStoreFile { get; } = new VectorStoreFileObject(VectorStoreFileValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreFileObject left, VectorStoreFileObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreFileObject left, VectorStoreFileObject right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator VectorStoreFileObject(string value) => new VectorStoreFileObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreFileObject other && Equals(other); + /// + public bool Equals(VectorStoreFileObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileStatus.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileStatus.cs new file mode 100644 index 000000000000..a33d2d07b28b --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileStatus.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Vector store file status. + public readonly partial struct VectorStoreFileStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreFileStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InProgressValue = "in_progress"; + private const string CompletedValue = "completed"; + private const string FailedValue = "failed"; + private const string CancelledValue = "cancelled"; + + /// The file is currently being processed. + public static VectorStoreFileStatus InProgress { get; } = new VectorStoreFileStatus(InProgressValue); + /// The file has been successfully processed. + public static VectorStoreFileStatus Completed { get; } = new VectorStoreFileStatus(CompletedValue); + /// The file has failed to process. + public static VectorStoreFileStatus Failed { get; } = new VectorStoreFileStatus(FailedValue); + /// The file was cancelled. + public static VectorStoreFileStatus Cancelled { get; } = new VectorStoreFileStatus(CancelledValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreFileStatus left, VectorStoreFileStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreFileStatus left, VectorStoreFileStatus right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator VectorStoreFileStatus(string value) => new VectorStoreFileStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreFileStatus other && Equals(other); + /// + public bool Equals(VectorStoreFileStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileStatusFilter.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileStatusFilter.cs new file mode 100644 index 000000000000..7cd77b664ee1 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreFileStatusFilter.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Query parameter filter for vector store file retrieval endpoint. + public readonly partial struct VectorStoreFileStatusFilter : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreFileStatusFilter(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string InProgressValue = "in_progress"; + private const string CompletedValue = "completed"; + private const string FailedValue = "failed"; + private const string CancelledValue = "cancelled"; + + /// Retrieve only files that are currently being processed. + public static VectorStoreFileStatusFilter InProgress { get; } = new VectorStoreFileStatusFilter(InProgressValue); + /// Retrieve only files that have been successfully processed. + public static VectorStoreFileStatusFilter Completed { get; } = new VectorStoreFileStatusFilter(CompletedValue); + /// Retrieve only files that have failed to process. + public static VectorStoreFileStatusFilter Failed { get; } = new VectorStoreFileStatusFilter(FailedValue); + /// Retrieve only files that were cancelled. + public static VectorStoreFileStatusFilter Cancelled { get; } = new VectorStoreFileStatusFilter(CancelledValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreFileStatusFilter left, VectorStoreFileStatusFilter right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreFileStatusFilter left, VectorStoreFileStatusFilter right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator VectorStoreFileStatusFilter(string value) => new VectorStoreFileStatusFilter(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreFileStatusFilter other && Equals(other); + /// + public bool Equals(VectorStoreFileStatusFilter other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreObject.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreObject.cs new file mode 100644 index 000000000000..cb3b6e814908 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreObject.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// The VectorStore_object. + public readonly partial struct VectorStoreObject : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreObject(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string VectorStoreValue = "vector_store"; + + /// vector_store. + public static VectorStoreObject VectorStore { get; } = new VectorStoreObject(VectorStoreValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreObject left, VectorStoreObject right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreObject left, VectorStoreObject right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator VectorStoreObject(string value) => new VectorStoreObject(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreObject other && Equals(other); + /// + public bool Equals(VectorStoreObject other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreOptions.Serialization.cs new file mode 100644 index 000000000000..1d15eb029bc1 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreOptions.Serialization.cs @@ -0,0 +1,232 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class VectorStoreOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreOptions)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(FileIds)) + { + writer.WritePropertyName("file_ids"u8); + writer.WriteStartArray(); + foreach (var item in FileIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(ExpiresAfter)) + { + writer.WritePropertyName("expires_after"u8); + writer.WriteObjectValue(ExpiresAfter, options); + } + if (Optional.IsDefined(ChunkingStrategy)) + { + writer.WritePropertyName("chunking_strategy"u8); + writer.WriteObjectValue(ChunkingStrategy, options); + } + if (Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VectorStoreOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreOptions(document.RootElement, options); + } + + internal static VectorStoreOptions DeserializeVectorStoreOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList fileIds = default; + string name = default; + VectorStoreExpirationPolicy expiresAfter = default; + VectorStoreChunkingStrategyRequest chunkingStrategy = default; + IDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("file_ids"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + fileIds = array; + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("expires_after"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + expiresAfter = VectorStoreExpirationPolicy.DeserializeVectorStoreExpirationPolicy(property.Value, options); + continue; + } + if (property.NameEquals("chunking_strategy"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + chunkingStrategy = VectorStoreChunkingStrategyRequest.DeserializeVectorStoreChunkingStrategyRequest(property.Value, options); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreOptions( + fileIds ?? new ChangeTrackingList(), + name, + expiresAfter, + chunkingStrategy, + metadata ?? new ChangeTrackingDictionary(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreOptions)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreOptions(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreOptions.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreOptions.cs new file mode 100644 index 000000000000..2aa8bd2f3858 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreOptions.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Request object for creating a vector store. + public partial class VectorStoreOptions + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public VectorStoreOptions() + { + FileIds = new ChangeTrackingList(); + Metadata = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// A list of file IDs that the vector store should use. Useful for tools like `file_search` that can access files. + /// The name of the vector store. + /// Details on when this vector store expires. + /// + /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. Only applicable if file_ids is non-empty. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + /// Keeps track of any properties unknown to the library. + internal VectorStoreOptions(IList fileIds, string name, VectorStoreExpirationPolicy expiresAfter, VectorStoreChunkingStrategyRequest chunkingStrategy, IDictionary metadata, IDictionary serializedAdditionalRawData) + { + FileIds = fileIds; + Name = name; + ExpiresAfter = expiresAfter; + ChunkingStrategy = chunkingStrategy; + Metadata = metadata; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// A list of file IDs that the vector store should use. Useful for tools like `file_search` that can access files. + public IList FileIds { get; } + /// The name of the vector store. + public string Name { get; set; } + /// Details on when this vector store expires. + public VectorStoreExpirationPolicy ExpiresAfter { get; set; } + /// + /// The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. Only applicable if file_ids is non-empty. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public VectorStoreChunkingStrategyRequest ChunkingStrategy { get; set; } + /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. + public IDictionary Metadata { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyOptions.Serialization.cs new file mode 100644 index 000000000000..0b18f5655b55 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyOptions.Serialization.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class VectorStoreStaticChunkingStrategyOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyOptions)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("max_chunk_size_tokens"u8); + writer.WriteNumberValue(MaxChunkSizeTokens); + writer.WritePropertyName("chunk_overlap_tokens"u8); + writer.WriteNumberValue(ChunkOverlapTokens); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VectorStoreStaticChunkingStrategyOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreStaticChunkingStrategyOptions(document.RootElement, options); + } + + internal static VectorStoreStaticChunkingStrategyOptions DeserializeVectorStoreStaticChunkingStrategyOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + int maxChunkSizeTokens = default; + int chunkOverlapTokens = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("max_chunk_size_tokens"u8)) + { + maxChunkSizeTokens = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("chunk_overlap_tokens"u8)) + { + chunkOverlapTokens = property.Value.GetInt32(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreStaticChunkingStrategyOptions(maxChunkSizeTokens, chunkOverlapTokens, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyOptions)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreStaticChunkingStrategyOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreStaticChunkingStrategyOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreStaticChunkingStrategyOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreStaticChunkingStrategyOptions(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyOptions.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyOptions.cs new file mode 100644 index 000000000000..38db6670abf3 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyOptions.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Options to configure a vector store static chunking strategy. + public partial class VectorStoreStaticChunkingStrategyOptions + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The maximum number of tokens in each chunk. The default value is 800. The minimum value is 100 and the maximum value is 4096. + /// + /// The number of tokens that overlap between chunks. The default value is 400. + /// Note that the overlap must not exceed half of max_chunk_size_tokens. * + /// + public VectorStoreStaticChunkingStrategyOptions(int maxChunkSizeTokens, int chunkOverlapTokens) + { + MaxChunkSizeTokens = maxChunkSizeTokens; + ChunkOverlapTokens = chunkOverlapTokens; + } + + /// Initializes a new instance of . + /// The maximum number of tokens in each chunk. The default value is 800. The minimum value is 100 and the maximum value is 4096. + /// + /// The number of tokens that overlap between chunks. The default value is 400. + /// Note that the overlap must not exceed half of max_chunk_size_tokens. * + /// + /// Keeps track of any properties unknown to the library. + internal VectorStoreStaticChunkingStrategyOptions(int maxChunkSizeTokens, int chunkOverlapTokens, IDictionary serializedAdditionalRawData) + { + MaxChunkSizeTokens = maxChunkSizeTokens; + ChunkOverlapTokens = chunkOverlapTokens; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreStaticChunkingStrategyOptions() + { + } + + /// The maximum number of tokens in each chunk. The default value is 800. The minimum value is 100 and the maximum value is 4096. + public int MaxChunkSizeTokens { get; set; } + /// + /// The number of tokens that overlap between chunks. The default value is 400. + /// Note that the overlap must not exceed half of max_chunk_size_tokens. * + /// + public int ChunkOverlapTokens { get; set; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyRequest.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyRequest.Serialization.cs new file mode 100644 index 000000000000..2d5098c57c0c --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyRequest.Serialization.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class VectorStoreStaticChunkingStrategyRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyRequest)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("static"u8); + writer.WriteObjectValue(Static, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VectorStoreStaticChunkingStrategyRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreStaticChunkingStrategyRequest(document.RootElement, options); + } + + internal static VectorStoreStaticChunkingStrategyRequest DeserializeVectorStoreStaticChunkingStrategyRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VectorStoreStaticChunkingStrategyOptions @static = default; + VectorStoreChunkingStrategyRequestType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("static"u8)) + { + @static = VectorStoreStaticChunkingStrategyOptions.DeserializeVectorStoreStaticChunkingStrategyOptions(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new VectorStoreChunkingStrategyRequestType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreStaticChunkingStrategyRequest(type, serializedAdditionalRawData, @static); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyRequest)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreStaticChunkingStrategyRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreStaticChunkingStrategyRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new VectorStoreStaticChunkingStrategyRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreStaticChunkingStrategyRequest(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyRequest.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyRequest.cs new file mode 100644 index 000000000000..0a65da2962bd --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyRequest.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// A statically configured chunking strategy. + public partial class VectorStoreStaticChunkingStrategyRequest : VectorStoreChunkingStrategyRequest + { + /// Initializes a new instance of . + /// The options for the static chunking strategy. + /// is null. + public VectorStoreStaticChunkingStrategyRequest(VectorStoreStaticChunkingStrategyOptions @static) + { + Argument.AssertNotNull(@static, nameof(@static)); + + Type = VectorStoreChunkingStrategyRequestType.Static; + Static = @static; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// The options for the static chunking strategy. + internal VectorStoreStaticChunkingStrategyRequest(VectorStoreChunkingStrategyRequestType type, IDictionary serializedAdditionalRawData, VectorStoreStaticChunkingStrategyOptions @static) : base(type, serializedAdditionalRawData) + { + Static = @static; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreStaticChunkingStrategyRequest() + { + } + + /// The options for the static chunking strategy. + public VectorStoreStaticChunkingStrategyOptions Static { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyResponse.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyResponse.Serialization.cs new file mode 100644 index 000000000000..d478d4b4f14f --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyResponse.Serialization.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class VectorStoreStaticChunkingStrategyResponse : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyResponse)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + writer.WritePropertyName("static"u8); + writer.WriteObjectValue(Static, options); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VectorStoreStaticChunkingStrategyResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyResponse)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreStaticChunkingStrategyResponse(document.RootElement, options); + } + + internal static VectorStoreStaticChunkingStrategyResponse DeserializeVectorStoreStaticChunkingStrategyResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + VectorStoreStaticChunkingStrategyOptions @static = default; + VectorStoreChunkingStrategyResponseType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("static"u8)) + { + @static = VectorStoreStaticChunkingStrategyOptions.DeserializeVectorStoreStaticChunkingStrategyOptions(property.Value, options); + continue; + } + if (property.NameEquals("type"u8)) + { + type = new VectorStoreChunkingStrategyResponseType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreStaticChunkingStrategyResponse(type, serializedAdditionalRawData, @static); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyResponse)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreStaticChunkingStrategyResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreStaticChunkingStrategyResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreStaticChunkingStrategyResponse)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new VectorStoreStaticChunkingStrategyResponse FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreStaticChunkingStrategyResponse(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyResponse.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyResponse.cs new file mode 100644 index 000000000000..5d2a0200bdcd --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStaticChunkingStrategyResponse.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AI.OpenAI.Assistants +{ + /// A statically configured chunking strategy. + public partial class VectorStoreStaticChunkingStrategyResponse : VectorStoreChunkingStrategyResponse + { + /// Initializes a new instance of . + /// The options for the static chunking strategy. + /// is null. + internal VectorStoreStaticChunkingStrategyResponse(VectorStoreStaticChunkingStrategyOptions @static) + { + Argument.AssertNotNull(@static, nameof(@static)); + + Type = VectorStoreChunkingStrategyResponseType.Static; + Static = @static; + } + + /// Initializes a new instance of . + /// The object type. + /// Keeps track of any properties unknown to the library. + /// The options for the static chunking strategy. + internal VectorStoreStaticChunkingStrategyResponse(VectorStoreChunkingStrategyResponseType type, IDictionary serializedAdditionalRawData, VectorStoreStaticChunkingStrategyOptions @static) : base(type, serializedAdditionalRawData) + { + Static = @static; + } + + /// Initializes a new instance of for deserialization. + internal VectorStoreStaticChunkingStrategyResponse() + { + } + + /// The options for the static chunking strategy. + public VectorStoreStaticChunkingStrategyOptions Static { get; } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStatus.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStatus.cs new file mode 100644 index 000000000000..d3d85c6002cb --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreStatus.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AI.OpenAI.Assistants +{ + /// Vector store possible status. + public readonly partial struct VectorStoreStatus : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public VectorStoreStatus(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ExpiredValue = "expired"; + private const string InProgressValue = "in_progress"; + private const string CompletedValue = "completed"; + + /// expired status indicates that this vector store has expired and is no longer available for use. + public static VectorStoreStatus Expired { get; } = new VectorStoreStatus(ExpiredValue); + /// in_progress status indicates that this vector store is still processing files. + public static VectorStoreStatus InProgress { get; } = new VectorStoreStatus(InProgressValue); + /// completed status indicates that this vector store is ready for use. + public static VectorStoreStatus Completed { get; } = new VectorStoreStatus(CompletedValue); + /// Determines if two values are the same. + public static bool operator ==(VectorStoreStatus left, VectorStoreStatus right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(VectorStoreStatus left, VectorStoreStatus right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator VectorStoreStatus(string value) => new VectorStoreStatus(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is VectorStoreStatus other && Equals(other); + /// + public bool Equals(VectorStoreStatus other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreUpdateOptions.Serialization.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreUpdateOptions.Serialization.cs new file mode 100644 index 000000000000..1719c5abd919 --- /dev/null +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreUpdateOptions.Serialization.cs @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AI.OpenAI.Assistants +{ + public partial class VectorStoreUpdateOptions : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreUpdateOptions)} does not support writing '{format}' format."); + } + + writer.WriteStartObject(); + if (Optional.IsDefined(Name)) + { + if (Name != null) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + else + { + writer.WriteNull("name"); + } + } + if (Optional.IsDefined(ExpiresAfter)) + { + if (ExpiresAfter != null) + { + writer.WritePropertyName("expires_after"u8); + writer.WriteObjectValue(ExpiresAfter, options); + } + else + { + writer.WriteNull("expires_after"); + } + } + if (Optional.IsCollectionDefined(Metadata)) + { + if (Metadata != null) + { + writer.WritePropertyName("metadata"u8); + writer.WriteStartObject(); + foreach (var item in Metadata) + { + writer.WritePropertyName(item.Key); + writer.WriteStringValue(item.Value); + } + writer.WriteEndObject(); + } + else + { + writer.WriteNull("metadata"); + } + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + writer.WriteEndObject(); + } + + VectorStoreUpdateOptions IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(VectorStoreUpdateOptions)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeVectorStoreUpdateOptions(document.RootElement, options); + } + + internal static VectorStoreUpdateOptions DeserializeVectorStoreUpdateOptions(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string name = default; + VectorStoreExpirationPolicy expiresAfter = default; + IDictionary metadata = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + name = null; + continue; + } + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("expires_after"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + expiresAfter = null; + continue; + } + expiresAfter = VectorStoreExpirationPolicy.DeserializeVectorStoreExpirationPolicy(property.Value, options); + continue; + } + if (property.NameEquals("metadata"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, property0.Value.GetString()); + } + metadata = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new VectorStoreUpdateOptions(name, expiresAfter, metadata ?? new ChangeTrackingDictionary(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(VectorStoreUpdateOptions)} does not support writing '{options.Format}' format."); + } + } + + VectorStoreUpdateOptions IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data); + return DeserializeVectorStoreUpdateOptions(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(VectorStoreUpdateOptions)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static VectorStoreUpdateOptions FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content); + return DeserializeVectorStoreUpdateOptions(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateThreadRequest.cs b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreUpdateOptions.cs similarity index 69% rename from sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateThreadRequest.cs rename to sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreUpdateOptions.cs index 46ab2f35dbcb..e3bcef35dc48 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/UpdateThreadRequest.cs +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/src/Generated/VectorStoreUpdateOptions.cs @@ -10,8 +10,8 @@ namespace Azure.AI.OpenAI.Assistants { - /// The UpdateThreadRequest. - internal partial class UpdateThreadRequest + /// Request object for updating a vector store. + public partial class VectorStoreUpdateOptions { /// /// Keeps track of any properties unknown to the library. @@ -45,22 +45,30 @@ internal partial class UpdateThreadRequest /// private IDictionary _serializedAdditionalRawData; - /// Initializes a new instance of . - internal UpdateThreadRequest() + /// Initializes a new instance of . + public VectorStoreUpdateOptions() { Metadata = new ChangeTrackingDictionary(); } - /// Initializes a new instance of . + /// Initializes a new instance of . + /// The name of the vector store. + /// Details on when this vector store expires. /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. /// Keeps track of any properties unknown to the library. - internal UpdateThreadRequest(IReadOnlyDictionary metadata, IDictionary serializedAdditionalRawData) + internal VectorStoreUpdateOptions(string name, VectorStoreExpirationPolicy expiresAfter, IDictionary metadata, IDictionary serializedAdditionalRawData) { + Name = name; + ExpiresAfter = expiresAfter; Metadata = metadata; _serializedAdditionalRawData = serializedAdditionalRawData; } + /// The name of the vector store. + public string Name { get; set; } + /// Details on when this vector store expires. + public VectorStoreExpirationPolicy ExpiresAfter { get; set; } /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. - public IReadOnlyDictionary Metadata { get; } + public IDictionary Metadata { get; set; } } } diff --git a/sdk/openai/Azure.AI.OpenAI.Assistants/tsp-location.yaml b/sdk/openai/Azure.AI.OpenAI.Assistants/tsp-location.yaml index 58f812caec89..872ebcab6ba9 100644 --- a/sdk/openai/Azure.AI.OpenAI.Assistants/tsp-location.yaml +++ b/sdk/openai/Azure.AI.OpenAI.Assistants/tsp-location.yaml @@ -1,3 +1,4 @@ directory: specification/ai/OpenAI.Assistants -commit: 4fef3a8d819f8fc8eef6a3b68320f710e666b72a -repo: Azure/azure-rest-api-specs +commit: abdd04c316cd2e71dc4819b4e78eaceb50bae76c +repo: test-repo-billy/azure-rest-api-specs +additionalDirectories: