diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 90d43a69c..a19d358bd 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "6.85.0" + ".": "6.86.0" } diff --git a/.stats.yml b/.stats.yml index 707fc41ea..84e5d6572 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 1222 +configured_endpoints: 1233 diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c367df81..69c4dec6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [6.86.0](https://github.com/team-telnyx/telnyx-java/compare/v6.85.0...v6.86.0) (2026-08-14) + + +### Features + +* promote from staging 4b164ce ([63147f6](https://github.com/team-telnyx/telnyx-java/commit/63147f69840b04f8e5d5901efce4f3f460275142)) + ## [6.85.0](https://github.com/team-telnyx/telnyx-java/compare/v6.84.0...v6.85.0) (2026-08-11) diff --git a/README.md b/README.md index 0b9afbf00..38511b5fb 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.telnyx.sdk/telnyx)](https://central.sonatype.com/artifact/com.telnyx.sdk/telnyx/6.85.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.telnyx.sdk/telnyx)](https://central.sonatype.com/artifact/com.telnyx.sdk/telnyx/6.86.0) @@ -17,7 +17,7 @@ It is generated with [Stainless](https://www.stainless.com/). ### Gradle ```kotlin -implementation("com.telnyx.sdk:telnyx:6.85.0") +implementation("com.telnyx.sdk:telnyx:6.86.0") ``` ### Maven @@ -26,7 +26,7 @@ implementation("com.telnyx.sdk:telnyx:6.85.0") com.telnyx.sdk telnyx - 6.85.0 + 6.86.0 ``` diff --git a/api.md b/api.md new file mode 100644 index 000000000..00fb506ef --- /dev/null +++ b/api.md @@ -0,0 +1,3074 @@ +# Legacy + +## Reporting + +### BatchDetailRecords + +#### Messaging + +Methods: + +- client.legacy().reporting().batchDetailRecords().messaging().create(params) +- client.legacy().reporting().batchDetailRecords().messaging().retrieve(params) +- client.legacy().reporting().batchDetailRecords().messaging().list() +- client.legacy().reporting().batchDetailRecords().messaging().delete(params) + +#### SpeechToText + +Methods: + +- client.legacy().reporting().batchDetailRecords().speechToText().create(params) +- client.legacy().reporting().batchDetailRecords().speechToText().retrieve(params) +- client.legacy().reporting().batchDetailRecords().speechToText().list() +- client.legacy().reporting().batchDetailRecords().speechToText().delete(params) + +#### Voice + +Methods: + +- client.legacy().reporting().batchDetailRecords().voice().create(params) +- client.legacy().reporting().batchDetailRecords().voice().retrieve(params) +- client.legacy().reporting().batchDetailRecords().voice().list() +- client.legacy().reporting().batchDetailRecords().voice().delete(params) +- client.legacy().reporting().batchDetailRecords().voice().retrieveFields() + +### UsageReports + +Methods: + +- client.legacy().reporting().usageReports().retrieveSpeechToText(params) + +#### Messaging + +Methods: + +- client.legacy().reporting().usageReports().messaging().create(params) +- client.legacy().reporting().usageReports().messaging().retrieve(params) +- client.legacy().reporting().usageReports().messaging().list(params) +- client.legacy().reporting().usageReports().messaging().delete(params) + +#### NumberLookup + +Methods: + +- client.legacy().reporting().usageReports().numberLookup().create(params) +- client.legacy().reporting().usageReports().numberLookup().retrieve(params) +- client.legacy().reporting().usageReports().numberLookup().list(params) +- client.legacy().reporting().usageReports().numberLookup().delete(params) + +#### Voice + +Methods: + +- client.legacy().reporting().usageReports().voice().create(params) +- client.legacy().reporting().usageReports().voice().retrieve(params) +- client.legacy().reporting().usageReports().voice().list(params) +- client.legacy().reporting().usageReports().voice().delete(params) + +# OAuth + +Methods: + +- client.oauth().retrieve(params) +- client.oauth().grants(params) +- client.oauth().introspect(params) +- client.oauth().register(params) +- client.oauth().retrieveAuthorize(params) +- client.oauth().retrieveJwks() +- client.oauth().token(params) + +# OAuthClients + +Methods: + +- client.oauthClients().create(params) +- client.oauthClients().retrieve(params) +- client.oauthClients().update(params) +- client.oauthClients().list(params) +- client.oauthClients().delete(params) + +# OAuthGrants + +Methods: + +- client.oauthGrants().retrieve(params) +- client.oauthGrants().list(params) +- client.oauthGrants().delete(params) + +# AccessIpAddress + +Methods: + +- client.accessIpAddress().create(params) +- client.accessIpAddress().retrieve(params) +- client.accessIpAddress().list(params) +- client.accessIpAddress().delete(params) + +# AccessIpRanges + +Methods: + +- client.accessIpRanges().create(params) +- client.accessIpRanges().list(params) +- client.accessIpRanges().delete(params) + +# Actions + +## Purchase + +Methods: + +- client.actions().purchase().create(params) + +## Register + +Methods: + +- client.actions().register().create(params) + +# Addresses + +Methods: + +- client.addresses().create(params) +- client.addresses().retrieve(params) +- client.addresses().list(params) +- client.addresses().delete(params) + +## Actions + +Methods: + +- client.addresses().actions().acceptSuggestions(params) +- client.addresses().actions().validate(params) + +# AdvancedOrders + +Methods: + +- client.advancedOrders().create(params) +- client.advancedOrders().retrieve(params) +- client.advancedOrders().list() +- client.advancedOrders().updateRequirementGroup(params) + +# Ai + +Methods: + +- client.ai().retrieveConversationHistories(params) +- client.ai().summarize(params) + +## Assistants + +Methods: + +- client.ai().assistants().create(params) +- client.ai().assistants().retrieve(params) +- client.ai().assistants().update(params) +- client.ai().assistants().list() +- client.ai().assistants().delete(params) +- client.ai().assistants().chat(params) +- client.ai().assistants().clone(params) +- client.ai().assistants().getTexml(params) +- client.ai().assistants().imports(params) +- client.ai().assistants().sendSms(params) + +### Tests + +Methods: + +- client.ai().assistants().tests().create(params) +- client.ai().assistants().tests().retrieve(params) +- client.ai().assistants().tests().update(params) +- client.ai().assistants().tests().list(params) +- client.ai().assistants().tests().delete(params) + +#### TestSuites + +Methods: + +- client.ai().assistants().tests().testSuites().list() + +##### Runs + +Methods: + +- client.ai().assistants().tests().testSuites().runs().list(params) +- client.ai().assistants().tests().testSuites().runs().trigger(params) + +#### Runs + +Methods: + +- client.ai().assistants().tests().runs().retrieve(params) +- client.ai().assistants().tests().runs().list(params) +- client.ai().assistants().tests().runs().trigger(params) + +### CanaryDeploys + +Methods: + +- client.ai().assistants().canaryDeploys().create(params) +- client.ai().assistants().canaryDeploys().retrieve(params) +- client.ai().assistants().canaryDeploys().update(params) +- client.ai().assistants().canaryDeploys().delete(params) + +### ScheduledEvents + +Methods: + +- client.ai().assistants().scheduledEvents().create(params) +- client.ai().assistants().scheduledEvents().retrieve(params) +- client.ai().assistants().scheduledEvents().list(params) +- client.ai().assistants().scheduledEvents().delete(params) + +### Tools + +Methods: + +- client.ai().assistants().tools().add(params) +- client.ai().assistants().tools().remove(params) +- client.ai().assistants().tools().test(params) + +### Versions + +Methods: + +- client.ai().assistants().versions().retrieve(params) +- client.ai().assistants().versions().update(params) +- client.ai().assistants().versions().list(params) +- client.ai().assistants().versions().delete(params) +- client.ai().assistants().versions().promote(params) + +### Tags + +Methods: + +- client.ai().assistants().tags().list() +- client.ai().assistants().tags().add(params) +- client.ai().assistants().tags().remove(params) + +### Instructions + +Methods: + +- client.ai().assistants().instructions().enhance(params) + +## Audio + +Methods: + +- client.ai().audio().transcribe(params) + +## Clusters + +Methods: + +- client.ai().clusters().retrieve(params) +- client.ai().clusters().list(params) +- client.ai().clusters().delete(params) +- client.ai().clusters().compute(params) +- client.ai().clusters().fetchGraph(params) + +## Collections + +Methods: + +- client.ai().collections().create(params) +- client.ai().collections().retrieve(params) +- client.ai().collections().update(params) +- client.ai().collections().list(params) +- client.ai().collections().delete(params) +- client.ai().collections().retrieveById(params) +- client.ai().collections().retrieveDocuments(params) + +### Settings + +Methods: + +- client.ai().collections().settings().create(params) +- client.ai().collections().settings().list(params) +- client.ai().collections().settings().patchAll(params) + +### Sources + +Methods: + +- client.ai().collections().sources().create(params) +- client.ai().collections().sources().list(params) +- client.ai().collections().sources().delete(params) +- client.ai().collections().sources().replace(params) + +## Conversations + +Methods: + +- client.ai().conversations().create(params) +- client.ai().conversations().retrieve(params) +- client.ai().conversations().update(params) +- client.ai().conversations().list(params) +- client.ai().conversations().delete(params) +- client.ai().conversations().addMessage(params) +- client.ai().conversations().retrieveConversationsInsights(params) + +### InsightGroups + +Methods: + +- client.ai().conversations().insightGroups().retrieve(params) +- client.ai().conversations().insightGroups().update(params) +- client.ai().conversations().insightGroups().delete(params) +- client.ai().conversations().insightGroups().insightGroups(params) +- client.ai().conversations().insightGroups().retrieveInsightGroups(params) + +#### Insights + +Methods: + +- client.ai().conversations().insightGroups().insights().assign(params) +- client.ai().conversations().insightGroups().insights().deleteUnassign(params) + +### Insights + +Methods: + +- client.ai().conversations().insights().create(params) +- client.ai().conversations().insights().retrieve(params) +- client.ai().conversations().insights().update(params) +- client.ai().conversations().insights().list(params) +- client.ai().conversations().insights().delete(params) + +### Messages + +Methods: + +- client.ai().conversations().messages().list(params) + +### ConversationInsights + +Methods: + +- client.ai().conversations().conversationInsights().retrieveAggregates(params) + +## Embeddings + +Methods: + +- client.ai().embeddings().create(params) +- client.ai().embeddings().retrieve(params) +- client.ai().embeddings().list(params) +- client.ai().embeddings().similaritySearch(params) +- client.ai().embeddings().url(params) + +### Buckets + +Methods: + +- client.ai().embeddings().buckets().retrieve(params) +- client.ai().embeddings().buckets().list() +- client.ai().embeddings().buckets().delete(params) + +## FineTuning + +### Jobs + +Methods: + +- client.ai().fineTuning().jobs().create(params) +- client.ai().fineTuning().jobs().retrieve(params) +- client.ai().fineTuning().jobs().list() +- client.ai().fineTuning().jobs().cancel(params) + +## Integrations + +Methods: + +- client.ai().integrations().retrieve(params) +- client.ai().integrations().list() + +### Connections + +Methods: + +- client.ai().integrations().connections().retrieve(params) +- client.ai().integrations().connections().list() +- client.ai().integrations().connections().delete(params) + +## McpServers + +Methods: + +- client.ai().mcpServers().create(params) +- client.ai().mcpServers().retrieve(params) +- client.ai().mcpServers().update(params) +- client.ai().mcpServers().list(params) +- client.ai().mcpServers().delete(params) + +## Missions + +Methods: + +- client.ai().missions().create(params) +- client.ai().missions().retrieve(params) +- client.ai().missions().list(params) +- client.ai().missions().cloneMission(params) +- client.ai().missions().deleteMission(params) +- client.ai().missions().listEvents(params) +- client.ai().missions().updateMission(params) + +### Runs + +Methods: + +- client.ai().missions().runs().create(params) +- client.ai().missions().runs().retrieve(params) +- client.ai().missions().runs().update(params) +- client.ai().missions().runs().list(params) +- client.ai().missions().runs().cancelRun(params) +- client.ai().missions().runs().listRuns(params) +- client.ai().missions().runs().pauseRun(params) +- client.ai().missions().runs().resumeRun(params) + +#### Events + +Methods: + +- client.ai().missions().runs().events().list(params) +- client.ai().missions().runs().events().getEventDetails(params) +- client.ai().missions().runs().events().log(params) + +#### Plan + +Methods: + +- client.ai().missions().runs().plan().create(params) +- client.ai().missions().runs().plan().retrieve(params) +- client.ai().missions().runs().plan().addStepsToPlan(params) +- client.ai().missions().runs().plan().getStepDetails(params) +- client.ai().missions().runs().plan().updateStep(params) + +#### TelnyxAgents + +Methods: + +- client.ai().missions().runs().telnyxAgents().list(params) +- client.ai().missions().runs().telnyxAgents().link(params) +- client.ai().missions().runs().telnyxAgents().unlink(params) + +### KnowledgeBases + +Methods: + +- client.ai().missions().knowledgeBases().createKnowledgeBase(params) +- client.ai().missions().knowledgeBases().deleteKnowledgeBase(params) +- client.ai().missions().knowledgeBases().getKnowledgeBase(params) +- client.ai().missions().knowledgeBases().listKnowledgeBases(params) +- client.ai().missions().knowledgeBases().updateKnowledgeBase(params) + +### McpServers + +Methods: + +- client.ai().missions().mcpServers().createMcpServer(params) +- client.ai().missions().mcpServers().deleteMcpServer(params) +- client.ai().missions().mcpServers().getMcpServer(params) +- client.ai().missions().mcpServers().listMcpServers(params) +- client.ai().missions().mcpServers().updateMcpServer(params) + +### Tools + +Methods: + +- client.ai().missions().tools().createTool(params) +- client.ai().missions().tools().deleteTool(params) +- client.ai().missions().tools().getTool(params) +- client.ai().missions().tools().listTools(params) +- client.ai().missions().tools().updateTool(params) + +## OpenAI + +Methods: + +- client.ai().openai().createResponse(params) +- client.ai().openai().listModels() + +### Embeddings + +Methods: + +- client.ai().openai().embeddings().createEmbeddings(params) +- client.ai().openai().embeddings().listEmbeddingModels() + +### Chat + +Methods: + +- client.ai().openai().chat().createCompletion(params) + +## Tools + +Methods: + +- client.ai().tools().create(params) +- client.ai().tools().retrieve(params) +- client.ai().tools().update(params) +- client.ai().tools().list(params) +- client.ai().tools().delete(params) + +## Anthropic + +### V1 + +Methods: + +- client.ai().anthropic().v1().messages(params) + +# AuditEvents + +Methods: + +- client.auditEvents().list(params) + +# AuthenticationProviders + +Methods: + +- client.authenticationProviders().create(params) +- client.authenticationProviders().retrieve(params) +- client.authenticationProviders().update(params) +- client.authenticationProviders().list(params) +- client.authenticationProviders().delete(params) + +# AvailablePhoneNumberBlocks + +Methods: + +- client.availablePhoneNumberBlocks().list(params) + +# AvailablePhoneNumbers + +Methods: + +- client.availablePhoneNumbers().list(params) + +# Balance + +Methods: + +- client.balance().retrieve() + +# BillingGroups + +Methods: + +- client.billingGroups().create(params) +- client.billingGroups().retrieve(params) +- client.billingGroups().update(params) +- client.billingGroups().list(params) +- client.billingGroups().delete(params) + +# BulkSimCardActions + +Methods: + +- client.bulkSimCardActions().retrieve(params) +- client.bulkSimCardActions().list(params) + +# BundlePricing + +## BillingBundles + +Methods: + +- client.bundlePricing().billingBundles().retrieve(params) +- client.bundlePricing().billingBundles().list(params) + +## UserBundles + +Methods: + +- client.bundlePricing().userBundles().create(params) +- client.bundlePricing().userBundles().retrieve(params) +- client.bundlePricing().userBundles().list(params) +- client.bundlePricing().userBundles().deactivate(params) +- client.bundlePricing().userBundles().listResources(params) +- client.bundlePricing().userBundles().listUnused(params) + +# CallControlApplications + +Methods: + +- client.callControlApplications().create(params) +- client.callControlApplications().retrieve(params) +- client.callControlApplications().update(params) +- client.callControlApplications().list(params) +- client.callControlApplications().delete(params) + +# CallEvents + +Methods: + +- client.callEvents().list(params) + +# Calls + +Methods: + +- client.calls().dial(params) +- client.calls().retrieveStatus(params) + +## Actions + +Methods: + +- client.calls().actions().addAiAssistantMessages(params) +- client.calls().actions().answer(params) +- client.calls().actions().bridge(params) +- client.calls().actions().enqueue(params) +- client.calls().actions().gather(params) +- client.calls().actions().gatherUsingAi(params) +- client.calls().actions().gatherUsingAudio(params) +- client.calls().actions().gatherUsingSpeak(params) +- client.calls().actions().hangup(params) +- client.calls().actions().joinAiAssistant(params) +- client.calls().actions().leaveQueue(params) +- client.calls().actions().pauseRecording(params) +- client.calls().actions().pay(params) +- client.calls().actions().refer(params) +- client.calls().actions().reject(params) +- client.calls().actions().resumeRecording(params) +- client.calls().actions().sendDtmf(params) +- client.calls().actions().sendSipInfo(params) +- client.calls().actions().speak(params) +- client.calls().actions().startAiAssistant(params) +- client.calls().actions().startConversationRelay(params) +- client.calls().actions().startForking(params) +- client.calls().actions().startNoiseSuppression(params) +- client.calls().actions().startPlayback(params) +- client.calls().actions().startRecording(params) +- client.calls().actions().startSiprec(params) +- client.calls().actions().startStreaming(params) +- client.calls().actions().startTranscription(params) +- client.calls().actions().stopAiAssistant(params) +- client.calls().actions().stopConversationRelay(params) +- client.calls().actions().stopForking(params) +- client.calls().actions().stopGather(params) +- client.calls().actions().stopNoiseSuppression(params) +- client.calls().actions().stopPlayback(params) +- client.calls().actions().stopRecording(params) +- client.calls().actions().stopSiprec(params) +- client.calls().actions().stopStreaming(params) +- client.calls().actions().stopTranscription(params) +- client.calls().actions().switchSupervisorRole(params) +- client.calls().actions().transfer(params) +- client.calls().actions().updateClientState(params) + +# ChannelZones + +Methods: + +- client.channelZones().update(params) +- client.channelZones().list(params) + +# ChargesBreakdown + +Methods: + +- client.chargesBreakdown().retrieve(params) + +# ChargesSummary + +Methods: + +- client.chargesSummary().retrieve(params) + +# Comments + +Methods: + +- client.comments().create(params) +- client.comments().retrieve(params) +- client.comments().list(params) +- client.comments().markAsRead(params) + +# Conferences + +Methods: + +- client.conferences().create(params) +- client.conferences().retrieve(params) +- client.conferences().list(params) +- client.conferences().listParticipants(params) +- client.conferences().retrieveParticipant(params) +- client.conferences().updateParticipant(params) + +## Actions + +Methods: + +- client.conferences().actions().update(params) +- client.conferences().actions().endConference(params) +- client.conferences().actions().gatherDtmfAudio(params) +- client.conferences().actions().hold(params) +- client.conferences().actions().join(params) +- client.conferences().actions().leave(params) +- client.conferences().actions().mute(params) +- client.conferences().actions().play(params) +- client.conferences().actions().recordPause(params) +- client.conferences().actions().recordResume(params) +- client.conferences().actions().recordStart(params) +- client.conferences().actions().recordStop(params) +- client.conferences().actions().sendDtmf(params) +- client.conferences().actions().speak(params) +- client.conferences().actions().stop(params) +- client.conferences().actions().unhold(params) +- client.conferences().actions().unmute(params) + +# Connections + +Methods: + +- client.connections().retrieve(params) +- client.connections().list(params) +- client.connections().listActiveCalls(params) + +# CountryCoverage + +Methods: + +- client.countryCoverage().retrieve() +- client.countryCoverage().retrieveCountry(params) + +# CredentialConnections + +Methods: + +- client.credentialConnections().create(params) +- client.credentialConnections().retrieve(params) +- client.credentialConnections().update(params) +- client.credentialConnections().list(params) +- client.credentialConnections().delete(params) + +## Actions + +Methods: + +- client.credentialConnections().actions().checkRegistrationStatus(params) + +# CustomStorageCredentials + +Methods: + +- client.customStorageCredentials().create(params) +- client.customStorageCredentials().retrieve(params) +- client.customStorageCredentials().update(params) +- client.customStorageCredentials().delete(params) + +# CustomerServiceRecords + +Methods: + +- client.customerServiceRecords().create(params) +- client.customerServiceRecords().retrieve(params) +- client.customerServiceRecords().list(params) +- client.customerServiceRecords().verifyPhoneNumberCoverage(params) + +# DetailRecords + +Methods: + +- client.detailRecords().list(params) + +# DialogflowConnections + +Methods: + +- client.dialogflowConnections().create(params) +- client.dialogflowConnections().retrieve(params) +- client.dialogflowConnections().update(params) +- client.dialogflowConnections().delete(params) + +# DocumentLinks + +Methods: + +- client.documentLinks().list(params) + +# Documents + +Methods: + +- client.documents().retrieve(params) +- client.documents().update(params) +- client.documents().list(params) +- client.documents().delete(params) +- client.documents().download(params) +- client.documents().generateDownloadLink(params) +- client.documents().upload(params) +- client.documents().uploadJson(params) + +# DynamicEmergencyAddresses + +Methods: + +- client.dynamicEmergencyAddresses().create(params) +- client.dynamicEmergencyAddresses().retrieve(params) +- client.dynamicEmergencyAddresses().list(params) +- client.dynamicEmergencyAddresses().delete(params) + +# DynamicEmergencyEndpoints + +Methods: + +- client.dynamicEmergencyEndpoints().create(params) +- client.dynamicEmergencyEndpoints().retrieve(params) +- client.dynamicEmergencyEndpoints().list(params) +- client.dynamicEmergencyEndpoints().delete(params) + +# ExternalConnections + +Methods: + +- client.externalConnections().create(params) +- client.externalConnections().retrieve(params) +- client.externalConnections().update(params) +- client.externalConnections().list(params) +- client.externalConnections().delete(params) +- client.externalConnections().updateLocation(params) + +## LogMessages + +Methods: + +- client.externalConnections().logMessages().retrieve(params) +- client.externalConnections().logMessages().list(params) +- client.externalConnections().logMessages().dismiss(params) + +## CivicAddresses + +Methods: + +- client.externalConnections().civicAddresses().retrieve(params) +- client.externalConnections().civicAddresses().list(params) + +## PhoneNumbers + +Methods: + +- client.externalConnections().phoneNumbers().retrieve(params) +- client.externalConnections().phoneNumbers().update(params) +- client.externalConnections().phoneNumbers().list(params) + +## Releases + +Methods: + +- client.externalConnections().releases().retrieve(params) +- client.externalConnections().releases().list(params) + +## Uploads + +Methods: + +- client.externalConnections().uploads().create(params) +- client.externalConnections().uploads().retrieve(params) +- client.externalConnections().uploads().list(params) +- client.externalConnections().uploads().pendingCount(params) +- client.externalConnections().uploads().refreshStatus(params) +- client.externalConnections().uploads().retry(params) + +# FaxApplications + +Methods: + +- client.faxApplications().create(params) +- client.faxApplications().retrieve(params) +- client.faxApplications().update(params) +- client.faxApplications().list(params) +- client.faxApplications().delete(params) + +# Faxes + +Methods: + +- client.faxes().create(params) +- client.faxes().retrieve(params) +- client.faxes().list(params) +- client.faxes().delete(params) + +## Actions + +Methods: + +- client.faxes().actions().cancel(params) +- client.faxes().actions().refresh(params) + +# FqdnConnections + +Methods: + +- client.fqdnConnections().create(params) +- client.fqdnConnections().retrieve(params) +- client.fqdnConnections().update(params) +- client.fqdnConnections().list(params) +- client.fqdnConnections().delete(params) + +## FqdnAuthentication + +Methods: + +- client.fqdnConnections().fqdnAuthentication().list(params) +- client.fqdnConnections().fqdnAuthentication().patchAll(params) + +# Fqdns + +Methods: + +- client.fqdns().create(params) +- client.fqdns().retrieve(params) +- client.fqdns().update(params) +- client.fqdns().list(params) +- client.fqdns().delete(params) + +# GlobalIpAllowedPorts + +Methods: + +- client.globalIpAllowedPorts().list() + +# GlobalIpAssignmentHealth + +Methods: + +- client.globalIpAssignmentHealth().retrieve(params) + +# GlobalIpAssignments + +Methods: + +- client.globalIpAssignments().create(params) +- client.globalIpAssignments().retrieve(params) +- client.globalIpAssignments().update(params) +- client.globalIpAssignments().list(params) +- client.globalIpAssignments().delete(params) + +# GlobalIpAssignmentsUsage + +Methods: + +- client.globalIpAssignmentsUsage().retrieve(params) + +# GlobalIpHealthCheckTypes + +Methods: + +- client.globalIpHealthCheckTypes().list() + +# GlobalIpHealthChecks + +Methods: + +- client.globalIpHealthChecks().create(params) +- client.globalIpHealthChecks().retrieve(params) +- client.globalIpHealthChecks().list(params) +- client.globalIpHealthChecks().delete(params) + +# GlobalIpLatency + +Methods: + +- client.globalIpLatency().retrieve(params) + +# GlobalIpProtocols + +Methods: + +- client.globalIpProtocols().list() + +# GlobalIpUsage + +Methods: + +- client.globalIpUsage().retrieve(params) + +# GlobalIps + +Methods: + +- client.globalIps().create(params) +- client.globalIps().retrieve(params) +- client.globalIps().list(params) +- client.globalIps().delete(params) + +# InboundChannels + +Methods: + +- client.inboundChannels().update(params) +- client.inboundChannels().list() + +# IntegrationSecrets + +Methods: + +- client.integrationSecrets().create(params) +- client.integrationSecrets().list(params) +- client.integrationSecrets().delete(params) + +# InventoryCoverage + +Methods: + +- client.inventoryCoverage().list(params) + +# Invoices + +Methods: + +- client.invoices().retrieve(params) +- client.invoices().list(params) + +# IpConnections + +Methods: + +- client.ipConnections().create(params) +- client.ipConnections().retrieve(params) +- client.ipConnections().update(params) +- client.ipConnections().list(params) +- client.ipConnections().delete(params) + +# Ips + +Methods: + +- client.ips().create(params) +- client.ips().retrieve(params) +- client.ips().update(params) +- client.ips().list(params) +- client.ips().delete(params) + +# LedgerBillingGroupReports + +Methods: + +- client.ledgerBillingGroupReports().create(params) +- client.ledgerBillingGroupReports().retrieve(params) + +# List + +Methods: + +- client.list().retrieveAll() +- client.list().retrieveByZone(params) + +# ManagedAccounts + +Methods: + +- client.managedAccounts().create(params) +- client.managedAccounts().retrieve(params) +- client.managedAccounts().update(params) +- client.managedAccounts().list(params) +- client.managedAccounts().getAllocatableGlobalOutboundChannels() +- client.managedAccounts().updateGlobalChannelLimit(params) + +## Actions + +Methods: + +- client.managedAccounts().actions().disable(params) +- client.managedAccounts().actions().enable(params) + +# Media + +Methods: + +- client.media().retrieve(params) +- client.media().update(params) +- client.media().list(params) +- client.media().delete(params) +- client.media().download(params) +- client.media().upload(params) + +# Messages + +Methods: + +- client.messages().retrieve(params) +- client.messages().cancelScheduled(params) +- client.messages().retrieveGroupMessages(params) +- client.messages().schedule(params) +- client.messages().send(params) +- client.messages().sendGroupMms(params) +- client.messages().sendLongCode(params) +- client.messages().sendNumberPool(params) +- client.messages().sendShortCode(params) +- client.messages().sendWithAlphanumericSender(params) +- client.messages().whatsapp(params) + +## Rcs + +Methods: + +- client.messages().rcs().generateDeeplink(params) +- client.messages().rcs().send(params) + +# Messaging + +## Rcs + +Methods: + +- client.messaging().rcs().inviteTestNumber(params) +- client.messaging().rcs().listBulkCapabilities(params) +- client.messaging().rcs().retrieveCapabilities(params) + +### Agents + +Methods: + +- client.messaging().rcs().agents().retrieve(params) +- client.messaging().rcs().agents().update(params) +- client.messaging().rcs().agents().list(params) + +# MessagingHostedNumberOrders + +Methods: + +- client.messagingHostedNumberOrders().create(params) +- client.messagingHostedNumberOrders().retrieve(params) +- client.messagingHostedNumberOrders().list(params) +- client.messagingHostedNumberOrders().delete(params) +- client.messagingHostedNumberOrders().checkEligibility(params) +- client.messagingHostedNumberOrders().createVerificationCodes(params) +- client.messagingHostedNumberOrders().validateCodes(params) + +## Actions + +Methods: + +- client.messagingHostedNumberOrders().actions().uploadFile(params) + +# MessagingHostedNumbers + +Methods: + +- client.messagingHostedNumbers().retrieve(params) +- client.messagingHostedNumbers().update(params) +- client.messagingHostedNumbers().list(params) +- client.messagingHostedNumbers().delete(params) + +# MessagingNumbersBulkUpdates + +Methods: + +- client.messagingNumbersBulkUpdates().create(params) +- client.messagingNumbersBulkUpdates().retrieve(params) + +# MessagingOptouts + +Methods: + +- client.messagingOptouts().list(params) + +# MessagingProfiles + +Methods: + +- client.messagingProfiles().create(params) +- client.messagingProfiles().retrieve(params) +- client.messagingProfiles().update(params) +- client.messagingProfiles().list(params) +- client.messagingProfiles().delete(params) +- client.messagingProfiles().listAlphanumericSenderIds(params) +- client.messagingProfiles().listPhoneNumbers(params) +- client.messagingProfiles().listShortCodes(params) +- client.messagingProfiles().retrieveMetrics(params) + +## AutorespConfigs + +Methods: + +- client.messagingProfiles().autorespConfigs().create(params) +- client.messagingProfiles().autorespConfigs().retrieve(params) +- client.messagingProfiles().autorespConfigs().update(params) +- client.messagingProfiles().autorespConfigs().list(params) +- client.messagingProfiles().autorespConfigs().delete(params) + +## Actions + +Methods: + +- client.messagingProfiles().actions().regenerateSecret(params) + +# MessagingTollfree + +## Verification + +### Requests + +Methods: + +- client.messagingTollfree().verification().requests().create(params) +- client.messagingTollfree().verification().requests().retrieve(params) +- client.messagingTollfree().verification().requests().update(params) +- client.messagingTollfree().verification().requests().list(params) +- client.messagingTollfree().verification().requests().delete(params) +- client.messagingTollfree().verification().requests().retrieveStatusHistory(params) + +# MessagingUrlDomains + +Methods: + +- client.messagingUrlDomains().list(params) + +# MobileNetworkOperators + +Methods: + +- client.mobileNetworkOperators().list(params) + +# MobilePushCredentials + +Methods: + +- client.mobilePushCredentials().create(params) +- client.mobilePushCredentials().retrieve(params) +- client.mobilePushCredentials().list(params) +- client.mobilePushCredentials().delete(params) + +# NetworkCoverage + +Methods: + +- client.networkCoverage().list(params) + +# Networks + +Methods: + +- client.networks().create(params) +- client.networks().retrieve(params) +- client.networks().update(params) +- client.networks().list(params) +- client.networks().delete(params) +- client.networks().listInterfaces(params) + +## DefaultGateway + +Methods: + +- client.networks().defaultGateway().create(params) +- client.networks().defaultGateway().retrieve(params) +- client.networks().defaultGateway().delete(params) + +# NotificationChannels + +Methods: + +- client.notificationChannels().create(params) +- client.notificationChannels().retrieve(params) +- client.notificationChannels().update(params) +- client.notificationChannels().list(params) +- client.notificationChannels().delete(params) + +# NotificationEventConditions + +Methods: + +- client.notificationEventConditions().list(params) + +# NotificationEvents + +Methods: + +- client.notificationEvents().list(params) + +# NotificationProfiles + +Methods: + +- client.notificationProfiles().create(params) +- client.notificationProfiles().retrieve(params) +- client.notificationProfiles().update(params) +- client.notificationProfiles().list(params) +- client.notificationProfiles().delete(params) + +# NotificationSettings + +Methods: + +- client.notificationSettings().create(params) +- client.notificationSettings().retrieve(params) +- client.notificationSettings().list(params) +- client.notificationSettings().delete(params) + +# NumberBlockOrders + +Methods: + +- client.numberBlockOrders().create(params) +- client.numberBlockOrders().retrieve(params) +- client.numberBlockOrders().list(params) + +# NumberLookup + +Methods: + +- client.numberLookup().retrieve(params) + +# NumberOrderPhoneNumbers + +Methods: + +- client.numberOrderPhoneNumbers().retrieve(params) +- client.numberOrderPhoneNumbers().list(params) +- client.numberOrderPhoneNumbers().updateRequirementGroup(params) +- client.numberOrderPhoneNumbers().updateRequirements(params) + +# NumberOrders + +Methods: + +- client.numberOrders().create(params) +- client.numberOrders().retrieve(params) +- client.numberOrders().update(params) +- client.numberOrders().list(params) + +# NumberReservations + +Methods: + +- client.numberReservations().create(params) +- client.numberReservations().retrieve(params) +- client.numberReservations().list(params) + +## Actions + +Methods: + +- client.numberReservations().actions().extend(params) + +# NumbersFeatures + +Methods: + +- client.numbersFeatures().create(params) + +# OperatorConnect + +## Actions + +Methods: + +- client.operatorConnect().actions().refresh() + +# OtaUpdates + +Methods: + +- client.otaUpdates().retrieve(params) +- client.otaUpdates().list(params) + +# OutboundVoiceProfiles + +Methods: + +- client.outboundVoiceProfiles().create(params) +- client.outboundVoiceProfiles().retrieve(params) +- client.outboundVoiceProfiles().update(params) +- client.outboundVoiceProfiles().list(params) +- client.outboundVoiceProfiles().delete(params) + +# Payment + +Methods: + +- client.payment().createStoredPaymentTransaction(params) + +## AutoRechargePrefs + +Methods: + +- client.payment().autoRechargePrefs().update(params) +- client.payment().autoRechargePrefs().list() + +# PhoneNumberBlocks + +## Jobs + +Methods: + +- client.phoneNumberBlocks().jobs().retrieve(params) +- client.phoneNumberBlocks().jobs().list(params) +- client.phoneNumberBlocks().jobs().deletePhoneNumberBlock(params) + +# PhoneNumbers + +Methods: + +- client.phoneNumbers().retrieve(params) +- client.phoneNumbers().update(params) +- client.phoneNumbers().list(params) +- client.phoneNumbers().delete(params) +- client.phoneNumbers().slimList(params) + +## Actions + +Methods: + +- client.phoneNumbers().actions().changeBundleStatus(params) +- client.phoneNumbers().actions().enableEmergency(params) +- client.phoneNumbers().actions().verifyOwnership(params) + +## CsvDownloads + +Methods: + +- client.phoneNumbers().csvDownloads().create(params) +- client.phoneNumbers().csvDownloads().retrieve(params) +- client.phoneNumbers().csvDownloads().list(params) + +## Jobs + +Methods: + +- client.phoneNumbers().jobs().retrieve(params) +- client.phoneNumbers().jobs().list(params) +- client.phoneNumbers().jobs().deleteBatch(params) +- client.phoneNumbers().jobs().updateBatch(params) +- client.phoneNumbers().jobs().updateEmergencySettingsBatch(params) + +## Messaging + +Methods: + +- client.phoneNumbers().messaging().retrieve(params) +- client.phoneNumbers().messaging().update(params) +- client.phoneNumbers().messaging().list(params) + +## Voice + +Methods: + +- client.phoneNumbers().voice().retrieve(params) +- client.phoneNumbers().voice().update(params) +- client.phoneNumbers().voice().list(params) + +## Voicemail + +Methods: + +- client.phoneNumbers().voicemail().create(params) +- client.phoneNumbers().voicemail().retrieve(params) +- client.phoneNumbers().voicemail().update(params) + +# PhoneNumbersRegulatoryRequirements + +Methods: + +- client.phoneNumbersRegulatoryRequirements().retrieve(params) + +# PortabilityChecks + +Methods: + +- client.portabilityChecks().run(params) + +# Porting + +Methods: + +- client.porting().listUkCarriers() + +## Events + +Methods: + +- client.porting().events().retrieve(params) +- client.porting().events().list(params) +- client.porting().events().republish(params) + +## Reports + +Methods: + +- client.porting().reports().create(params) +- client.porting().reports().retrieve(params) +- client.porting().reports().list(params) + +## LoaConfigurations + +Methods: + +- client.porting().loaConfigurations().create(params) +- client.porting().loaConfigurations().retrieve(params) +- client.porting().loaConfigurations().update(params) +- client.porting().loaConfigurations().list(params) +- client.porting().loaConfigurations().delete(params) +- client.porting().loaConfigurations().preview(params) +- client.porting().loaConfigurations().preview0(params) +- client.porting().loaConfigurations().preview1(params) + +# PortingOrders + +Methods: + +- client.portingOrders().create(params) +- client.portingOrders().retrieve(params) +- client.portingOrders().update(params) +- client.portingOrders().list(params) +- client.portingOrders().delete(params) +- client.portingOrders().retrieveAllowedFocWindows(params) +- client.portingOrders().retrieveExceptionTypes() +- client.portingOrders().retrieveLoaTemplate(params) +- client.portingOrders().retrieveRequirements(params) +- client.portingOrders().retrieveSubRequest(params) + +## PhoneNumberConfigurations + +Methods: + +- client.portingOrders().phoneNumberConfigurations().create(params) +- client.portingOrders().phoneNumberConfigurations().list(params) + +## Actions + +Methods: + +- client.portingOrders().actions().activate(params) +- client.portingOrders().actions().cancel(params) +- client.portingOrders().actions().confirm(params) +- client.portingOrders().actions().share(params) + +## ActivationJobs + +Methods: + +- client.portingOrders().activationJobs().retrieve(params) +- client.portingOrders().activationJobs().update(params) +- client.portingOrders().activationJobs().list(params) + +## AdditionalDocuments + +Methods: + +- client.portingOrders().additionalDocuments().create(params) +- client.portingOrders().additionalDocuments().list(params) +- client.portingOrders().additionalDocuments().delete(params) + +## Comments + +Methods: + +- client.portingOrders().comments().create(params) +- client.portingOrders().comments().list(params) + +## VerificationCodes + +Methods: + +- client.portingOrders().verificationCodes().list(params) +- client.portingOrders().verificationCodes().send(params) +- client.portingOrders().verificationCodes().verify(params) + +## ActionRequirements + +Methods: + +- client.portingOrders().actionRequirements().list(params) +- client.portingOrders().actionRequirements().initiate(params) + +## AssociatedPhoneNumbers + +Methods: + +- client.portingOrders().associatedPhoneNumbers().create(params) +- client.portingOrders().associatedPhoneNumbers().list(params) +- client.portingOrders().associatedPhoneNumbers().delete(params) + +## PhoneNumberBlocks + +Methods: + +- client.portingOrders().phoneNumberBlocks().create(params) +- client.portingOrders().phoneNumberBlocks().list(params) +- client.portingOrders().phoneNumberBlocks().delete(params) + +## PhoneNumberExtensions + +Methods: + +- client.portingOrders().phoneNumberExtensions().create(params) +- client.portingOrders().phoneNumberExtensions().list(params) +- client.portingOrders().phoneNumberExtensions().delete(params) + +# PortingPhoneNumbers + +Methods: + +- client.portingPhoneNumbers().list(params) + +# Portouts + +Methods: + +- client.portouts().retrieve(params) +- client.portouts().list(params) +- client.portouts().listRejectionCodes(params) +- client.portouts().updateStatus(params) + +## Events + +Methods: + +- client.portouts().events().retrieve(params) +- client.portouts().events().list(params) +- client.portouts().events().republish(params) + +## Reports + +Methods: + +- client.portouts().reports().create(params) +- client.portouts().reports().retrieve(params) +- client.portouts().reports().list(params) + +## Comments + +Methods: + +- client.portouts().comments().create(params) +- client.portouts().comments().list(params) + +## SupportingDocuments + +Methods: + +- client.portouts().supportingDocuments().create(params) +- client.portouts().supportingDocuments().list(params) + +# PrivateWirelessGateways + +Methods: + +- client.privateWirelessGateways().create(params) +- client.privateWirelessGateways().retrieve(params) +- client.privateWirelessGateways().list(params) +- client.privateWirelessGateways().delete(params) + +# PublicInternetGateways + +Methods: + +- client.publicInternetGateways().create(params) +- client.publicInternetGateways().retrieve(params) +- client.publicInternetGateways().list(params) +- client.publicInternetGateways().delete(params) + +# Queues + +Methods: + +- client.queues().create(params) +- client.queues().retrieve(params) +- client.queues().update(params) +- client.queues().list(params) +- client.queues().delete(params) + +## Calls + +Methods: + +- client.queues().calls().retrieve(params) +- client.queues().calls().update(params) +- client.queues().calls().list(params) +- client.queues().calls().remove(params) + +# Rcs + +## Agents + +Methods: + +- client.rcs().agents().create(params) +- client.rcs().agents().retrieve(params) +- client.rcs().agents().update(params) +- client.rcs().agents().list(params) +- client.rcs().agents().launch(params) +- client.rcs().agents().retrieveCarrierApprovals(params) +- client.rcs().agents().submit(params) + +### TestDevices + +Methods: + +- client.rcs().agents().testDevices().create(params) +- client.rcs().agents().testDevices().list(params) +- client.rcs().agents().testDevices().delete(params) + +## Brands + +Methods: + +- client.rcs().brands().create(params) +- client.rcs().brands().retrieve(params) +- client.rcs().brands().update(params) +- client.rcs().brands().list() +- client.rcs().brands().submit(params) + +# RecordingTranscriptions + +Methods: + +- client.recordingTranscriptions().retrieve(params) +- client.recordingTranscriptions().list(params) +- client.recordingTranscriptions().delete(params) + +# Recordings + +Methods: + +- client.recordings().retrieve(params) +- client.recordings().list(params) +- client.recordings().delete(params) + +## Actions + +Methods: + +- client.recordings().actions().delete(params) + +# Regions + +Methods: + +- client.regions().list() + +# RegulatoryRequirements + +Methods: + +- client.regulatoryRequirements().retrieve(params) + +# Reports + +Methods: + +- client.reports().listMdrs(params) +- client.reports().listWdrs(params) + +## CdrUsageReports + +Methods: + +- client.reports().cdrUsageReports().fetchSync(params) + +## MdrUsageReports + +Methods: + +- client.reports().mdrUsageReports().create(params) +- client.reports().mdrUsageReports().retrieve(params) +- client.reports().mdrUsageReports().list(params) +- client.reports().mdrUsageReports().delete(params) +- client.reports().mdrUsageReports().fetchSync(params) + +# SpeechToText + +Methods: + +- client.speechToText().listProviders(params) +- client.speechToText().retrieveTranscription(params) + +# RequirementGroups + +Methods: + +- client.requirementGroups().create(params) +- client.requirementGroups().retrieve(params) +- client.requirementGroups().update(params) +- client.requirementGroups().list(params) +- client.requirementGroups().delete(params) +- client.requirementGroups().submitForApproval(params) + +# RequirementTypes + +Methods: + +- client.requirementTypes().retrieve(params) +- client.requirementTypes().list(params) + +# Requirements + +Methods: + +- client.requirements().retrieve(params) +- client.requirements().list(params) + +# RoomCompositions + +Methods: + +- client.roomCompositions().create(params) +- client.roomCompositions().retrieve(params) +- client.roomCompositions().list(params) +- client.roomCompositions().delete(params) + +# RoomParticipants + +Methods: + +- client.roomParticipants().retrieve(params) +- client.roomParticipants().list(params) + +# RoomRecordings + +Methods: + +- client.roomRecordings().retrieve(params) +- client.roomRecordings().list(params) +- client.roomRecordings().delete(params) +- client.roomRecordings().deleteBulk(params) + +# Rooms + +Methods: + +- client.rooms().create(params) +- client.rooms().retrieve(params) +- client.rooms().update(params) +- client.rooms().list(params) +- client.rooms().delete(params) + +## Actions + +Methods: + +- client.rooms().actions().generateJoinClientToken(params) +- client.rooms().actions().refreshClientToken(params) + +## Sessions + +Methods: + +- client.rooms().sessions().retrieve(params) +- client.rooms().sessions().list0(params) +- client.rooms().sessions().list1(params) +- client.rooms().sessions().retrieveParticipants(params) + +### Actions + +Methods: + +- client.rooms().sessions().actions().end(params) +- client.rooms().sessions().actions().kick(params) +- client.rooms().sessions().actions().mute(params) +- client.rooms().sessions().actions().unmute(params) + +# Seti + +Methods: + +- client.seti().retrieveBlackBoxTestResults(params) + +# ShortCodes + +Methods: + +- client.shortCodes().retrieve(params) +- client.shortCodes().update(params) +- client.shortCodes().list(params) + +# SimCardDataUsageNotifications + +Methods: + +- client.simCardDataUsageNotifications().create(params) +- client.simCardDataUsageNotifications().retrieve(params) +- client.simCardDataUsageNotifications().update(params) +- client.simCardDataUsageNotifications().list(params) +- client.simCardDataUsageNotifications().delete(params) + +# SimCardGroups + +Methods: + +- client.simCardGroups().create(params) +- client.simCardGroups().retrieve(params) +- client.simCardGroups().update(params) +- client.simCardGroups().list(params) +- client.simCardGroups().delete(params) + +## Actions + +Methods: + +- client.simCardGroups().actions().retrieve(params) +- client.simCardGroups().actions().list(params) +- client.simCardGroups().actions().removePrivateWirelessGateway(params) +- client.simCardGroups().actions().removeWirelessBlocklist(params) +- client.simCardGroups().actions().setPrivateWirelessGateway(params) +- client.simCardGroups().actions().setWirelessBlocklist(params) + +# SimCardOrderPreview + +Methods: + +- client.simCardOrderPreview().preview(params) + +# SimCardOrders + +Methods: + +- client.simCardOrders().create(params) +- client.simCardOrders().retrieve(params) +- client.simCardOrders().list(params) + +# SimCards + +Methods: + +- client.simCards().retrieve(params) +- client.simCards().update(params) +- client.simCards().list(params) +- client.simCards().delete(params) +- client.simCards().getActivationCode(params) +- client.simCards().getDeviceDetails(params) +- client.simCards().getPublicIp(params) +- client.simCards().listWirelessConnectivityLogs(params) + +## Actions + +Methods: + +- client.simCards().actions().retrieve(params) +- client.simCards().actions().list(params) +- client.simCards().actions().bulkDisableVoice(params) +- client.simCards().actions().bulkEnableVoice(params) +- client.simCards().actions().bulkSetPublicIps(params) +- client.simCards().actions().disable(params) +- client.simCards().actions().disableVoice(params) +- client.simCards().actions().enable(params) +- client.simCards().actions().enableVoice(params) +- client.simCards().actions().removePublicIp(params) +- client.simCards().actions().setPublicIp(params) +- client.simCards().actions().setStandby(params) +- client.simCards().actions().validateRegistrationCodes(params) + +# SiprecConnectors + +Methods: + +- client.siprecConnectors().create(params) +- client.siprecConnectors().retrieve(params) +- client.siprecConnectors().update(params) +- client.siprecConnectors().delete(params) + +# Storage + +Methods: + +- client.storage().listMigrationSourceCoverage() + +## Buckets + +Methods: + +- client.storage().buckets().createPresignedUrl(params) + +### SslCertificate + +Methods: + +- client.storage().buckets().sslCertificate().create(params) +- client.storage().buckets().sslCertificate().retrieve(params) +- client.storage().buckets().sslCertificate().delete(params) + +### Usage + +Methods: + +- client.storage().buckets().usage().getApiUsage(params) +- client.storage().buckets().usage().getBucketUsage(params) + +## MigrationSources + +Methods: + +- client.storage().migrationSources().create(params) +- client.storage().migrationSources().retrieve(params) +- client.storage().migrationSources().list() +- client.storage().migrationSources().delete(params) + +## Migrations + +Methods: + +- client.storage().migrations().create(params) +- client.storage().migrations().retrieve(params) +- client.storage().migrations().list() + +### Actions + +Methods: + +- client.storage().migrations().actions().stop(params) + +## Kvs + +Methods: + +- client.storage().kvs().create(params) +- client.storage().kvs().retrieve(params) +- client.storage().kvs().list(params) +- client.storage().kvs().delete(params) + +### Keys + +Methods: + +- client.storage().kvs().keys().retrieve(params) +- client.storage().kvs().keys().update(params) +- client.storage().kvs().keys().list(params) +- client.storage().kvs().keys().delete(params) + +## Cloudfs + +Methods: + +- client.storage().cloudfs().create(params) +- client.storage().cloudfs().retrieve(params) +- client.storage().cloudfs().update(params) +- client.storage().cloudfs().list(params) +- client.storage().cloudfs().delete(params) + +### Actions + +Methods: + +- client.storage().cloudfs().actions().rotateMetaToken(params) + +## Sqldbs + +Methods: + +- client.storage().sqldbs().create(params) +- client.storage().sqldbs().retrieve(params) +- client.storage().sqldbs().list(params) +- client.storage().sqldbs().delete(params) + +### Actions + +Methods: + +- client.storage().sqldbs().actions().query(params) + +# SubNumberOrders + +Methods: + +- client.subNumberOrders().retrieve(params) +- client.subNumberOrders().update(params) +- client.subNumberOrders().list(params) +- client.subNumberOrders().cancel(params) +- client.subNumberOrders().updateRequirementGroup(params) + +# SubNumberOrdersReport + +Methods: + +- client.subNumberOrdersReport().create(params) +- client.subNumberOrdersReport().retrieve(params) +- client.subNumberOrdersReport().download(params) + +# TelephonyCredentials + +Methods: + +- client.telephonyCredentials().create(params) +- client.telephonyCredentials().retrieve(params) +- client.telephonyCredentials().update(params) +- client.telephonyCredentials().list(params) +- client.telephonyCredentials().delete(params) +- client.telephonyCredentials().createToken(params) + +# Texml + +Methods: + +- client.texml().initiateAiCall(params) +- client.texml().secrets(params) + +## Accounts + +Methods: + +- client.texml().accounts().retrieveRecordingsJson(params) +- client.texml().accounts().retrieveTranscriptionsJson(params) + +### Calls + +Methods: + +- client.texml().accounts().calls().retrieve(params) +- client.texml().accounts().calls().update(params) +- client.texml().accounts().calls().calls(params) +- client.texml().accounts().calls().retrieveCalls(params) +- client.texml().accounts().calls().siprecJson(params) +- client.texml().accounts().calls().streamsJson(params) + +#### RecordingsJson + +Methods: + +- client.texml().accounts().calls().recordingsJson().recordingsJson(params) +- client.texml().accounts().calls().recordingsJson().retrieveRecordingsJson(params) + +#### Recordings + +Methods: + +- client.texml().accounts().calls().recordings().recordingSidJson(params) + +#### Siprec + +Methods: + +- client.texml().accounts().calls().siprec().siprecSidJson(params) + +#### Streams + +Methods: + +- client.texml().accounts().calls().streams().streamingSidJson(params) + +### Conferences + +Methods: + +- client.texml().accounts().conferences().retrieve(params) +- client.texml().accounts().conferences().update(params) +- client.texml().accounts().conferences().retrieveConferences(params) +- client.texml().accounts().conferences().retrieveRecordings(params) +- client.texml().accounts().conferences().retrieveRecordingsJson(params) + +#### Participants + +Methods: + +- client.texml().accounts().conferences().participants().retrieve(params) +- client.texml().accounts().conferences().participants().update(params) +- client.texml().accounts().conferences().participants().delete(params) +- client.texml().accounts().conferences().participants().participants(params) +- client.texml().accounts().conferences().participants().retrieveParticipants(params) + +### Recordings + +#### Json + +Methods: + +- client.texml().accounts().recordings().json().deleteRecordingSidJson(params) +- client.texml().accounts().recordings().json().retrieveRecordingSidJson(params) + +### Transcriptions + +#### Json + +Methods: + +- client.texml().accounts().transcriptions().json().deleteRecordingTranscriptionSidJson(params) +- client.texml().accounts().transcriptions().json().retrieveRecordingTranscriptionSidJson(params) + +### Queues + +Methods: + +- client.texml().accounts().queues().create(params) +- client.texml().accounts().queues().retrieve(params) +- client.texml().accounts().queues().update(params) +- client.texml().accounts().queues().list(params) +- client.texml().accounts().queues().delete(params) + +# TexmlApplications + +Methods: + +- client.texmlApplications().create(params) +- client.texmlApplications().retrieve(params) +- client.texmlApplications().update(params) +- client.texmlApplications().list(params) +- client.texmlApplications().delete(params) + +# TextToSpeech + +Methods: + +- client.textToSpeech().generateSpeech(params) +- client.textToSpeech().listVoices(params) +- client.textToSpeech().retrieveSpeech(params) + +# UsageReports + +Methods: + +- client.usageReports().list(params) +- client.usageReports().getOptions(params) + +# UserAddresses + +Methods: + +- client.userAddresses().create(params) +- client.userAddresses().retrieve(params) +- client.userAddresses().list(params) + +# UserTags + +Methods: + +- client.userTags().list(params) + +# Verifications + +Methods: + +- client.verifications().retrieve(params) +- client.verifications().triggerCall(params) +- client.verifications().triggerFlashcall(params) +- client.verifications().triggerSms(params) +- client.verifications().triggerWhatsappVerification(params) + +## ByPhoneNumber + +Methods: + +- client.verifications().byPhoneNumber().list(params) + +### Actions + +Methods: + +- client.verifications().byPhoneNumber().actions().verify(params) + +## Actions + +Methods: + +- client.verifications().actions().verify(params) + +# VerifiedNumbers + +Methods: + +- client.verifiedNumbers().create(params) +- client.verifiedNumbers().retrieve(params) +- client.verifiedNumbers().list(params) +- client.verifiedNumbers().delete(params) + +## Actions + +Methods: + +- client.verifiedNumbers().actions().submitVerificationCode(params) + +# VerifyProfiles + +Methods: + +- client.verifyProfiles().create(params) +- client.verifyProfiles().retrieve(params) +- client.verifyProfiles().update(params) +- client.verifyProfiles().list(params) +- client.verifyProfiles().delete(params) +- client.verifyProfiles().createTemplate(params) +- client.verifyProfiles().retrieveTemplates() +- client.verifyProfiles().updateTemplate(params) + +# VirtualCrossConnects + +Methods: + +- client.virtualCrossConnects().create(params) +- client.virtualCrossConnects().retrieve(params) +- client.virtualCrossConnects().update(params) +- client.virtualCrossConnects().list(params) +- client.virtualCrossConnects().delete(params) + +# VirtualCrossConnectsCoverage + +Methods: + +- client.virtualCrossConnectsCoverage().list(params) + +# WebhookDeliveries + +Methods: + +- client.webhookDeliveries().retrieve(params) +- client.webhookDeliveries().list(params) + +# WireguardInterfaces + +Methods: + +- client.wireguardInterfaces().create(params) +- client.wireguardInterfaces().retrieve(params) +- client.wireguardInterfaces().list(params) +- client.wireguardInterfaces().delete(params) + +# WireguardPeers + +Methods: + +- client.wireguardPeers().create(params) +- client.wireguardPeers().retrieve(params) +- client.wireguardPeers().update(params) +- client.wireguardPeers().list(params) +- client.wireguardPeers().delete(params) +- client.wireguardPeers().retrieveConfig(params) + +# Wireless + +Methods: + +- client.wireless().retrieveRegions(params) + +## DetailRecordsReports + +Methods: + +- client.wireless().detailRecordsReports().create(params) +- client.wireless().detailRecordsReports().retrieve(params) +- client.wireless().detailRecordsReports().list(params) +- client.wireless().detailRecordsReports().delete(params) + +# WirelessBlocklistValues + +Methods: + +- client.wirelessBlocklistValues().list(params) + +# WirelessBlocklists + +Methods: + +- client.wirelessBlocklists().create(params) +- client.wirelessBlocklists().retrieve(params) +- client.wirelessBlocklists().update(params) +- client.wirelessBlocklists().list(params) +- client.wirelessBlocklists().delete(params) + +# WellKnown + +Methods: + +- client.wellKnown().retrieveAuthorizationServerMetadata() +- client.wellKnown().retrieveProtectedResourceMetadata() + +# InexplicitNumberOrders + +Methods: + +- client.inexplicitNumberOrders().create(params) +- client.inexplicitNumberOrders().retrieve(params) +- client.inexplicitNumberOrders().list(params) + +# MobilePhoneNumbers + +Methods: + +- client.mobilePhoneNumbers().retrieve(params) +- client.mobilePhoneNumbers().update(params) +- client.mobilePhoneNumbers().list(params) + +## Messaging + +Methods: + +- client.mobilePhoneNumbers().messaging().retrieve(params) +- client.mobilePhoneNumbers().messaging().list(params) + +# MobileVoiceConnections + +Methods: + +- client.mobileVoiceConnections().create(params) +- client.mobileVoiceConnections().retrieve(params) +- client.mobileVoiceConnections().update(params) +- client.mobileVoiceConnections().list(params) +- client.mobileVoiceConnections().delete(params) + +# Messaging10dlc + +Methods: + +- client.messaging10dlc().getEnum(params) + +## Brand + +Methods: + +- client.messaging10dlc().brand().create(params) +- client.messaging10dlc().brand().retrieve(params) +- client.messaging10dlc().brand().update(params) +- client.messaging10dlc().brand().list(params) +- client.messaging10dlc().brand().delete(params) +- client.messaging10dlc().brand().getFeedback(params) +- client.messaging10dlc().brand().getSmsOtpByReference(params) +- client.messaging10dlc().brand().resend2faEmail(params) +- client.messaging10dlc().brand().retrieveSmsOtpStatus(params) +- client.messaging10dlc().brand().revet(params) +- client.messaging10dlc().brand().triggerSmsOtp(params) +- client.messaging10dlc().brand().verifySmsOtp(params) + +### ExternalVetting + +Methods: + +- client.messaging10dlc().brand().externalVetting().list(params) +- client.messaging10dlc().brand().externalVetting().imports(params) +- client.messaging10dlc().brand().externalVetting().order(params) + +## Campaign + +Methods: + +- client.messaging10dlc().campaign().retrieve(params) +- client.messaging10dlc().campaign().update(params) +- client.messaging10dlc().campaign().list(params) +- client.messaging10dlc().campaign().acceptSharing(params) +- client.messaging10dlc().campaign().deactivate(params) +- client.messaging10dlc().campaign().getMnoMetadata(params) +- client.messaging10dlc().campaign().getOperationStatus(params) +- client.messaging10dlc().campaign().getSharingStatus(params) +- client.messaging10dlc().campaign().submitAppeal(params) + +### Usecase + +Methods: + +- client.messaging10dlc().campaign().usecase().getCost(params) + +### Osr + +Methods: + +- client.messaging10dlc().campaign().osr().getAttributes(params) + +## CampaignBuilder + +Methods: + +- client.messaging10dlc().campaignBuilder().submit(params) + +### Brand + +Methods: + +- client.messaging10dlc().campaignBuilder().brand().qualifyByUsecase(params) + +## PartnerCampaigns + +Methods: + +- client.messaging10dlc().partnerCampaigns().retrieve(params) +- client.messaging10dlc().partnerCampaigns().update(params) +- client.messaging10dlc().partnerCampaigns().list(params) +- client.messaging10dlc().partnerCampaigns().listSharedByMe(params) +- client.messaging10dlc().partnerCampaigns().retrieveSharingStatus(params) + +## PhoneNumberCampaigns + +Methods: + +- client.messaging10dlc().phoneNumberCampaigns().create(params) +- client.messaging10dlc().phoneNumberCampaigns().retrieve(params) +- client.messaging10dlc().phoneNumberCampaigns().update(params) +- client.messaging10dlc().phoneNumberCampaigns().list(params) +- client.messaging10dlc().phoneNumberCampaigns().delete(params) + +## PhoneNumberAssignmentByProfile + +Methods: + +- client.messaging10dlc().phoneNumberAssignmentByProfile().assign(params) +- client.messaging10dlc().phoneNumberAssignmentByProfile().listPhoneNumberStatus(params) +- client.messaging10dlc().phoneNumberAssignmentByProfile().retrievePhoneNumberStatus(params) +- client.messaging10dlc().phoneNumberAssignmentByProfile().retrieveStatus(params) + +# Organizations + +## Users + +Methods: + +- client.organizations().users().retrieve(params) +- client.organizations().users().list(params) +- client.organizations().users().getGroupsReport(params) + +### Actions + +Methods: + +- client.organizations().users().actions().remove(params) + +# AlphanumericSenderIds + +Methods: + +- client.alphanumericSenderIds().create(params) +- client.alphanumericSenderIds().retrieve(params) +- client.alphanumericSenderIds().list(params) +- client.alphanumericSenderIds().delete(params) + +# MessagingProfileMetrics + +Methods: + +- client.messagingProfileMetrics().list(params) + +# SessionAnalysis + +Methods: + +- client.sessionAnalysis().retrieve(params) + +## Metadata + +Methods: + +- client.sessionAnalysis().metadata().retrieve() +- client.sessionAnalysis().metadata().retrieveRecordType(params) + +# Whatsapp + +## BusinessAccounts + +Methods: + +- client.whatsapp().businessAccounts().retrieve(params) +- client.whatsapp().businessAccounts().list(params) +- client.whatsapp().businessAccounts().delete(params) + +### PhoneNumbers + +Methods: + +- client.whatsapp().businessAccounts().phoneNumbers().list(params) +- client.whatsapp().businessAccounts().phoneNumbers().initializeVerification(params) + +### Settings + +Methods: + +- client.whatsapp().businessAccounts().settings().retrieve(params) +- client.whatsapp().businessAccounts().settings().update(params) + +## Templates + +Methods: + +- client.whatsapp().templates().create(params) +- client.whatsapp().templates().list(params) + +## PhoneNumbers + +Methods: + +- client.whatsapp().phoneNumbers().list(params) +- client.whatsapp().phoneNumbers().delete(params) +- client.whatsapp().phoneNumbers().get(params) +- client.whatsapp().phoneNumbers().resendVerification(params) +- client.whatsapp().phoneNumbers().retrieveConversationWindow(params) +- client.whatsapp().phoneNumbers().verify(params) + +### CallingSettings + +Methods: + +- client.whatsapp().phoneNumbers().callingSettings().retrieve(params) +- client.whatsapp().phoneNumbers().callingSettings().update(params) + +### Profile + +Methods: + +- client.whatsapp().phoneNumbers().profile().retrieve(params) +- client.whatsapp().phoneNumbers().profile().update(params) + +#### Photo + +Methods: + +- client.whatsapp().phoneNumbers().profile().photo().retrieve(params) +- client.whatsapp().phoneNumbers().profile().photo().delete(params) +- client.whatsapp().phoneNumbers().profile().photo().upload(params) + +### ConversationalComponents + +Methods: + +- client.whatsapp().phoneNumbers().conversationalComponents().list(params) +- client.whatsapp().phoneNumbers().conversationalComponents().patchAll(params) + +## UserData + +Methods: + +- client.whatsapp().userData().retrieve() +- client.whatsapp().userData().update(params) + +# WhatsappMessageTemplates + +Methods: + +- client.whatsappMessageTemplates().retrieve(params) +- client.whatsappMessageTemplates().update(params) +- client.whatsappMessageTemplates().delete(params) + +# X402 + +## CreditAccount + +Methods: + +- client.x402().creditAccount().createQuote(params) +- client.x402().creditAccount().settle(params) + +# VoiceClones + +Methods: + +- client.voiceClones().create(params) +- client.voiceClones().update(params) +- client.voiceClones().list(params) +- client.voiceClones().delete(params) +- client.voiceClones().createFromUpload(params) +- client.voiceClones().downloadSample(params) + +# VoiceDesigns + +Methods: + +- client.voiceDesigns().create(params) +- client.voiceDesigns().retrieve(params) +- client.voiceDesigns().list(params) +- client.voiceDesigns().delete(params) +- client.voiceDesigns().deleteVersion(params) +- client.voiceDesigns().downloadSample(params) +- client.voiceDesigns().rename(params) + +# TrafficPolicyProfiles + +Methods: + +- client.trafficPolicyProfiles().create(params) +- client.trafficPolicyProfiles().retrieve(params) +- client.trafficPolicyProfiles().update(params) +- client.trafficPolicyProfiles().list(params) +- client.trafficPolicyProfiles().delete(params) +- client.trafficPolicyProfiles().listServices(params) + +# Enterprises + +Methods: + +- client.enterprises().create(params) +- client.enterprises().retrieve(params) +- client.enterprises().update(params) +- client.enterprises().list(params) +- client.enterprises().delete(params) +- client.enterprises().brandedCalling(params) + +## Reputation + +Methods: + +- client.enterprises().reputation().retrieve(params) +- client.enterprises().reputation().disable(params) +- client.enterprises().reputation().enable(params) +- client.enterprises().reputation().updateFrequency(params) + +### Numbers + +Methods: + +- client.enterprises().reputation().numbers().retrieve(params) +- client.enterprises().reputation().numbers().list(params) +- client.enterprises().reputation().numbers().associate(params) +- client.enterprises().reputation().numbers().disassociate(params) +- client.enterprises().reputation().numbers().refresh(params) + +### Loa + +Methods: + +- client.enterprises().reputation().loa().update(params) +- client.enterprises().reputation().loa().render(params) + +### Remediation + +Methods: + +- client.enterprises().reputation().remediation().create(params) +- client.enterprises().reputation().remediation().retrieve(params) +- client.enterprises().reputation().remediation().list(params) + +## Dir + +Methods: + +- client.enterprises().dir().create(params) +- client.enterprises().dir().list(params) + +# Reputation + +## Numbers + +Methods: + +- client.reputation().numbers().retrieve(params) +- client.reputation().numbers().list(params) +- client.reputation().numbers().delete(params) + +# TermsOfService + +Methods: + +- client.termsOfService().retrieveInfo(params) +- client.termsOfService().retrieveStatus(params) + +## NumberReputation + +Methods: + +- client.termsOfService().numberReputation().agree() + +## Agreements + +Methods: + +- client.termsOfService().agreements().retrieve(params) +- client.termsOfService().agreements().list(params) + +## BrandedCalling + +Methods: + +- client.termsOfService().brandedCalling().agree() + +# PronunciationDicts + +Methods: + +- client.pronunciationDicts().create(params) +- client.pronunciationDicts().retrieve(params) +- client.pronunciationDicts().update(params) +- client.pronunciationDicts().list(params) +- client.pronunciationDicts().delete(params) + +# UacConnections + +Methods: + +- client.uacConnections().create(params) +- client.uacConnections().retrieve(params) +- client.uacConnections().update(params) +- client.uacConnections().list(params) +- client.uacConnections().delete(params) + +## Actions + +Methods: + +- client.uacConnections().actions().checkRegistrationStatus(params) + +# VoiceSdkCallReports + +Methods: + +- client.voiceSdkCallReports().retrieve(params) +- client.voiceSdkCallReports().list(params) + +# SipRegistrationStatus + +Methods: + +- client.sipRegistrationStatus().retrieve(params) + +# CallReasons + +Methods: + +- client.callReasons().list(params) +- client.callReasons().validate(params) + +# Dir + +Methods: + +- client.dir().retrieve(params) +- client.dir().update(params) +- client.dir().list(params) +- client.dir().delete(params) +- client.dir().listDocumentTypes() +- client.dir().listInfringementClaims(params) +- client.dir().newLoa(params) +- client.dir().submit(params) +- client.dir().updateInfringement(params) + +## Comments + +Methods: + +- client.dir().comments().create(params) +- client.dir().comments().list(params) + +## PhoneNumberBatches + +Methods: + +- client.dir().phoneNumberBatches().retrieve(params) +- client.dir().phoneNumberBatches().list(params) + +## PhoneNumbers + +Methods: + +- client.dir().phoneNumbers().list(params) +- client.dir().phoneNumbers().add(params) +- client.dir().phoneNumbers().remove(params) + +## References + +Methods: + +- client.dir().references().create(params) +- client.dir().references().update(params) +- client.dir().references().list(params) + +## VerifyEmail + +Methods: + +- client.dir().verifyEmail().create(params) +- client.dir().verifyEmail().list(params) +- client.dir().verifyEmail().confirm(params) + +# InfringementClaims + +Methods: + +- client.infringementClaims().retrieve(params) +- client.infringementClaims().contest(params) + +# EmailBlocks + +Methods: + +- client.emailBlocks().create(params) +- client.emailBlocks().retrieve(params) +- client.emailBlocks().list(params) +- client.emailBlocks().delete(params) +- client.emailBlocks().retrieveEvents(params) +- client.emailBlocks().retrieveExport(params) + +## Import + +Methods: + +- client.emailBlocks().import\_().create(params) +- client.emailBlocks().import\_().retrieve(params) + +# EmailDomains + +Methods: + +- client.emailDomains().create(params) +- client.emailDomains().retrieve(params) +- client.emailDomains().update(params) +- client.emailDomains().list(params) +- client.emailDomains().delete(params) +- client.emailDomains().retrieveDnsRecords(params) +- client.emailDomains().retrieveHealth(params) +- client.emailDomains().verify(params) + +## Webhooks + +Methods: + +- client.emailDomains().webhooks().create(params) +- client.emailDomains().webhooks().retrieve(params) +- client.emailDomains().webhooks().update(params) +- client.emailDomains().webhooks().list(params) +- client.emailDomains().webhooks().delete(params) + +# EmailEvents + +Methods: + +- client.emailEvents().list(params) +- client.emailEvents().retrieveStats(params) + +# EmailInboxes + +Methods: + +- client.emailInboxes().create(params) +- client.emailInboxes().retrieve(params) +- client.emailInboxes().list(params) +- client.emailInboxes().delete(params) + +## Drafts + +Methods: + +- client.emailInboxes().drafts().create(params) +- client.emailInboxes().drafts().retrieve(params) +- client.emailInboxes().drafts().update(params) +- client.emailInboxes().drafts().list(params) +- client.emailInboxes().drafts().delete(params) +- client.emailInboxes().drafts().patch(params) +- client.emailInboxes().drafts().send(params) + +## Filters + +Methods: + +- client.emailInboxes().filters().list(params) +- client.emailInboxes().filters().add(params) +- client.emailInboxes().filters().deleteAll(params) +- client.emailInboxes().filters().replace(params) + +## Messages + +Methods: + +- client.emailInboxes().messages().update(params) +- client.emailInboxes().messages().list(params) +- client.emailInboxes().messages().drafts(params) + +### Actions + +Methods: + +- client.emailInboxes().messages().actions().forward(params) +- client.emailInboxes().messages().actions().reply(params) +- client.emailInboxes().messages().actions().replyAll(params) + +### Labels + +Methods: + +- client.emailInboxes().messages().labels().create(params) +- client.emailInboxes().messages().labels().deleteAll(params) + +## Threads + +Methods: + +- client.emailInboxes().threads().retrieve(params) +- client.emailInboxes().threads().list(params) + +### Labels + +Methods: + +- client.emailInboxes().threads().labels().create(params) +- client.emailInboxes().threads().labels().deleteAll(params) + +# EmailMessages + +Methods: + +- client.emailMessages().create(params) +- client.emailMessages().retrieve(params) +- client.emailMessages().list(params) +- client.emailMessages().delete(params) +- client.emailMessages().batch(params) +- client.emailMessages().deleteAll(params) +- client.emailMessages().deleteSchedule(params) +- client.emailMessages().retrieveEvents(params) + +## Recipients + +Methods: + +- client.emailMessages().recipients().retrieve(params) +- client.emailMessages().recipients().list(params) + +# EmailTemplates + +Methods: + +- client.emailTemplates().create(params) +- client.emailTemplates().retrieve(params) +- client.emailTemplates().update(params) +- client.emailTemplates().list(params) +- client.emailTemplates().delete(params) +- client.emailTemplates().render(params) +- client.emailTemplates().replace(params) + +# EmailThreads + +Methods: + +- client.emailThreads().retrieve(params) +- client.emailThreads().list(params) + +# EmailUnsubscribeGroups + +Methods: + +- client.emailUnsubscribeGroups().create(params) +- client.emailUnsubscribeGroups().retrieve(params) +- client.emailUnsubscribeGroups().update(params) +- client.emailUnsubscribeGroups().list(params) +- client.emailUnsubscribeGroups().delete(params) + +## Suppressions + +Methods: + +- client.emailUnsubscribeGroups().suppressions().create(params) +- client.emailUnsubscribeGroups().suppressions().list(params) +- client.emailUnsubscribeGroups().suppressions().delete(params) + +# EmailValidations + +Methods: + +- client.emailValidations().create(params) + +## Batch + +Methods: + +- client.emailValidations().batch().create(params) +- client.emailValidations().batch().retrieve(params) + +# Pricing + +## Products + +Methods: + +- client.pricing().products().retrieve(params) +- client.pricing().products().list(params) + +# WebSearch + +Methods: + +- client.webSearch().create(params) +- client.webSearch().contents(params) + +## Research + +Methods: + +- client.webSearch().research().create(params) +- client.webSearch().research().retrieve(params) diff --git a/build.gradle.kts b/build.gradle.kts index 0f528f08b..5be148378 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ allprojects { group = "com.telnyx.sdk" - version = "6.85.0" // x-release-please-version + version = "6.86.0" // x-release-please-version } subprojects { diff --git a/gradle.properties b/gradle.properties index 6680f9ce9..bc7b5ee37 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,8 +4,8 @@ org.gradle.parallel=true org.gradle.daemon=false # These options improve our compilation and test performance. They are inherited by the Kotlin daemon. org.gradle.jvmargs=\ - -Xms2g \ - -Xmx8g \ + -Xms12g \ + -Xmx12g \ -XX:+UseParallelGC \ -XX:InitialCodeCacheSize=256m \ -XX:ReservedCodeCacheSize=1G \ diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClient.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClient.kt index 84e83bb61..7b661c1e7 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClient.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClient.kt @@ -172,6 +172,7 @@ import com.telnyx.sdk.services.blocking.VirtualCrossConnectsCoverageService import com.telnyx.sdk.services.blocking.VoiceCloneService import com.telnyx.sdk.services.blocking.VoiceDesignService import com.telnyx.sdk.services.blocking.VoiceSdkCallReportService +import com.telnyx.sdk.services.blocking.WebSearchService import com.telnyx.sdk.services.blocking.WebhookDeliveryService import com.telnyx.sdk.services.blocking.WebhookService import com.telnyx.sdk.services.blocking.WellKnownService @@ -750,6 +751,8 @@ interface TelnyxClient { fun pricing(): PricingService + fun webSearch(): WebSearchService + /** * Closes this client, relinquishing any underlying resources. * @@ -1305,5 +1308,7 @@ interface TelnyxClient { fun emailValidations(): EmailValidationService.WithRawResponse fun pricing(): PricingService.WithRawResponse + + fun webSearch(): WebSearchService.WithRawResponse } } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientAsync.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientAsync.kt index f838cf014..044534c89 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientAsync.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientAsync.kt @@ -172,6 +172,7 @@ import com.telnyx.sdk.services.async.VirtualCrossConnectsCoverageServiceAsync import com.telnyx.sdk.services.async.VoiceCloneServiceAsync import com.telnyx.sdk.services.async.VoiceDesignServiceAsync import com.telnyx.sdk.services.async.VoiceSdkCallReportServiceAsync +import com.telnyx.sdk.services.async.WebSearchServiceAsync import com.telnyx.sdk.services.async.WebhookDeliveryServiceAsync import com.telnyx.sdk.services.async.WebhookServiceAsync import com.telnyx.sdk.services.async.WellKnownServiceAsync @@ -750,6 +751,8 @@ interface TelnyxClientAsync { fun pricing(): PricingServiceAsync + fun webSearch(): WebSearchServiceAsync + /** * Closes this client, relinquishing any underlying resources. * @@ -1308,5 +1311,7 @@ interface TelnyxClientAsync { fun emailValidations(): EmailValidationServiceAsync.WithRawResponse fun pricing(): PricingServiceAsync.WithRawResponse + + fun webSearch(): WebSearchServiceAsync.WithRawResponse } } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientAsyncImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientAsyncImpl.kt index 48becfe0a..13ae10920 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientAsyncImpl.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientAsyncImpl.kt @@ -342,6 +342,8 @@ import com.telnyx.sdk.services.async.VoiceDesignServiceAsync import com.telnyx.sdk.services.async.VoiceDesignServiceAsyncImpl import com.telnyx.sdk.services.async.VoiceSdkCallReportServiceAsync import com.telnyx.sdk.services.async.VoiceSdkCallReportServiceAsyncImpl +import com.telnyx.sdk.services.async.WebSearchServiceAsync +import com.telnyx.sdk.services.async.WebSearchServiceAsyncImpl import com.telnyx.sdk.services.async.WebhookDeliveryServiceAsync import com.telnyx.sdk.services.async.WebhookDeliveryServiceAsyncImpl import com.telnyx.sdk.services.async.WebhookServiceAsync @@ -1082,6 +1084,10 @@ class TelnyxClientAsyncImpl(private val clientOptions: ClientOptions) : TelnyxCl PricingServiceAsyncImpl(clientOptionsWithUserAgent) } + private val webSearch: WebSearchServiceAsync by lazy { + WebSearchServiceAsyncImpl(clientOptionsWithUserAgent) + } + override fun sync(): TelnyxClient = sync override fun withRawResponse(): TelnyxClientAsync.WithRawResponse = withRawResponse @@ -1648,6 +1654,8 @@ class TelnyxClientAsyncImpl(private val clientOptions: ClientOptions) : TelnyxCl override fun pricing(): PricingServiceAsync = pricing + override fun webSearch(): WebSearchServiceAsync = webSearch + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -2412,6 +2420,10 @@ class TelnyxClientAsyncImpl(private val clientOptions: ClientOptions) : TelnyxCl PricingServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val webSearch: WebSearchServiceAsync.WithRawResponse by lazy { + WebSearchServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): TelnyxClientAsync.WithRawResponse = @@ -3035,5 +3047,7 @@ class TelnyxClientAsyncImpl(private val clientOptions: ClientOptions) : TelnyxCl emailValidations override fun pricing(): PricingServiceAsync.WithRawResponse = pricing + + override fun webSearch(): WebSearchServiceAsync.WithRawResponse = webSearch } } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientImpl.kt index e062d1630..c437b14ca 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientImpl.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/client/TelnyxClientImpl.kt @@ -342,6 +342,8 @@ import com.telnyx.sdk.services.blocking.VoiceDesignService import com.telnyx.sdk.services.blocking.VoiceDesignServiceImpl import com.telnyx.sdk.services.blocking.VoiceSdkCallReportService import com.telnyx.sdk.services.blocking.VoiceSdkCallReportServiceImpl +import com.telnyx.sdk.services.blocking.WebSearchService +import com.telnyx.sdk.services.blocking.WebSearchServiceImpl import com.telnyx.sdk.services.blocking.WebhookDeliveryService import com.telnyx.sdk.services.blocking.WebhookDeliveryServiceImpl import com.telnyx.sdk.services.blocking.WebhookService @@ -1038,6 +1040,10 @@ class TelnyxClientImpl(private val clientOptions: ClientOptions) : TelnyxClient private val pricing: PricingService by lazy { PricingServiceImpl(clientOptionsWithUserAgent) } + private val webSearch: WebSearchService by lazy { + WebSearchServiceImpl(clientOptionsWithUserAgent) + } + override fun async(): TelnyxClientAsync = async override fun withRawResponse(): TelnyxClient.WithRawResponse = withRawResponse @@ -1589,6 +1595,8 @@ class TelnyxClientImpl(private val clientOptions: ClientOptions) : TelnyxClient override fun pricing(): PricingService = pricing + override fun webSearch(): WebSearchService = webSearch + override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -2329,6 +2337,10 @@ class TelnyxClientImpl(private val clientOptions: ClientOptions) : TelnyxClient PricingServiceImpl.WithRawResponseImpl(clientOptions) } + private val webSearch: WebSearchService.WithRawResponse by lazy { + WebSearchServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): TelnyxClient.WithRawResponse = @@ -2938,5 +2950,7 @@ class TelnyxClientImpl(private val clientOptions: ClientOptions) : TelnyxClient override fun emailValidations(): EmailValidationService.WithRawResponse = emailValidations override fun pricing(): PricingService.WithRawResponse = pricing + + override fun webSearch(): WebSearchService.WithRawResponse = webSearch } } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/calls/CallDialParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/calls/CallDialParams.kt index e5e0712d5..5c3a43757 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/calls/CallDialParams.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/calls/CallDialParams.kt @@ -655,9 +655,9 @@ private constructor( fun webhookUrlMethod(): Optional = body.webhookUrlMethod() /** - * A map of event types to webhook URLs. When an event of the specified type occurs, the webhook - * URL associated with that event type will be called instead of the default webhook URL. Events - * not mapped here will use the default webhook URL. + * A map of event types to arrays of webhook URLs. When an event of the specified type occurs, + * the webhook URLs associated with that event type will be called instead of the default + * webhook URL. Events not mapped here will use the default webhook URL. * * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -2309,9 +2309,9 @@ private constructor( } /** - * A map of event types to webhook URLs. When an event of the specified type occurs, the - * webhook URL associated with that event type will be called instead of the default webhook - * URL. Events not mapped here will use the default webhook URL. + * A map of event types to arrays of webhook URLs. When an event of the specified type + * occurs, the webhook URLs associated with that event type will be called instead of the + * default webhook URL. Events not mapped here will use the default webhook URL. */ fun webhookUrls(webhookUrls: WebhookUrls) = apply { body.webhookUrls(webhookUrls) } @@ -3426,9 +3426,9 @@ private constructor( webhookUrlMethod.getOptional("webhook_url_method") /** - * A map of event types to webhook URLs. When an event of the specified type occurs, the - * webhook URL associated with that event type will be called instead of the default webhook - * URL. Events not mapped here will use the default webhook URL. + * A map of event types to arrays of webhook URLs. When an event of the specified type + * occurs, the webhook URLs associated with that event type will be called instead of the + * default webhook URL. Events not mapped here will use the default webhook URL. * * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -5328,9 +5328,9 @@ private constructor( } /** - * A map of event types to webhook URLs. When an event of the specified type occurs, the - * webhook URL associated with that event type will be called instead of the default - * webhook URL. Events not mapped here will use the default webhook URL. + * A map of event types to arrays of webhook URLs. When an event of the specified type + * occurs, the webhook URLs associated with that event type will be called instead of + * the default webhook URL. Events not mapped here will use the default webhook URL. */ fun webhookUrls(webhookUrls: WebhookUrls) = webhookUrls(JsonField.of(webhookUrls)) @@ -10005,9 +10005,9 @@ private constructor( } /** - * A map of event types to webhook URLs. When an event of the specified type occurs, the webhook - * URL associated with that event type will be called instead of the default webhook URL. Events - * not mapped here will use the default webhook URL. + * A map of event types to arrays of webhook URLs. When an event of the specified type occurs, + * the webhook URLs associated with that event type will be called instead of the default + * webhook URL. Events not mapped here will use the default webhook URL. */ class WebhookUrls @JsonCreator diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/calls/actions/ActionAnswerParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/calls/actions/ActionAnswerParams.kt index 37bf807a9..cfb80a752 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/calls/actions/ActionAnswerParams.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/calls/actions/ActionAnswerParams.kt @@ -323,9 +323,9 @@ private constructor( fun webhookUrlMethod(): Optional = body.webhookUrlMethod() /** - * A map of event types to webhook URLs. When an event of the specified type occurs, the webhook - * URL associated with that event type will be called instead of `webhook_url`. Events not - * mapped here will use the default `webhook_url`. + * A map of event types to arrays of webhook URLs. When an event of the specified type occurs, + * the webhook URLs associated with that event type will be called instead of `webhook_url`. + * Events not mapped here will use the default `webhook_url`. * * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1155,9 +1155,9 @@ private constructor( } /** - * A map of event types to webhook URLs. When an event of the specified type occurs, the - * webhook URL associated with that event type will be called instead of `webhook_url`. - * Events not mapped here will use the default `webhook_url`. + * A map of event types to arrays of webhook URLs. When an event of the specified type + * occurs, the webhook URLs associated with that event type will be called instead of + * `webhook_url`. Events not mapped here will use the default `webhook_url`. */ fun webhookUrls(webhookUrls: WebhookUrls) = apply { body.webhookUrls(webhookUrls) } @@ -1783,9 +1783,9 @@ private constructor( webhookUrlMethod.getOptional("webhook_url_method") /** - * A map of event types to webhook URLs. When an event of the specified type occurs, the - * webhook URL associated with that event type will be called instead of `webhook_url`. - * Events not mapped here will use the default `webhook_url`. + * A map of event types to arrays of webhook URLs. When an event of the specified type + * occurs, the webhook URLs associated with that event type will be called instead of + * `webhook_url`. Events not mapped here will use the default `webhook_url`. * * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -2723,9 +2723,9 @@ private constructor( } /** - * A map of event types to webhook URLs. When an event of the specified type occurs, the - * webhook URL associated with that event type will be called instead of `webhook_url`. - * Events not mapped here will use the default `webhook_url`. + * A map of event types to arrays of webhook URLs. When an event of the specified type + * occurs, the webhook URLs associated with that event type will be called instead of + * `webhook_url`. Events not mapped here will use the default `webhook_url`. */ fun webhookUrls(webhookUrls: WebhookUrls) = webhookUrls(JsonField.of(webhookUrls)) @@ -4481,9 +4481,9 @@ private constructor( } /** - * A map of event types to webhook URLs. When an event of the specified type occurs, the webhook - * URL associated with that event type will be called instead of `webhook_url`. Events not - * mapped here will use the default `webhook_url`. + * A map of event types to arrays of webhook URLs. When an event of the specified type occurs, + * the webhook URLs associated with that event type will be called instead of `webhook_url`. + * Events not mapped here will use the default `webhook_url`. */ class WebhookUrls @JsonCreator diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/calls/actions/ActionTransferParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/calls/actions/ActionTransferParams.kt index e1fb0bf11..4f48e31ea 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/calls/actions/ActionTransferParams.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/calls/actions/ActionTransferParams.kt @@ -423,9 +423,9 @@ private constructor( fun webhookUrlMethod(): Optional = body.webhookUrlMethod() /** - * A map of event types to webhook URLs. When an event of the specified type occurs, the webhook - * URL associated with that event type will be called instead of `webhook_url`. Events not - * mapped here will use the default `webhook_url`. + * A map of event types to arrays of webhook URLs. When an event of the specified type occurs, + * the webhook URLs associated with that event type will be called instead of `webhook_url`. + * Events not mapped here will use the default `webhook_url`. * * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1470,9 +1470,9 @@ private constructor( } /** - * A map of event types to webhook URLs. When an event of the specified type occurs, the - * webhook URL associated with that event type will be called instead of `webhook_url`. - * Events not mapped here will use the default `webhook_url`. + * A map of event types to arrays of webhook URLs. When an event of the specified type + * occurs, the webhook URLs associated with that event type will be called instead of + * `webhook_url`. Events not mapped here will use the default `webhook_url`. */ fun webhookUrls(webhookUrls: WebhookUrls) = apply { body.webhookUrls(webhookUrls) } @@ -2244,9 +2244,9 @@ private constructor( webhookUrlMethod.getOptional("webhook_url_method") /** - * A map of event types to webhook URLs. When an event of the specified type occurs, the - * webhook URL associated with that event type will be called instead of `webhook_url`. - * Events not mapped here will use the default `webhook_url`. + * A map of event types to arrays of webhook URLs. When an event of the specified type + * occurs, the webhook URLs associated with that event type will be called instead of + * `webhook_url`. Events not mapped here will use the default `webhook_url`. * * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -3434,9 +3434,9 @@ private constructor( } /** - * A map of event types to webhook URLs. When an event of the specified type occurs, the - * webhook URL associated with that event type will be called instead of `webhook_url`. - * Events not mapped here will use the default `webhook_url`. + * A map of event types to arrays of webhook URLs. When an event of the specified type + * occurs, the webhook URLs associated with that event type will be called instead of + * `webhook_url`. Events not mapped here will use the default `webhook_url`. */ fun webhookUrls(webhookUrls: WebhookUrls) = webhookUrls(JsonField.of(webhookUrls)) @@ -6242,9 +6242,9 @@ private constructor( } /** - * A map of event types to webhook URLs. When an event of the specified type occurs, the webhook - * URL associated with that event type will be called instead of `webhook_url`. Events not - * mapped here will use the default `webhook_url`. + * A map of event types to arrays of webhook URLs. When an event of the specified type occurs, + * the webhook URLs associated with that event type will be called instead of `webhook_url`. + * Events not mapped here will use the default `webhook_url`. */ class WebhookUrls @JsonCreator diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailCreateParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailCreateParams.kt index 1a03735bf..eff7705f4 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailCreateParams.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailCreateParams.kt @@ -10,7 +10,12 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** Create voicemail settings for a phone number */ +/** + * Create voicemail settings for a phone number. You can also configure a custom greeting by setting + * the `greeting` object: use `mode` `custom_greeting` together with a `media_name` that points to + * an audio file uploaded through the Media Storage API, or `mode` `default` to use the standard + * system greeting. + */ class VoicemailCreateParams private constructor( private val phoneNumberId: String?, diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailPrefResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailPrefResponse.kt index b627dc30a..b83d37040 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailPrefResponse.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailPrefResponse.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.telnyx.sdk.core.Enum import com.telnyx.sdk.core.ExcludeMissing import com.telnyx.sdk.core.JsonField import com.telnyx.sdk.core.JsonMissing @@ -14,11 +15,13 @@ import com.telnyx.sdk.errors.TelnyxInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull class VoicemailPrefResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val enabled: JsonField, + private val greeting: JsonField, private val pin: JsonField, private val additionalProperties: MutableMap, ) { @@ -26,8 +29,9 @@ private constructor( @JsonCreator private constructor( @JsonProperty("enabled") @ExcludeMissing enabled: JsonField = JsonMissing.of(), + @JsonProperty("greeting") @ExcludeMissing greeting: JsonField = JsonMissing.of(), @JsonProperty("pin") @ExcludeMissing pin: JsonField = JsonMissing.of(), - ) : this(enabled, pin, mutableMapOf()) + ) : this(enabled, greeting, pin, mutableMapOf()) /** * Whether voicemail is enabled. @@ -37,6 +41,17 @@ private constructor( */ fun enabled(): Optional = enabled.getOptional("enabled") + /** + * Controls the greeting a caller hears before leaving a voicemail. Set `mode` to `default` to + * play the standard system greeting, or to `custom_greeting` to play your own audio. When + * `mode` is `custom_greeting`, `media_name` is required and must reference an audio file + * already uploaded to your account through the Media Storage API. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun greeting(): Optional = greeting.getOptional("greeting") + /** * The pin used for the voicemail. * @@ -52,6 +67,13 @@ private constructor( */ @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled + /** + * Returns the raw JSON value of [greeting]. + * + * Unlike [greeting], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("greeting") @ExcludeMissing fun _greeting(): JsonField = greeting + /** * Returns the raw JSON value of [pin]. * @@ -81,12 +103,14 @@ private constructor( class Builder internal constructor() { private var enabled: JsonField = JsonMissing.of() + private var greeting: JsonField = JsonMissing.of() private var pin: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(voicemailPrefResponse: VoicemailPrefResponse) = apply { enabled = voicemailPrefResponse.enabled + greeting = voicemailPrefResponse.greeting pin = voicemailPrefResponse.pin additionalProperties = voicemailPrefResponse.additionalProperties.toMutableMap() } @@ -102,6 +126,23 @@ private constructor( */ fun enabled(enabled: JsonField) = apply { this.enabled = enabled } + /** + * Controls the greeting a caller hears before leaving a voicemail. Set `mode` to `default` + * to play the standard system greeting, or to `custom_greeting` to play your own audio. + * When `mode` is `custom_greeting`, `media_name` is required and must reference an audio + * file already uploaded to your account through the Media Storage API. + */ + fun greeting(greeting: Greeting) = greeting(JsonField.of(greeting)) + + /** + * Sets [Builder.greeting] to an arbitrary JSON value. + * + * You should usually call [Builder.greeting] with a well-typed [Greeting] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun greeting(greeting: JsonField) = apply { this.greeting = greeting } + /** The pin used for the voicemail. */ fun pin(pin: String) = pin(JsonField.of(pin)) @@ -138,7 +179,7 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): VoicemailPrefResponse = - VoicemailPrefResponse(enabled, pin, additionalProperties.toMutableMap()) + VoicemailPrefResponse(enabled, greeting, pin, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -157,6 +198,7 @@ private constructor( } enabled() + greeting().ifPresent { it.validate() } pin() validated = true } @@ -176,7 +218,359 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (enabled.asKnown().isPresent) 1 else 0) + (if (pin.asKnown().isPresent) 1 else 0) + (if (enabled.asKnown().isPresent) 1 else 0) + + (greeting.asKnown().getOrNull()?.validity() ?: 0) + + (if (pin.asKnown().isPresent) 1 else 0) + + /** + * Controls the greeting a caller hears before leaving a voicemail. Set `mode` to `default` to + * play the standard system greeting, or to `custom_greeting` to play your own audio. When + * `mode` is `custom_greeting`, `media_name` is required and must reference an audio file + * already uploaded to your account through the Media Storage API. + */ + class Greeting + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val mediaName: JsonField, + private val mode: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("media_name") + @ExcludeMissing + mediaName: JsonField = JsonMissing.of(), + @JsonProperty("mode") @ExcludeMissing mode: JsonField = JsonMissing.of(), + ) : this(mediaName, mode, mutableMapOf()) + + /** + * The name of the media file to play as the greeting. Required when `mode` is + * `custom_greeting`; ignored when `mode` is `default`. The value must match the + * `media_name` of a file you previously uploaded with the Media Storage API (`POST + * /v2/media`). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mediaName(): Optional = mediaName.getOptional("media_name") + + /** + * The greeting mode. `default` plays the standard system greeting. `custom_greeting` plays + * the audio referenced by `media_name`. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mode(): Optional = mode.getOptional("mode") + + /** + * Returns the raw JSON value of [mediaName]. + * + * Unlike [mediaName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("media_name") @ExcludeMissing fun _mediaName(): JsonField = mediaName + + /** + * Returns the raw JSON value of [mode]. + * + * Unlike [mode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Greeting]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Greeting]. */ + class Builder internal constructor() { + + private var mediaName: JsonField = JsonMissing.of() + private var mode: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(greeting: Greeting) = apply { + mediaName = greeting.mediaName + mode = greeting.mode + additionalProperties = greeting.additionalProperties.toMutableMap() + } + + /** + * The name of the media file to play as the greeting. Required when `mode` is + * `custom_greeting`; ignored when `mode` is `default`. The value must match the + * `media_name` of a file you previously uploaded with the Media Storage API (`POST + * /v2/media`). + */ + fun mediaName(mediaName: String?) = mediaName(JsonField.ofNullable(mediaName)) + + /** Alias for calling [Builder.mediaName] with `mediaName.orElse(null)`. */ + fun mediaName(mediaName: Optional) = mediaName(mediaName.getOrNull()) + + /** + * Sets [Builder.mediaName] to an arbitrary JSON value. + * + * You should usually call [Builder.mediaName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun mediaName(mediaName: JsonField) = apply { this.mediaName = mediaName } + + /** + * The greeting mode. `default` plays the standard system greeting. `custom_greeting` + * plays the audio referenced by `media_name`. + */ + fun mode(mode: Mode) = mode(JsonField.of(mode)) + + /** + * Sets [Builder.mode] to an arbitrary JSON value. + * + * You should usually call [Builder.mode] with a well-typed [Mode] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun mode(mode: JsonField) = apply { this.mode = mode } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Greeting]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Greeting = Greeting(mediaName, mode, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Greeting = apply { + if (validated) { + return@apply + } + + mediaName() + mode().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (mediaName.asKnown().isPresent) 1 else 0) + + (mode.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The greeting mode. `default` plays the standard system greeting. `custom_greeting` plays + * the audio referenced by `media_name`. + */ + class Mode @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DEFAULT = of("default") + + @JvmField val CUSTOM_GREETING = of("custom_greeting") + + @JvmStatic fun of(value: String) = Mode(JsonField.of(value)) + } + + /** An enum containing [Mode]'s known values. */ + enum class Known { + DEFAULT, + CUSTOM_GREETING, + } + + /** + * An enum containing [Mode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Mode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DEFAULT, + CUSTOM_GREETING, + /** An enum member indicating that [Mode] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DEFAULT -> Value.DEFAULT + CUSTOM_GREETING -> Value.CUSTOM_GREETING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + DEFAULT -> Known.DEFAULT + CUSTOM_GREETING -> Known.CUSTOM_GREETING + else -> throw TelnyxInvalidDataException("Unknown Mode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + TelnyxInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Mode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Mode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Greeting && + mediaName == other.mediaName && + mode == other.mode && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(mediaName, mode, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Greeting{mediaName=$mediaName, mode=$mode, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -185,14 +579,15 @@ private constructor( return other is VoicemailPrefResponse && enabled == other.enabled && + greeting == other.greeting && pin == other.pin && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(enabled, pin, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(enabled, greeting, pin, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "VoicemailPrefResponse{enabled=$enabled, pin=$pin, additionalProperties=$additionalProperties}" + "VoicemailPrefResponse{enabled=$enabled, greeting=$greeting, pin=$pin, additionalProperties=$additionalProperties}" } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailRequest.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailRequest.kt index 5cc5693e2..da0629e25 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailRequest.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailRequest.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.telnyx.sdk.core.Enum import com.telnyx.sdk.core.ExcludeMissing import com.telnyx.sdk.core.JsonField import com.telnyx.sdk.core.JsonMissing @@ -14,11 +15,13 @@ import com.telnyx.sdk.errors.TelnyxInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull class VoicemailRequest @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val enabled: JsonField, + private val greeting: JsonField, private val pin: JsonField, private val additionalProperties: MutableMap, ) { @@ -26,8 +29,9 @@ private constructor( @JsonCreator private constructor( @JsonProperty("enabled") @ExcludeMissing enabled: JsonField = JsonMissing.of(), + @JsonProperty("greeting") @ExcludeMissing greeting: JsonField = JsonMissing.of(), @JsonProperty("pin") @ExcludeMissing pin: JsonField = JsonMissing.of(), - ) : this(enabled, pin, mutableMapOf()) + ) : this(enabled, greeting, pin, mutableMapOf()) /** * Whether voicemail is enabled. @@ -37,6 +41,17 @@ private constructor( */ fun enabled(): Optional = enabled.getOptional("enabled") + /** + * Controls the greeting a caller hears before leaving a voicemail. Set `mode` to `default` to + * play the standard system greeting, or to `custom_greeting` to play your own audio. When + * `mode` is `custom_greeting`, `media_name` is required and must reference an audio file + * already uploaded to your account through the Media Storage API. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun greeting(): Optional = greeting.getOptional("greeting") + /** * The pin used for voicemail * @@ -52,6 +67,13 @@ private constructor( */ @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled + /** + * Returns the raw JSON value of [greeting]. + * + * Unlike [greeting], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("greeting") @ExcludeMissing fun _greeting(): JsonField = greeting + /** * Returns the raw JSON value of [pin]. * @@ -81,12 +103,14 @@ private constructor( class Builder internal constructor() { private var enabled: JsonField = JsonMissing.of() + private var greeting: JsonField = JsonMissing.of() private var pin: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(voicemailRequest: VoicemailRequest) = apply { enabled = voicemailRequest.enabled + greeting = voicemailRequest.greeting pin = voicemailRequest.pin additionalProperties = voicemailRequest.additionalProperties.toMutableMap() } @@ -102,6 +126,23 @@ private constructor( */ fun enabled(enabled: JsonField) = apply { this.enabled = enabled } + /** + * Controls the greeting a caller hears before leaving a voicemail. Set `mode` to `default` + * to play the standard system greeting, or to `custom_greeting` to play your own audio. + * When `mode` is `custom_greeting`, `media_name` is required and must reference an audio + * file already uploaded to your account through the Media Storage API. + */ + fun greeting(greeting: Greeting) = greeting(JsonField.of(greeting)) + + /** + * Sets [Builder.greeting] to an arbitrary JSON value. + * + * You should usually call [Builder.greeting] with a well-typed [Greeting] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun greeting(greeting: JsonField) = apply { this.greeting = greeting } + /** The pin used for voicemail */ fun pin(pin: String) = pin(JsonField.of(pin)) @@ -138,7 +179,7 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): VoicemailRequest = - VoicemailRequest(enabled, pin, additionalProperties.toMutableMap()) + VoicemailRequest(enabled, greeting, pin, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -157,6 +198,7 @@ private constructor( } enabled() + greeting().ifPresent { it.validate() } pin() validated = true } @@ -176,7 +218,359 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (enabled.asKnown().isPresent) 1 else 0) + (if (pin.asKnown().isPresent) 1 else 0) + (if (enabled.asKnown().isPresent) 1 else 0) + + (greeting.asKnown().getOrNull()?.validity() ?: 0) + + (if (pin.asKnown().isPresent) 1 else 0) + + /** + * Controls the greeting a caller hears before leaving a voicemail. Set `mode` to `default` to + * play the standard system greeting, or to `custom_greeting` to play your own audio. When + * `mode` is `custom_greeting`, `media_name` is required and must reference an audio file + * already uploaded to your account through the Media Storage API. + */ + class Greeting + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val mediaName: JsonField, + private val mode: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("media_name") + @ExcludeMissing + mediaName: JsonField = JsonMissing.of(), + @JsonProperty("mode") @ExcludeMissing mode: JsonField = JsonMissing.of(), + ) : this(mediaName, mode, mutableMapOf()) + + /** + * The name of the media file to play as the greeting. Required when `mode` is + * `custom_greeting`; ignored when `mode` is `default`. The value must match the + * `media_name` of a file you previously uploaded with the Media Storage API (`POST + * /v2/media`). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mediaName(): Optional = mediaName.getOptional("media_name") + + /** + * The greeting mode. `default` plays the standard system greeting. `custom_greeting` plays + * the audio referenced by `media_name`. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mode(): Optional = mode.getOptional("mode") + + /** + * Returns the raw JSON value of [mediaName]. + * + * Unlike [mediaName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("media_name") @ExcludeMissing fun _mediaName(): JsonField = mediaName + + /** + * Returns the raw JSON value of [mode]. + * + * Unlike [mode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Greeting]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Greeting]. */ + class Builder internal constructor() { + + private var mediaName: JsonField = JsonMissing.of() + private var mode: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(greeting: Greeting) = apply { + mediaName = greeting.mediaName + mode = greeting.mode + additionalProperties = greeting.additionalProperties.toMutableMap() + } + + /** + * The name of the media file to play as the greeting. Required when `mode` is + * `custom_greeting`; ignored when `mode` is `default`. The value must match the + * `media_name` of a file you previously uploaded with the Media Storage API (`POST + * /v2/media`). + */ + fun mediaName(mediaName: String?) = mediaName(JsonField.ofNullable(mediaName)) + + /** Alias for calling [Builder.mediaName] with `mediaName.orElse(null)`. */ + fun mediaName(mediaName: Optional) = mediaName(mediaName.getOrNull()) + + /** + * Sets [Builder.mediaName] to an arbitrary JSON value. + * + * You should usually call [Builder.mediaName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun mediaName(mediaName: JsonField) = apply { this.mediaName = mediaName } + + /** + * The greeting mode. `default` plays the standard system greeting. `custom_greeting` + * plays the audio referenced by `media_name`. + */ + fun mode(mode: Mode) = mode(JsonField.of(mode)) + + /** + * Sets [Builder.mode] to an arbitrary JSON value. + * + * You should usually call [Builder.mode] with a well-typed [Mode] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun mode(mode: JsonField) = apply { this.mode = mode } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Greeting]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Greeting = Greeting(mediaName, mode, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Greeting = apply { + if (validated) { + return@apply + } + + mediaName() + mode().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (mediaName.asKnown().isPresent) 1 else 0) + + (mode.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The greeting mode. `default` plays the standard system greeting. `custom_greeting` plays + * the audio referenced by `media_name`. + */ + class Mode @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DEFAULT = of("default") + + @JvmField val CUSTOM_GREETING = of("custom_greeting") + + @JvmStatic fun of(value: String) = Mode(JsonField.of(value)) + } + + /** An enum containing [Mode]'s known values. */ + enum class Known { + DEFAULT, + CUSTOM_GREETING, + } + + /** + * An enum containing [Mode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Mode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DEFAULT, + CUSTOM_GREETING, + /** An enum member indicating that [Mode] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DEFAULT -> Value.DEFAULT + CUSTOM_GREETING -> Value.CUSTOM_GREETING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + DEFAULT -> Known.DEFAULT + CUSTOM_GREETING -> Known.CUSTOM_GREETING + else -> throw TelnyxInvalidDataException("Unknown Mode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + TelnyxInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Mode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Mode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Greeting && + mediaName == other.mediaName && + mode == other.mode && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(mediaName, mode, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Greeting{mediaName=$mediaName, mode=$mode, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -185,14 +579,15 @@ private constructor( return other is VoicemailRequest && enabled == other.enabled && + greeting == other.greeting && pin == other.pin && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(enabled, pin, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(enabled, greeting, pin, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "VoicemailRequest{enabled=$enabled, pin=$pin, additionalProperties=$additionalProperties}" + "VoicemailRequest{enabled=$enabled, greeting=$greeting, pin=$pin, additionalProperties=$additionalProperties}" } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailUpdateParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailUpdateParams.kt index 110121556..43fb4c1f2 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailUpdateParams.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailUpdateParams.kt @@ -10,7 +10,12 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** Update voicemail settings for a phone number */ +/** + * Update voicemail settings for a phone number. You can also configure a custom greeting by setting + * the `greeting` object: use `mode` `custom_greeting` together with a `media_name` that points to + * an audio file uploaded through the Media Storage API, or `mode` `default` to use the standard + * system greeting. + */ class VoicemailUpdateParams private constructor( private val phoneNumberId: String?, diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/privatewirelessgateways/PrivateWirelessGatewayStatus.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/privatewirelessgateways/PrivateWirelessGatewayStatus.kt index 58ed6f9a0..55cfece84 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/privatewirelessgateways/PrivateWirelessGatewayStatus.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/privatewirelessgateways/PrivateWirelessGatewayStatus.kt @@ -40,8 +40,8 @@ private constructor( /** * This attribute is an - * [error code](https://developers.telnyx.com/development/api-fundamentals/api-errors) related - * to the failure reason. + * [error code](https://developers.telnyx.com/docs/development/api-fundamentals/api-errors) + * related to the failure reason. * * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -136,7 +136,7 @@ private constructor( /** * This attribute is an - * [error code](https://developers.telnyx.com/development/api-fundamentals/api-errors) + * [error code](https://developers.telnyx.com/docs/development/api-fundamentals/api-errors) * related to the failure reason. */ fun errorCode(errorCode: String?) = errorCode(JsonField.ofNullable(errorCode)) diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/ActionBulkEnableVoiceParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/ActionBulkEnableVoiceParams.kt index c801e8fd4..cba362d01 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/ActionBulkEnableVoiceParams.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/ActionBulkEnableVoiceParams.kt @@ -16,6 +16,7 @@ import com.telnyx.sdk.core.http.QueryParams import com.telnyx.sdk.errors.TelnyxInvalidDataException import java.util.Collections import java.util.Objects +import java.util.Optional /** * This API triggers an asynchronous operation to enable voice on SIM cards belonging to a specified @@ -41,6 +42,16 @@ private constructor( */ fun simCardGroupId(): String = body.simCardGroupId() + /** + * The identifier of the Mobile Voice Connection to associate with the SIM cards. The connection + * must be owned by the same user and of type mobile_voice. If omitted, voice is + * enabled without a connection association. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun connectionId(): Optional = body.connectionId() + /** * Returns the raw JSON value of [simCardGroupId]. * @@ -48,6 +59,13 @@ private constructor( */ fun _simCardGroupId(): JsonField = body._simCardGroupId() + /** + * Returns the raw JSON value of [connectionId]. + * + * Unlike [connectionId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _connectionId(): JsonField = body._connectionId() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -92,6 +110,7 @@ private constructor( * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: * - [simCardGroupId] + * - [connectionId] */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -108,6 +127,24 @@ private constructor( body.simCardGroupId(simCardGroupId) } + /** + * The identifier of the Mobile Voice Connection to associate with the SIM cards. The + * connection must be owned by the same user and of type mobile_voice. If + * omitted, voice is enabled without a connection association. + */ + fun connectionId(connectionId: String) = apply { body.connectionId(connectionId) } + + /** + * Sets [Builder.connectionId] to an arbitrary JSON value. + * + * You should usually call [Builder.connectionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun connectionId(connectionId: JsonField) = apply { + body.connectionId(connectionId) + } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -256,6 +293,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val simCardGroupId: JsonField, + private val connectionId: JsonField, private val additionalProperties: MutableMap, ) { @@ -263,8 +301,11 @@ private constructor( private constructor( @JsonProperty("sim_card_group_id") @ExcludeMissing - simCardGroupId: JsonField = JsonMissing.of() - ) : this(simCardGroupId, mutableMapOf()) + simCardGroupId: JsonField = JsonMissing.of(), + @JsonProperty("connection_id") + @ExcludeMissing + connectionId: JsonField = JsonMissing.of(), + ) : this(simCardGroupId, connectionId, mutableMapOf()) /** * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is @@ -272,6 +313,16 @@ private constructor( */ fun simCardGroupId(): String = simCardGroupId.getRequired("sim_card_group_id") + /** + * The identifier of the Mobile Voice Connection to associate with the SIM cards. The + * connection must be owned by the same user and of type mobile_voice. If + * omitted, voice is enabled without a connection association. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun connectionId(): Optional = connectionId.getOptional("connection_id") + /** * Returns the raw JSON value of [simCardGroupId]. * @@ -282,6 +333,16 @@ private constructor( @ExcludeMissing fun _simCardGroupId(): JsonField = simCardGroupId + /** + * Returns the raw JSON value of [connectionId]. + * + * Unlike [connectionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("connection_id") + @ExcludeMissing + fun _connectionId(): JsonField = connectionId + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -311,11 +372,13 @@ private constructor( class Builder internal constructor() { private var simCardGroupId: JsonField? = null + private var connectionId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { simCardGroupId = body.simCardGroupId + connectionId = body.connectionId additionalProperties = body.additionalProperties.toMutableMap() } @@ -333,6 +396,24 @@ private constructor( this.simCardGroupId = simCardGroupId } + /** + * The identifier of the Mobile Voice Connection to associate with the SIM cards. The + * connection must be owned by the same user and of type mobile_voice. If + * omitted, voice is enabled without a connection association. + */ + fun connectionId(connectionId: String) = connectionId(JsonField.of(connectionId)) + + /** + * Sets [Builder.connectionId] to an arbitrary JSON value. + * + * You should usually call [Builder.connectionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun connectionId(connectionId: JsonField) = apply { + this.connectionId = connectionId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -367,6 +448,7 @@ private constructor( fun build(): Body = Body( checkRequired("simCardGroupId", simCardGroupId), + connectionId, additionalProperties.toMutableMap(), ) } @@ -388,6 +470,7 @@ private constructor( } simCardGroupId() + connectionId() validated = true } @@ -406,7 +489,9 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = (if (simCardGroupId.asKnown().isPresent) 1 else 0) + internal fun validity(): Int = + (if (simCardGroupId.asKnown().isPresent) 1 else 0) + + (if (connectionId.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -415,15 +500,18 @@ private constructor( return other is Body && simCardGroupId == other.simCardGroupId && + connectionId == other.connectionId && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(simCardGroupId, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(simCardGroupId, connectionId, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "Body{simCardGroupId=$simCardGroupId, additionalProperties=$additionalProperties}" + "Body{simCardGroupId=$simCardGroupId, connectionId=$connectionId, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/ActionDisableVoiceParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/ActionDisableVoiceParams.kt new file mode 100644 index 000000000..aa20511c0 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/ActionDisableVoiceParams.kt @@ -0,0 +1,237 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.simcards.actions + +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * This API disables voice calling on a SIM card. The SIM card will no longer be able to make or + * receive calls.
The API will trigger an asynchronous operation called a SIM Card Action. The + * status of the SIM Card Action can be followed through the + * [List SIM Card Action](https://developers.telnyx.com/api-reference/sim-card-actions/list-sim-card-actions) + * API. + */ +class ActionDisableVoiceParams +private constructor( + private val id: String?, + private val additionalHeaders: com.telnyx.sdk.core.http.Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ActionDisableVoiceParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ActionDisableVoiceParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ActionDisableVoiceParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var additionalHeaders: com.telnyx.sdk.core.http.Headers.Builder = + com.telnyx.sdk.core.http.Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(actionDisableVoiceParams: ActionDisableVoiceParams) = apply { + id = actionDisableVoiceParams.id + additionalHeaders = actionDisableVoiceParams.additionalHeaders.toBuilder() + additionalQueryParams = actionDisableVoiceParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + actionDisableVoiceParams.additionalBodyProperties.toMutableMap() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + fun additionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ActionDisableVoiceParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ActionDisableVoiceParams = + ActionDisableVoiceParams( + id, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + else -> "" + } + + override fun _headers(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ActionDisableVoiceParams && + id == other.id && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(id, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "ActionDisableVoiceParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/ActionDisableVoiceResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/ActionDisableVoiceResponse.kt new file mode 100644 index 000000000..3d653fda0 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/ActionDisableVoiceResponse.kt @@ -0,0 +1,174 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.simcards.actions + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ActionDisableVoiceResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField = JsonMissing.of() + ) : this(data, mutableMapOf()) + + /** + * This object represents a SIM card action. It allows tracking the current status of an + * operation that impacts the SIM card. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ActionDisableVoiceResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ActionDisableVoiceResponse]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(actionDisableVoiceResponse: ActionDisableVoiceResponse) = apply { + data = actionDisableVoiceResponse.data + additionalProperties = actionDisableVoiceResponse.additionalProperties.toMutableMap() + } + + /** + * This object represents a SIM card action. It allows tracking the current status of an + * operation that impacts the SIM card. + */ + fun data(data: WirelessSimCardAction) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [WirelessSimCardAction] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ActionDisableVoiceResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ActionDisableVoiceResponse = + ActionDisableVoiceResponse(data, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ActionDisableVoiceResponse = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (data.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ActionDisableVoiceResponse && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ActionDisableVoiceResponse{data=$data, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/ActionEnableVoiceParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/ActionEnableVoiceParams.kt new file mode 100644 index 000000000..292a53c51 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/ActionEnableVoiceParams.kt @@ -0,0 +1,447 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.simcards.actions + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * This API enables voice calling on a SIM card. When a connection_id is provided, the + * SIM is associated with the specified Mobile Voice Connection. The connection must be owned by the + * same user and of type mobile_voice.
The API will trigger an asynchronous + * operation called a SIM Card Action. The status of the SIM Card Action can be followed through the + * [List SIM Card Action](https://developers.telnyx.com/api-reference/sim-card-actions/list-sim-card-actions) + * API. + */ +class ActionEnableVoiceParams +private constructor( + private val id: String?, + private val body: Body, + private val additionalHeaders: com.telnyx.sdk.core.http.Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** + * The identifier of the Mobile Voice Connection to associate with this SIM card. The connection + * must be owned by the same user and of type mobile_voice. If omitted, voice is + * enabled without a connection association. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun connectionId(): Optional = body.connectionId() + + /** + * Returns the raw JSON value of [connectionId]. + * + * Unlike [connectionId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _connectionId(): JsonField = body._connectionId() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ActionEnableVoiceParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ActionEnableVoiceParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ActionEnableVoiceParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: com.telnyx.sdk.core.http.Headers.Builder = + com.telnyx.sdk.core.http.Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(actionEnableVoiceParams: ActionEnableVoiceParams) = apply { + id = actionEnableVoiceParams.id + body = actionEnableVoiceParams.body.toBuilder() + additionalHeaders = actionEnableVoiceParams.additionalHeaders.toBuilder() + additionalQueryParams = actionEnableVoiceParams.additionalQueryParams.toBuilder() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [connectionId] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * The identifier of the Mobile Voice Connection to associate with this SIM card. The + * connection must be owned by the same user and of type mobile_voice. If + * omitted, voice is enabled without a connection association. + */ + fun connectionId(connectionId: String) = apply { body.connectionId(connectionId) } + + /** + * Sets [Builder.connectionId] to an arbitrary JSON value. + * + * You should usually call [Builder.connectionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun connectionId(connectionId: JsonField) = apply { + body.connectionId(connectionId) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ActionEnableVoiceParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ActionEnableVoiceParams = + ActionEnableVoiceParams( + id, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + else -> "" + } + + override fun _headers(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val connectionId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("connection_id") + @ExcludeMissing + connectionId: JsonField = JsonMissing.of() + ) : this(connectionId, mutableMapOf()) + + /** + * The identifier of the Mobile Voice Connection to associate with this SIM card. The + * connection must be owned by the same user and of type mobile_voice. If + * omitted, voice is enabled without a connection association. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun connectionId(): Optional = connectionId.getOptional("connection_id") + + /** + * Returns the raw JSON value of [connectionId]. + * + * Unlike [connectionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("connection_id") + @ExcludeMissing + fun _connectionId(): JsonField = connectionId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var connectionId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + connectionId = body.connectionId + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * The identifier of the Mobile Voice Connection to associate with this SIM card. The + * connection must be owned by the same user and of type mobile_voice. If + * omitted, voice is enabled without a connection association. + */ + fun connectionId(connectionId: String) = connectionId(JsonField.of(connectionId)) + + /** + * Sets [Builder.connectionId] to an arbitrary JSON value. + * + * You should usually call [Builder.connectionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun connectionId(connectionId: JsonField) = apply { + this.connectionId = connectionId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(connectionId, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + connectionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (connectionId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + connectionId == other.connectionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(connectionId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{connectionId=$connectionId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ActionEnableVoiceParams && + id == other.id && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(id, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ActionEnableVoiceParams{id=$id, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/ActionEnableVoiceResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/ActionEnableVoiceResponse.kt new file mode 100644 index 000000000..fe0b35d4d --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/ActionEnableVoiceResponse.kt @@ -0,0 +1,174 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.simcards.actions + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ActionEnableVoiceResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField = JsonMissing.of() + ) : this(data, mutableMapOf()) + + /** + * This object represents a SIM card action. It allows tracking the current status of an + * operation that impacts the SIM card. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ActionEnableVoiceResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ActionEnableVoiceResponse]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(actionEnableVoiceResponse: ActionEnableVoiceResponse) = apply { + data = actionEnableVoiceResponse.data + additionalProperties = actionEnableVoiceResponse.additionalProperties.toMutableMap() + } + + /** + * This object represents a SIM card action. It allows tracking the current status of an + * operation that impacts the SIM card. + */ + fun data(data: WirelessSimCardAction) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [WirelessSimCardAction] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ActionEnableVoiceResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ActionEnableVoiceResponse = + ActionEnableVoiceResponse(data, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ActionEnableVoiceResponse = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (data.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ActionEnableVoiceResponse && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ActionEnableVoiceResponse{data=$data, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/ActionListParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/ActionListParams.kt index 28f50cbee..6a5aee6de 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/ActionListParams.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/ActionListParams.kt @@ -417,6 +417,10 @@ private constructor( @JvmField val SET_PUBLIC_IP = of("set_public_ip") + @JvmField val ENABLE_VOICE = of("enable_voice") + + @JvmField val DISABLE_VOICE = of("disable_voice") + @JvmStatic fun of(value: String) = ActionType(JsonField.of(value)) } @@ -428,6 +432,8 @@ private constructor( SET_STANDBY, REMOVE_PUBLIC_IP, SET_PUBLIC_IP, + ENABLE_VOICE, + DISABLE_VOICE, } /** @@ -446,6 +452,8 @@ private constructor( SET_STANDBY, REMOVE_PUBLIC_IP, SET_PUBLIC_IP, + ENABLE_VOICE, + DISABLE_VOICE, /** * An enum member indicating that [ActionType] was instantiated with an unknown * value. @@ -468,6 +476,8 @@ private constructor( SET_STANDBY -> Value.SET_STANDBY REMOVE_PUBLIC_IP -> Value.REMOVE_PUBLIC_IP SET_PUBLIC_IP -> Value.SET_PUBLIC_IP + ENABLE_VOICE -> Value.ENABLE_VOICE + DISABLE_VOICE -> Value.DISABLE_VOICE else -> Value._UNKNOWN } @@ -488,6 +498,8 @@ private constructor( SET_STANDBY -> Known.SET_STANDBY REMOVE_PUBLIC_IP -> Known.REMOVE_PUBLIC_IP SET_PUBLIC_IP -> Known.SET_PUBLIC_IP + ENABLE_VOICE -> Known.ENABLE_VOICE + DISABLE_VOICE -> Known.DISABLE_VOICE else -> throw TelnyxInvalidDataException("Unknown ActionType: $value") } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/WirelessSimCardAction.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/WirelessSimCardAction.kt index da4d61321..339b33fbb 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/WirelessSimCardAction.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/simcards/actions/WirelessSimCardAction.kt @@ -80,6 +80,8 @@ private constructor( * standby status to the enabled status after it consumes data. *
  • disable - move the SIM card to the disabled status
  • *
  • set_standby - move the SIM card to the standby status
  • + *
  • enable_voice - enable voice calling on the SIM card
  • + *
  • disable_voice - disable voice calling on the SIM card
  • * * * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -253,6 +255,8 @@ private constructor( * data. *
  • disable - move the SIM card to the disabled status
  • *
  • set_standby - move the SIM card to the standby status
  • + *
  • enable_voice - enable voice calling on the SIM card
  • + *
  • disable_voice - disable voice calling on the SIM card
  • * */ fun actionType(actionType: ActionType) = actionType(JsonField.of(actionType)) @@ -434,6 +438,8 @@ private constructor( * standby status to the enabled status after it consumes data. *
  • disable - move the SIM card to the disabled status
  • *
  • set_standby - move the SIM card to the standby status
  • + *
  • enable_voice - enable voice calling on the SIM card
  • + *
  • disable_voice - disable voice calling on the SIM card
  • * */ class ActionType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -458,6 +464,10 @@ private constructor( @JvmField val SET_STANDBY = of("set_standby") + @JvmField val ENABLE_VOICE = of("enable_voice") + + @JvmField val DISABLE_VOICE = of("disable_voice") + @JvmStatic fun of(value: String) = ActionType(JsonField.of(value)) } @@ -467,6 +477,8 @@ private constructor( ENABLE_STANDBY_SIM_CARD, DISABLE, SET_STANDBY, + ENABLE_VOICE, + DISABLE_VOICE, } /** @@ -483,6 +495,8 @@ private constructor( ENABLE_STANDBY_SIM_CARD, DISABLE, SET_STANDBY, + ENABLE_VOICE, + DISABLE_VOICE, /** * An enum member indicating that [ActionType] was instantiated with an unknown value. */ @@ -502,6 +516,8 @@ private constructor( ENABLE_STANDBY_SIM_CARD -> Value.ENABLE_STANDBY_SIM_CARD DISABLE -> Value.DISABLE SET_STANDBY -> Value.SET_STANDBY + ENABLE_VOICE -> Value.ENABLE_VOICE + DISABLE_VOICE -> Value.DISABLE_VOICE else -> Value._UNKNOWN } @@ -520,6 +536,8 @@ private constructor( ENABLE_STANDBY_SIM_CARD -> Known.ENABLE_STANDBY_SIM_CARD DISABLE -> Known.DISABLE SET_STANDBY -> Known.SET_STANDBY + ENABLE_VOICE -> Known.ENABLE_VOICE + DISABLE_VOICE -> Known.DISABLE_VOICE else -> throw TelnyxInvalidDataException("Unknown ActionType: $value") } diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/kvs/EdgeComputePaginationMeta.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/kvs/EdgeComputePaginationMeta.kt new file mode 100644 index 000000000..f8e3eb941 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/kvs/EdgeComputePaginationMeta.kt @@ -0,0 +1,268 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.kvs + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +class EdgeComputePaginationMeta +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val pageNumber: JsonField, + private val pageSize: JsonField, + private val totalPages: JsonField, + private val totalResults: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("page_number") @ExcludeMissing pageNumber: JsonField = JsonMissing.of(), + @JsonProperty("page_size") @ExcludeMissing pageSize: JsonField = JsonMissing.of(), + @JsonProperty("total_pages") @ExcludeMissing totalPages: JsonField = JsonMissing.of(), + @JsonProperty("total_results") + @ExcludeMissing + totalResults: JsonField = JsonMissing.of(), + ) : this(pageNumber, pageSize, totalPages, totalResults, mutableMapOf()) + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pageNumber(): Optional = pageNumber.getOptional("page_number") + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pageSize(): Optional = pageSize.getOptional("page_size") + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun totalPages(): Optional = totalPages.getOptional("total_pages") + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun totalResults(): Optional = totalResults.getOptional("total_results") + + /** + * Returns the raw JSON value of [pageNumber]. + * + * Unlike [pageNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("page_number") @ExcludeMissing fun _pageNumber(): JsonField = pageNumber + + /** + * Returns the raw JSON value of [pageSize]. + * + * Unlike [pageSize], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("page_size") @ExcludeMissing fun _pageSize(): JsonField = pageSize + + /** + * Returns the raw JSON value of [totalPages]. + * + * Unlike [totalPages], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_pages") @ExcludeMissing fun _totalPages(): JsonField = totalPages + + /** + * Returns the raw JSON value of [totalResults]. + * + * Unlike [totalResults], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_results") + @ExcludeMissing + fun _totalResults(): JsonField = totalResults + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [EdgeComputePaginationMeta]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EdgeComputePaginationMeta]. */ + class Builder internal constructor() { + + private var pageNumber: JsonField = JsonMissing.of() + private var pageSize: JsonField = JsonMissing.of() + private var totalPages: JsonField = JsonMissing.of() + private var totalResults: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(edgeComputePaginationMeta: EdgeComputePaginationMeta) = apply { + pageNumber = edgeComputePaginationMeta.pageNumber + pageSize = edgeComputePaginationMeta.pageSize + totalPages = edgeComputePaginationMeta.totalPages + totalResults = edgeComputePaginationMeta.totalResults + additionalProperties = edgeComputePaginationMeta.additionalProperties.toMutableMap() + } + + fun pageNumber(pageNumber: Long) = pageNumber(JsonField.of(pageNumber)) + + /** + * Sets [Builder.pageNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.pageNumber] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun pageNumber(pageNumber: JsonField) = apply { this.pageNumber = pageNumber } + + fun pageSize(pageSize: Long) = pageSize(JsonField.of(pageSize)) + + /** + * Sets [Builder.pageSize] to an arbitrary JSON value. + * + * You should usually call [Builder.pageSize] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun pageSize(pageSize: JsonField) = apply { this.pageSize = pageSize } + + fun totalPages(totalPages: Long) = totalPages(JsonField.of(totalPages)) + + /** + * Sets [Builder.totalPages] to an arbitrary JSON value. + * + * You should usually call [Builder.totalPages] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun totalPages(totalPages: JsonField) = apply { this.totalPages = totalPages } + + fun totalResults(totalResults: Long) = totalResults(JsonField.of(totalResults)) + + /** + * Sets [Builder.totalResults] to an arbitrary JSON value. + * + * You should usually call [Builder.totalResults] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalResults(totalResults: JsonField) = apply { this.totalResults = totalResults } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EdgeComputePaginationMeta]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): EdgeComputePaginationMeta = + EdgeComputePaginationMeta( + pageNumber, + pageSize, + totalPages, + totalResults, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): EdgeComputePaginationMeta = apply { + if (validated) { + return@apply + } + + pageNumber() + pageSize() + totalPages() + totalResults() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (pageNumber.asKnown().isPresent) 1 else 0) + + (if (pageSize.asKnown().isPresent) 1 else 0) + + (if (totalPages.asKnown().isPresent) 1 else 0) + + (if (totalResults.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EdgeComputePaginationMeta && + pageNumber == other.pageNumber && + pageSize == other.pageSize && + totalPages == other.totalPages && + totalResults == other.totalResults && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(pageNumber, pageSize, totalPages, totalResults, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EdgeComputePaginationMeta{pageNumber=$pageNumber, pageSize=$pageSize, totalPages=$totalPages, totalResults=$totalResults, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/kvs/KvListPage.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/kvs/KvListPage.kt index 8cd73a97e..21bc2da9b 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/kvs/KvListPage.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/kvs/KvListPage.kt @@ -31,7 +31,7 @@ private constructor( * * @see KvListPageResponse.meta */ - fun meta(): Optional = response._meta().getOptional("meta") + fun meta(): Optional = response._meta().getOptional("meta") override fun items(): List = data() diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/kvs/KvListPageAsync.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/kvs/KvListPageAsync.kt index 8c98c079d..bfe9a169b 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/kvs/KvListPageAsync.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/kvs/KvListPageAsync.kt @@ -34,7 +34,7 @@ private constructor( * * @see KvListPageResponse.meta */ - fun meta(): Optional = response._meta().getOptional("meta") + fun meta(): Optional = response._meta().getOptional("meta") override fun items(): List = data() diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/kvs/KvListPageResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/kvs/KvListPageResponse.kt index 9efdeb813..f8df78eb5 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/kvs/KvListPageResponse.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/kvs/KvListPageResponse.kt @@ -22,14 +22,16 @@ class KvListPageResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val data: JsonField>, - private val meta: JsonField, + private val meta: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("data") @ExcludeMissing data: JsonField> = JsonMissing.of(), - @JsonProperty("meta") @ExcludeMissing meta: JsonField = JsonMissing.of(), + @JsonProperty("meta") + @ExcludeMissing + meta: JsonField = JsonMissing.of(), ) : this(data, meta, mutableMapOf()) /** @@ -42,7 +44,7 @@ private constructor( * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun meta(): Optional = meta.getOptional("meta") + fun meta(): Optional = meta.getOptional("meta") /** * Returns the raw JSON value of [data]. @@ -56,7 +58,7 @@ private constructor( * * Unlike [meta], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("meta") @ExcludeMissing fun _meta(): JsonField = meta + @JsonProperty("meta") @ExcludeMissing fun _meta(): JsonField = meta @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -80,7 +82,7 @@ private constructor( class Builder internal constructor() { private var data: JsonField>? = null - private var meta: JsonField = JsonMissing.of() + private var meta: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -115,15 +117,16 @@ private constructor( } } - fun meta(meta: Meta) = meta(JsonField.of(meta)) + fun meta(meta: EdgeComputePaginationMeta) = meta(JsonField.of(meta)) /** * Sets [Builder.meta] to an arbitrary JSON value. * - * You should usually call [Builder.meta] with a well-typed [Meta] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.meta] with a well-typed [EdgeComputePaginationMeta] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun meta(meta: JsonField) = apply { this.meta = meta } + fun meta(meta: JsonField) = apply { this.meta = meta } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -195,268 +198,6 @@ private constructor( (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (meta.asKnown().getOrNull()?.validity() ?: 0) - class Meta - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val pageNumber: JsonField, - private val pageSize: JsonField, - private val totalPages: JsonField, - private val totalResults: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("page_number") - @ExcludeMissing - pageNumber: JsonField = JsonMissing.of(), - @JsonProperty("page_size") @ExcludeMissing pageSize: JsonField = JsonMissing.of(), - @JsonProperty("total_pages") - @ExcludeMissing - totalPages: JsonField = JsonMissing.of(), - @JsonProperty("total_results") - @ExcludeMissing - totalResults: JsonField = JsonMissing.of(), - ) : this(pageNumber, pageSize, totalPages, totalResults, mutableMapOf()) - - /** - * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun pageNumber(): Optional = pageNumber.getOptional("page_number") - - /** - * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun pageSize(): Optional = pageSize.getOptional("page_size") - - /** - * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun totalPages(): Optional = totalPages.getOptional("total_pages") - - /** - * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun totalResults(): Optional = totalResults.getOptional("total_results") - - /** - * Returns the raw JSON value of [pageNumber]. - * - * Unlike [pageNumber], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("page_number") @ExcludeMissing fun _pageNumber(): JsonField = pageNumber - - /** - * Returns the raw JSON value of [pageSize]. - * - * Unlike [pageSize], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("page_size") @ExcludeMissing fun _pageSize(): JsonField = pageSize - - /** - * Returns the raw JSON value of [totalPages]. - * - * Unlike [totalPages], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("total_pages") @ExcludeMissing fun _totalPages(): JsonField = totalPages - - /** - * Returns the raw JSON value of [totalResults]. - * - * Unlike [totalResults], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("total_results") - @ExcludeMissing - fun _totalResults(): JsonField = totalResults - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Meta]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Meta]. */ - class Builder internal constructor() { - - private var pageNumber: JsonField = JsonMissing.of() - private var pageSize: JsonField = JsonMissing.of() - private var totalPages: JsonField = JsonMissing.of() - private var totalResults: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(meta: Meta) = apply { - pageNumber = meta.pageNumber - pageSize = meta.pageSize - totalPages = meta.totalPages - totalResults = meta.totalResults - additionalProperties = meta.additionalProperties.toMutableMap() - } - - fun pageNumber(pageNumber: Long) = pageNumber(JsonField.of(pageNumber)) - - /** - * Sets [Builder.pageNumber] to an arbitrary JSON value. - * - * You should usually call [Builder.pageNumber] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun pageNumber(pageNumber: JsonField) = apply { this.pageNumber = pageNumber } - - fun pageSize(pageSize: Long) = pageSize(JsonField.of(pageSize)) - - /** - * Sets [Builder.pageSize] to an arbitrary JSON value. - * - * You should usually call [Builder.pageSize] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun pageSize(pageSize: JsonField) = apply { this.pageSize = pageSize } - - fun totalPages(totalPages: Long) = totalPages(JsonField.of(totalPages)) - - /** - * Sets [Builder.totalPages] to an arbitrary JSON value. - * - * You should usually call [Builder.totalPages] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun totalPages(totalPages: JsonField) = apply { this.totalPages = totalPages } - - fun totalResults(totalResults: Long) = totalResults(JsonField.of(totalResults)) - - /** - * Sets [Builder.totalResults] to an arbitrary JSON value. - * - * You should usually call [Builder.totalResults] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun totalResults(totalResults: JsonField) = apply { - this.totalResults = totalResults - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Meta]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Meta = - Meta( - pageNumber, - pageSize, - totalPages, - totalResults, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws TelnyxInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): Meta = apply { - if (validated) { - return@apply - } - - pageNumber() - pageSize() - totalPages() - totalResults() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: TelnyxInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (pageNumber.asKnown().isPresent) 1 else 0) + - (if (pageSize.asKnown().isPresent) 1 else 0) + - (if (totalPages.asKnown().isPresent) 1 else 0) + - (if (totalResults.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Meta && - pageNumber == other.pageNumber && - pageSize == other.pageSize && - totalPages == other.totalPages && - totalResults == other.totalResults && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(pageNumber, pageSize, totalPages, totalResults, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Meta{pageNumber=$pageNumber, pageSize=$pageSize, totalPages=$totalPages, totalResults=$totalResults, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqlDatabase.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqlDatabase.kt new file mode 100644 index 000000000..c781d31f1 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqlDatabase.kt @@ -0,0 +1,502 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.sqldbs + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.telnyx.sdk.core.Enum +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class SqlDatabase +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val name: JsonField, + private val recordType: JsonField, + private val status: JsonField, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("record_type") + @ExcludeMissing + recordType: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this(id, createdAt, name, recordType, status, updatedAt, mutableMapOf()) + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun createdAt(): Optional = createdAt.getOptional("created_at") + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun recordType(): Optional = recordType.getOptional("record_type") + + /** + * Provisioning status. A database is usable once `status` is `provision_ok`. Once deletion + * completes, the database no longer appears in the API. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun updatedAt(): Optional = updatedAt.getOptional("updated_at") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [recordType]. + * + * Unlike [recordType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("record_type") @ExcludeMissing fun _recordType(): JsonField = recordType + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [SqlDatabase]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SqlDatabase]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var recordType: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(sqlDatabase: SqlDatabase) = apply { + id = sqlDatabase.id + createdAt = sqlDatabase.createdAt + name = sqlDatabase.name + recordType = sqlDatabase.recordType + status = sqlDatabase.status + updatedAt = sqlDatabase.updatedAt + additionalProperties = sqlDatabase.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun recordType(recordType: String) = recordType(JsonField.of(recordType)) + + /** + * Sets [Builder.recordType] to an arbitrary JSON value. + * + * You should usually call [Builder.recordType] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun recordType(recordType: JsonField) = apply { this.recordType = recordType } + + /** + * Provisioning status. A database is usable once `status` is `provision_ok`. Once deletion + * completes, the database no longer appears in the API. + */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SqlDatabase]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SqlDatabase = + SqlDatabase( + id, + createdAt, + name, + recordType, + status, + updatedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): SqlDatabase = apply { + if (validated) { + return@apply + } + + id() + createdAt() + name() + recordType() + status().ifPresent { it.validate() } + updatedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (recordType.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + /** + * Provisioning status. A database is usable once `status` is `provision_ok`. Once deletion + * completes, the database no longer appears in the API. + */ + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PENDING = of("pending") + + @JvmField val PROVISION_OK = of("provision_ok") + + @JvmField val PROVISION_FAILED = of("provision_failed") + + @JvmField val DELETING = of("deleting") + + @JvmField val DELETE_FAILED = of("delete_failed") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + PENDING, + PROVISION_OK, + PROVISION_FAILED, + DELETING, + DELETE_FAILED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PENDING, + PROVISION_OK, + PROVISION_FAILED, + DELETING, + DELETE_FAILED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PENDING -> Value.PENDING + PROVISION_OK -> Value.PROVISION_OK + PROVISION_FAILED -> Value.PROVISION_FAILED + DELETING -> Value.DELETING + DELETE_FAILED -> Value.DELETE_FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + PROVISION_OK -> Known.PROVISION_OK + PROVISION_FAILED -> Known.PROVISION_FAILED + DELETING -> Known.DELETING + DELETE_FAILED -> Known.DELETE_FAILED + else -> throw TelnyxInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { TelnyxInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SqlDatabase && + id == other.id && + createdAt == other.createdAt && + name == other.name && + recordType == other.recordType && + status == other.status && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, name, recordType, status, updatedAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SqlDatabase{id=$id, createdAt=$createdAt, name=$name, recordType=$recordType, status=$status, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqlDatabaseResponseWrapper.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqlDatabaseResponseWrapper.kt new file mode 100644 index 000000000..c2a6dca01 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqlDatabaseResponseWrapper.kt @@ -0,0 +1,165 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.sqldbs + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class SqlDatabaseResponseWrapper +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of() + ) : this(data, mutableMapOf()) + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SqlDatabaseResponseWrapper]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SqlDatabaseResponseWrapper]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(sqlDatabaseResponseWrapper: SqlDatabaseResponseWrapper) = apply { + data = sqlDatabaseResponseWrapper.data + additionalProperties = sqlDatabaseResponseWrapper.additionalProperties.toMutableMap() + } + + fun data(data: SqlDatabase) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [SqlDatabase] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SqlDatabaseResponseWrapper]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SqlDatabaseResponseWrapper = + SqlDatabaseResponseWrapper(data, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): SqlDatabaseResponseWrapper = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (data.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SqlDatabaseResponseWrapper && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SqlDatabaseResponseWrapper{data=$data, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbCreateParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbCreateParams.kt new file mode 100644 index 000000000..75d733ec8 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbCreateParams.kt @@ -0,0 +1,435 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.sqldbs + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects + +/** + * Creates a new SQL database. Provisioning is asynchronous: the database is returned with status + * `pending` and becomes usable once it reaches `provision_ok`. + */ +class SqldbCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: com.telnyx.sdk.core.http.Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Database name. Lowercase letters, numbers, and hyphens only; must start and end with a letter + * or number. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = body.name() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SqldbCreateParams]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SqldbCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: com.telnyx.sdk.core.http.Headers.Builder = + com.telnyx.sdk.core.http.Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(sqldbCreateParams: SqldbCreateParams) = apply { + body = sqldbCreateParams.body.toBuilder() + additionalHeaders = sqldbCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = sqldbCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [name] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * Database name. Lowercase letters, numbers, and hyphens only; must start and end with a + * letter or number. + */ + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { body.name(name) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SqldbCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SqldbCreateParams = + SqldbCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of() + ) : this(name, mutableMapOf()) + + /** + * Database name. Lowercase letters, numbers, and hyphens only; must start and end with a + * letter or number. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + name = body.name + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * Database name. Lowercase letters, numbers, and hyphens only; must start and end with + * a letter or number. + */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("name", name), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SqldbCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SqldbCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbDeleteParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbDeleteParams.kt new file mode 100644 index 000000000..2b006ee57 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbDeleteParams.kt @@ -0,0 +1,262 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.sqldbs + +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Deletes a SQL database and all of the data it holds. Deletion is asynchronous and returns `202` + * with an empty body — the record is not removed synchronously. Poll `GET /storage/sqldbs/{id}`, + * which returns `404` once the database has been purged; there is no durable `deleted` state. A + * database still bound by a function is refused with `409` unless `force=true`. + */ +class SqldbDeleteParams +private constructor( + private val id: String?, + private val force: Boolean?, + private val additionalHeaders: com.telnyx.sdk.core.http.Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** Delete the database even when functions still bind it. Their bindings stop resolving. */ + fun force(): Optional = Optional.ofNullable(force) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SqldbDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SqldbDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SqldbDeleteParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var force: Boolean? = null + private var additionalHeaders: com.telnyx.sdk.core.http.Headers.Builder = + com.telnyx.sdk.core.http.Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(sqldbDeleteParams: SqldbDeleteParams) = apply { + id = sqldbDeleteParams.id + force = sqldbDeleteParams.force + additionalHeaders = sqldbDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = sqldbDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = sqldbDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + /** Delete the database even when functions still bind it. Their bindings stop resolving. */ + fun force(force: Boolean?) = apply { this.force = force } + + /** + * Alias for [Builder.force]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun force(force: Boolean) = force(force as Boolean?) + + /** Alias for calling [Builder.force] with `force.orElse(null)`. */ + fun force(force: Optional) = force(force.getOrNull()) + + fun additionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [SqldbDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SqldbDeleteParams = + SqldbDeleteParams( + id, + force, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + else -> "" + } + + override fun _headers(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + force?.let { put("force", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SqldbDeleteParams && + id == other.id && + force == other.force && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(id, force, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "SqldbDeleteParams{id=$id, force=$force, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbListPage.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbListPage.kt new file mode 100644 index 000000000..d6a83fc89 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbListPage.kt @@ -0,0 +1,149 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.sqldbs + +import com.telnyx.sdk.core.AutoPager +import com.telnyx.sdk.core.Page +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.models.storage.kvs.EdgeComputePaginationMeta +import com.telnyx.sdk.services.blocking.storage.SqldbService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrDefault +import kotlin.jvm.optionals.getOrNull + +/** @see SqldbService.list */ +class SqldbListPage +private constructor( + private val service: SqldbService, + private val params: SqldbListParams, + private val response: SqldbListPageResponse, +) : Page { + + /** + * Delegates to [SqldbListPageResponse], but gracefully handles missing data. + * + * @see SqldbListPageResponse.data + */ + fun data(): List = response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [SqldbListPageResponse], but gracefully handles missing data. + * + * @see SqldbListPageResponse.meta + */ + fun meta(): Optional = response._meta().getOptional("meta") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean { + if (items().isEmpty()) { + return false + } + + val pageNumber = + response + ._meta() + .getOptional("meta") + .flatMap { it._pageNumber().getOptional("page_number") } + .getOrDefault(1) + val pageCount = + response + ._meta() + .getOptional("meta") + .flatMap { it._totalPages().getOptional("total_pages") } + .getOrNull() + return pageCount == null || pageNumber < pageCount + } + + fun nextPageParams(): SqldbListParams { + val pageNumber = params.pageNumber().getOrDefault(1) + return params.toBuilder().pageNumber(pageNumber + 1).build() + } + + override fun nextPage(): SqldbListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): SqldbListParams = params + + /** The response that this page was parsed from. */ + fun response(): SqldbListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SqldbListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SqldbListPage]. */ + class Builder internal constructor() { + + private var service: SqldbService? = null + private var params: SqldbListParams? = null + private var response: SqldbListPageResponse? = null + + @JvmSynthetic + internal fun from(sqldbListPage: SqldbListPage) = apply { + service = sqldbListPage.service + params = sqldbListPage.params + response = sqldbListPage.response + } + + fun service(service: SqldbService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: SqldbListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: SqldbListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [SqldbListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SqldbListPage = + SqldbListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SqldbListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = "SqldbListPage{service=$service, params=$params, response=$response}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbListPageAsync.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbListPageAsync.kt new file mode 100644 index 000000000..f8d490618 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbListPageAsync.kt @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.sqldbs + +import com.telnyx.sdk.core.AutoPagerAsync +import com.telnyx.sdk.core.PageAsync +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.models.storage.kvs.EdgeComputePaginationMeta +import com.telnyx.sdk.services.async.storage.SqldbServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrDefault +import kotlin.jvm.optionals.getOrNull + +/** @see SqldbServiceAsync.list */ +class SqldbListPageAsync +private constructor( + private val service: SqldbServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: SqldbListParams, + private val response: SqldbListPageResponse, +) : PageAsync { + + /** + * Delegates to [SqldbListPageResponse], but gracefully handles missing data. + * + * @see SqldbListPageResponse.data + */ + fun data(): List = response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [SqldbListPageResponse], but gracefully handles missing data. + * + * @see SqldbListPageResponse.meta + */ + fun meta(): Optional = response._meta().getOptional("meta") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean { + if (items().isEmpty()) { + return false + } + + val pageNumber = + response + ._meta() + .getOptional("meta") + .flatMap { it._pageNumber().getOptional("page_number") } + .getOrDefault(1) + val pageCount = + response + ._meta() + .getOptional("meta") + .flatMap { it._totalPages().getOptional("total_pages") } + .getOrNull() + return pageCount == null || pageNumber < pageCount + } + + fun nextPageParams(): SqldbListParams { + val pageNumber = params.pageNumber().getOrDefault(1) + return params.toBuilder().pageNumber(pageNumber + 1).build() + } + + override fun nextPage(): CompletableFuture = service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): SqldbListParams = params + + /** The response that this page was parsed from. */ + fun response(): SqldbListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SqldbListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SqldbListPageAsync]. */ + class Builder internal constructor() { + + private var service: SqldbServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: SqldbListParams? = null + private var response: SqldbListPageResponse? = null + + @JvmSynthetic + internal fun from(sqldbListPageAsync: SqldbListPageAsync) = apply { + service = sqldbListPageAsync.service + streamHandlerExecutor = sqldbListPageAsync.streamHandlerExecutor + params = sqldbListPageAsync.params + response = sqldbListPageAsync.response + } + + fun service(service: SqldbServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: SqldbListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: SqldbListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [SqldbListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SqldbListPageAsync = + SqldbListPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SqldbListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) + + override fun toString() = + "SqldbListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbListPageResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbListPageResponse.kt new file mode 100644 index 000000000..cbabc3282 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbListPageResponse.kt @@ -0,0 +1,219 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.sqldbs + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.checkKnown +import com.telnyx.sdk.core.toImmutable +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import com.telnyx.sdk.models.storage.kvs.EdgeComputePaginationMeta +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class SqldbListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val meta: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField> = JsonMissing.of(), + @JsonProperty("meta") + @ExcludeMissing + meta: JsonField = JsonMissing.of(), + ) : this(data, meta, mutableMapOf()) + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional> = data.getOptional("data") + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun meta(): Optional = meta.getOptional("meta") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [meta]. + * + * Unlike [meta], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("meta") @ExcludeMissing fun _meta(): JsonField = meta + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [SqldbListPageResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SqldbListPageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var meta: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(sqldbListPageResponse: SqldbListPageResponse) = apply { + data = sqldbListPageResponse.data.map { it.toMutableList() } + meta = sqldbListPageResponse.meta + additionalProperties = sqldbListPageResponse.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [SqlDatabase] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: SqlDatabase) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun meta(meta: EdgeComputePaginationMeta) = meta(JsonField.of(meta)) + + /** + * Sets [Builder.meta] to an arbitrary JSON value. + * + * You should usually call [Builder.meta] with a well-typed [EdgeComputePaginationMeta] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun meta(meta: JsonField) = apply { this.meta = meta } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SqldbListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SqldbListPageResponse = + SqldbListPageResponse( + (data ?: JsonMissing.of()).map { it.toImmutable() }, + meta, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): SqldbListPageResponse = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.forEach { it.validate() } } + meta().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (meta.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SqldbListPageResponse && + data == other.data && + meta == other.meta && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, meta, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SqldbListPageResponse{data=$data, meta=$meta, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbListParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbListParams.kt new file mode 100644 index 000000000..51df082a0 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbListParams.kt @@ -0,0 +1,602 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.sqldbs + +import com.fasterxml.jackson.annotation.JsonCreator +import com.telnyx.sdk.core.Enum +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Lists the SQL databases for the authenticated user's organization. Results use page-based + * pagination (`page[number]`/`page[size]`) and can be filtered and sorted. + */ +class SqldbListParams +private constructor( + private val filterName: String?, + private val filterStatus: FilterStatus?, + private val pageNumber: Long?, + private val pageSize: Long?, + private val sort: Sort?, + private val additionalHeaders: com.telnyx.sdk.core.http.Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Filter by exact name match. */ + fun filterName(): Optional = Optional.ofNullable(filterName) + + /** Filter by provisioning status. */ + fun filterStatus(): Optional = Optional.ofNullable(filterStatus) + + /** The page number to load. */ + fun pageNumber(): Optional = Optional.ofNullable(pageNumber) + + /** The size of the page. Values above 250 are treated as 250. */ + fun pageSize(): Optional = Optional.ofNullable(pageSize) + + /** Sort field; prefix with `-` for descending order. */ + fun sort(): Optional = Optional.ofNullable(sort) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SqldbListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SqldbListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SqldbListParams]. */ + class Builder internal constructor() { + + private var filterName: String? = null + private var filterStatus: FilterStatus? = null + private var pageNumber: Long? = null + private var pageSize: Long? = null + private var sort: Sort? = null + private var additionalHeaders: com.telnyx.sdk.core.http.Headers.Builder = + com.telnyx.sdk.core.http.Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(sqldbListParams: SqldbListParams) = apply { + filterName = sqldbListParams.filterName + filterStatus = sqldbListParams.filterStatus + pageNumber = sqldbListParams.pageNumber + pageSize = sqldbListParams.pageSize + sort = sqldbListParams.sort + additionalHeaders = sqldbListParams.additionalHeaders.toBuilder() + additionalQueryParams = sqldbListParams.additionalQueryParams.toBuilder() + } + + /** Filter by exact name match. */ + fun filterName(filterName: String?) = apply { this.filterName = filterName } + + /** Alias for calling [Builder.filterName] with `filterName.orElse(null)`. */ + fun filterName(filterName: Optional) = filterName(filterName.getOrNull()) + + /** Filter by provisioning status. */ + fun filterStatus(filterStatus: FilterStatus?) = apply { this.filterStatus = filterStatus } + + /** Alias for calling [Builder.filterStatus] with `filterStatus.orElse(null)`. */ + fun filterStatus(filterStatus: Optional) = + filterStatus(filterStatus.getOrNull()) + + /** The page number to load. */ + fun pageNumber(pageNumber: Long?) = apply { this.pageNumber = pageNumber } + + /** + * Alias for [Builder.pageNumber]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun pageNumber(pageNumber: Long) = pageNumber(pageNumber as Long?) + + /** Alias for calling [Builder.pageNumber] with `pageNumber.orElse(null)`. */ + fun pageNumber(pageNumber: Optional) = pageNumber(pageNumber.getOrNull()) + + /** The size of the page. Values above 250 are treated as 250. */ + fun pageSize(pageSize: Long?) = apply { this.pageSize = pageSize } + + /** + * Alias for [Builder.pageSize]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun pageSize(pageSize: Long) = pageSize(pageSize as Long?) + + /** Alias for calling [Builder.pageSize] with `pageSize.orElse(null)`. */ + fun pageSize(pageSize: Optional) = pageSize(pageSize.getOrNull()) + + /** Sort field; prefix with `-` for descending order. */ + fun sort(sort: Sort?) = apply { this.sort = sort } + + /** Alias for calling [Builder.sort] with `sort.orElse(null)`. */ + fun sort(sort: Optional) = sort(sort.getOrNull()) + + fun additionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SqldbListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SqldbListParams = + SqldbListParams( + filterName, + filterStatus, + pageNumber, + pageSize, + sort, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + filterName?.let { put("filter[name]", it) } + filterStatus?.let { put("filter[status]", it.toString()) } + pageNumber?.let { put("page[number]", it.toString()) } + pageSize?.let { put("page[size]", it.toString()) } + sort?.let { put("sort", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + /** Filter by provisioning status. */ + class FilterStatus @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PENDING = of("pending") + + @JvmField val PROVISION_OK = of("provision_ok") + + @JvmField val PROVISION_FAILED = of("provision_failed") + + @JvmField val DELETING = of("deleting") + + @JvmField val DELETE_FAILED = of("delete_failed") + + @JvmStatic fun of(value: String) = FilterStatus(JsonField.of(value)) + } + + /** An enum containing [FilterStatus]'s known values. */ + enum class Known { + PENDING, + PROVISION_OK, + PROVISION_FAILED, + DELETING, + DELETE_FAILED, + } + + /** + * An enum containing [FilterStatus]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FilterStatus] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PENDING, + PROVISION_OK, + PROVISION_FAILED, + DELETING, + DELETE_FAILED, + /** + * An enum member indicating that [FilterStatus] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PENDING -> Value.PENDING + PROVISION_OK -> Value.PROVISION_OK + PROVISION_FAILED -> Value.PROVISION_FAILED + DELETING -> Value.DELETING + DELETE_FAILED -> Value.DELETE_FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + PROVISION_OK -> Known.PROVISION_OK + PROVISION_FAILED -> Known.PROVISION_FAILED + DELETING -> Known.DELETING + DELETE_FAILED -> Known.DELETE_FAILED + else -> throw TelnyxInvalidDataException("Unknown FilterStatus: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { TelnyxInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): FilterStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FilterStatus && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Sort field; prefix with `-` for descending order. */ + class Sort @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val NAME = of("name") + + @JvmField val NAME_DESC = of("-name") + + @JvmField val STATUS = of("status") + + @JvmField val STATUS_DESC = of("-status") + + @JvmField val CREATED_AT = of("created_at") + + @JvmField val CREATED_AT_DESC = of("-created_at") + + @JvmStatic fun of(value: String) = Sort(JsonField.of(value)) + } + + /** An enum containing [Sort]'s known values. */ + enum class Known { + NAME, + NAME_DESC, + STATUS, + STATUS_DESC, + CREATED_AT, + CREATED_AT_DESC, + } + + /** + * An enum containing [Sort]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Sort] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NAME, + NAME_DESC, + STATUS, + STATUS_DESC, + CREATED_AT, + CREATED_AT_DESC, + /** An enum member indicating that [Sort] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NAME -> Value.NAME + NAME_DESC -> Value.NAME_DESC + STATUS -> Value.STATUS + STATUS_DESC -> Value.STATUS_DESC + CREATED_AT -> Value.CREATED_AT + CREATED_AT_DESC -> Value.CREATED_AT_DESC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + NAME -> Known.NAME + NAME_DESC -> Known.NAME_DESC + STATUS -> Known.STATUS + STATUS_DESC -> Known.STATUS_DESC + CREATED_AT -> Known.CREATED_AT + CREATED_AT_DESC -> Known.CREATED_AT_DESC + else -> throw TelnyxInvalidDataException("Unknown Sort: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { TelnyxInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Sort = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Sort && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SqldbListParams && + filterName == other.filterName && + filterStatus == other.filterStatus && + pageNumber == other.pageNumber && + pageSize == other.pageSize && + sort == other.sort && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + filterName, + filterStatus, + pageNumber, + pageSize, + sort, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "SqldbListParams{filterName=$filterName, filterStatus=$filterStatus, pageNumber=$pageNumber, pageSize=$pageSize, sort=$sort, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbRetrieveParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbRetrieveParams.kt new file mode 100644 index 000000000..7c5416f0f --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbRetrieveParams.kt @@ -0,0 +1,190 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.sqldbs + +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Retrieves a SQL database by its ID, including its provisioning status. */ +class SqldbRetrieveParams +private constructor( + private val id: String?, + private val additionalHeaders: com.telnyx.sdk.core.http.Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SqldbRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SqldbRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SqldbRetrieveParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var additionalHeaders: com.telnyx.sdk.core.http.Headers.Builder = + com.telnyx.sdk.core.http.Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(sqldbRetrieveParams: SqldbRetrieveParams) = apply { + id = sqldbRetrieveParams.id + additionalHeaders = sqldbRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = sqldbRetrieveParams.additionalQueryParams.toBuilder() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + fun additionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SqldbRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SqldbRetrieveParams = + SqldbRetrieveParams(id, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + else -> "" + } + + override fun _headers(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SqldbRetrieveParams && + id == other.id && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(id, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SqldbRetrieveParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/actions/ActionQueryParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/actions/ActionQueryParams.kt new file mode 100644 index 000000000..d12d38ac2 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/actions/ActionQueryParams.kt @@ -0,0 +1,863 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.sqldbs.actions + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.BaseDeserializer +import com.telnyx.sdk.core.BaseSerializer +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.allMaxBy +import com.telnyx.sdk.core.checkKnown +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.getOrThrow +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.core.toImmutable +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Runs SQL against the database and returns the resulting rows — empty for statements that return + * none, such as DDL. Bind positional `?` placeholders with `params` rather than interpolating + * values into the SQL string. + */ +class ActionQueryParams +private constructor( + private val id: String?, + private val body: Body, + private val additionalHeaders: com.telnyx.sdk.core.http.Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** + * The SQL to run. Use positional `?` placeholders and supply the values in `params` rather than + * interpolating them into this string. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sql(): String = body.sql() + + /** + * Positional bind parameters, in placeholder order. Each value is a string, a number, a + * boolean, or null; booleans are cast to `1`/`0`. The count must match the number of `?` + * placeholders exactly — a mismatch is rejected with 422 rather than binding null for the ones + * you left out. (Not enforced for multi-statement scripts or named parameters, where the + * placeholder count is not the number bound.) + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun params(): Optional> = body.params() + + /** + * Returns the raw JSON value of [sql]. + * + * Unlike [sql], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _sql(): JsonField = body._sql() + + /** + * Returns the raw JSON value of [params]. + * + * Unlike [params], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _params(): JsonField> = body._params() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ActionQueryParams]. + * + * The following fields are required: + * ```java + * .sql() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ActionQueryParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: com.telnyx.sdk.core.http.Headers.Builder = + com.telnyx.sdk.core.http.Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(actionQueryParams: ActionQueryParams) = apply { + id = actionQueryParams.id + body = actionQueryParams.body.toBuilder() + additionalHeaders = actionQueryParams.additionalHeaders.toBuilder() + additionalQueryParams = actionQueryParams.additionalQueryParams.toBuilder() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [sql] + * - [params] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * The SQL to run. Use positional `?` placeholders and supply the values in `params` rather + * than interpolating them into this string. + */ + fun sql(sql: String) = apply { body.sql(sql) } + + /** + * Sets [Builder.sql] to an arbitrary JSON value. + * + * You should usually call [Builder.sql] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun sql(sql: JsonField) = apply { body.sql(sql) } + + /** + * Positional bind parameters, in placeholder order. Each value is a string, a number, a + * boolean, or null; booleans are cast to `1`/`0`. The count must match the number of `?` + * placeholders exactly — a mismatch is rejected with 422 rather than binding null for the + * ones you left out. (Not enforced for multi-statement scripts or named parameters, where + * the placeholder count is not the number bound.) + */ + fun params(params: List) = apply { body.params(params) } + + /** + * Sets [Builder.params] to an arbitrary JSON value. + * + * You should usually call [Builder.params] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun params(params: JsonField>) = apply { body.params(params) } + + /** + * Adds a single [Param] to [params]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addParam(param: Param) = apply { body.addParam(param) } + + /** Alias for calling [addParam] with `Param.ofString(string)`. */ + fun addParam(string: String) = apply { body.addParam(string) } + + /** Alias for calling [addParam] with `Param.ofNumber(number)`. */ + fun addParam(number: Double) = apply { body.addParam(number) } + + /** Alias for calling [addParam] with `Param.ofBool(bool)`. */ + fun addParam(bool: Boolean) = apply { body.addParam(bool) } + + /** Alias for calling [addParam] with `Param.ofNull()`. */ + fun addParamNull() = apply { body.addParamNull() } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ActionQueryParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sql() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ActionQueryParams = + ActionQueryParams( + id, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + else -> "" + } + + override fun _headers(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val sql: JsonField, + private val params: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("sql") @ExcludeMissing sql: JsonField = JsonMissing.of(), + @JsonProperty("params") + @ExcludeMissing + params: JsonField> = JsonMissing.of(), + ) : this(sql, params, mutableMapOf()) + + /** + * The SQL to run. Use positional `?` placeholders and supply the values in `params` rather + * than interpolating them into this string. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sql(): String = sql.getRequired("sql") + + /** + * Positional bind parameters, in placeholder order. Each value is a string, a number, a + * boolean, or null; booleans are cast to `1`/`0`. The count must match the number of `?` + * placeholders exactly — a mismatch is rejected with 422 rather than binding null for the + * ones you left out. (Not enforced for multi-statement scripts or named parameters, where + * the placeholder count is not the number bound.) + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun params(): Optional> = params.getOptional("params") + + /** + * Returns the raw JSON value of [sql]. + * + * Unlike [sql], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sql") @ExcludeMissing fun _sql(): JsonField = sql + + /** + * Returns the raw JSON value of [params]. + * + * Unlike [params], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("params") @ExcludeMissing fun _params(): JsonField> = params + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .sql() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var sql: JsonField? = null + private var params: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + sql = body.sql + params = body.params.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * The SQL to run. Use positional `?` placeholders and supply the values in `params` + * rather than interpolating them into this string. + */ + fun sql(sql: String) = sql(JsonField.of(sql)) + + /** + * Sets [Builder.sql] to an arbitrary JSON value. + * + * You should usually call [Builder.sql] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sql(sql: JsonField) = apply { this.sql = sql } + + /** + * Positional bind parameters, in placeholder order. Each value is a string, a number, a + * boolean, or null; booleans are cast to `1`/`0`. The count must match the number of + * `?` placeholders exactly — a mismatch is rejected with 422 rather than binding null + * for the ones you left out. (Not enforced for multi-statement scripts or named + * parameters, where the placeholder count is not the number bound.) + */ + fun params(params: List) = params(JsonField.of(params)) + + /** + * Sets [Builder.params] to an arbitrary JSON value. + * + * You should usually call [Builder.params] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun params(params: JsonField>) = apply { + this.params = params.map { it.toMutableList() } + } + + /** + * Adds a single [Param] to [params]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addParam(param: Param) = apply { + params = + (params ?: JsonField.of(mutableListOf())).also { + checkKnown("params", it).add(param) + } + } + + /** Alias for calling [addParam] with `Param.ofString(string)`. */ + fun addParam(string: String) = addParam(Param.ofString(string)) + + /** Alias for calling [addParam] with `Param.ofNumber(number)`. */ + fun addParam(number: Double) = addParam(Param.ofNumber(number)) + + /** Alias for calling [addParam] with `Param.ofBool(bool)`. */ + fun addParam(bool: Boolean) = addParam(Param.ofBool(bool)) + + /** Alias for calling [addParam] with `Param.ofNull()`. */ + fun addParamNull() = addParam(Param.ofNull()) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sql() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("sql", sql), + (params ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + sql() + params().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (sql.asKnown().isPresent) 1 else 0) + + (params.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + sql == other.sql && + params == other.params && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(sql, params, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{sql=$sql, params=$params, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(using = Param.Deserializer::class) + @JsonSerialize(using = Param.Serializer::class) + class Param + private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val null_: JsonValue? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun null_(): Optional = Optional.ofNullable(null_) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun isNull(): Boolean = null_ != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun asNull(): JsonValue = null_.getOrThrow("null_") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.telnyx.sdk.core.JsonValue; + * import java.util.Optional; + * + * Optional result = param.accept(new Param.Visitor>() { + * @Override + * public Optional visitString(String string) { + * return Optional.of(string.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws TelnyxInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + null_ != null -> visitor.visitNull(null_) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Param = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNumber(number: Double) {} + + override fun visitBool(bool: Boolean) {} + + override fun visitNull(null_: JsonValue) { + null_.let { + if (it != JsonValue.from(null)) { + throw TelnyxInvalidDataException("'null_' is invalid, received $it") + } + } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNumber(number: Double) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun visitNull(null_: JsonValue) = + null_.let { if (it == JsonValue.from(null)) 1 else 0 } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Param && + string == other.string && + number == other.number && + bool == other.bool && + null_ == other.null_ + } + + override fun hashCode(): Int = Objects.hash(string, number, bool, null_) + + override fun toString(): String = + when { + string != null -> "Param{string=$string}" + number != null -> "Param{number=$number}" + bool != null -> "Param{bool=$bool}" + null_ != null -> "Param{null_=$null_}" + _json != null -> "Param{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Param") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Param(string = string) + + @JvmStatic fun ofNumber(number: Double) = Param(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Param(bool = bool) + + @JvmStatic fun ofNull() = Param(null_ = JsonValue.from(null)) + } + + /** An interface that defines how to map each variant of [Param] to a value of type [T]. */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + fun visitNull(null_: JsonValue): T + + /** + * Maps an unknown variant of [Param] to a value of type [T]. + * + * An instance of [Param] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws TelnyxInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw TelnyxInvalidDataException("Unknown Param: $json") + } + } + + internal class Deserializer : BaseDeserializer(Param::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Param { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Param(null_ = it, _json = json) } + ?.takeIf { it.isValid() }, + tryDeserialize(node, jacksonTypeRef())?.let { + Param(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Param(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Param(bool = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> Param(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Param::class) { + + override fun serialize( + value: Param, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value.null_ != null -> generator.writeObject(value.null_) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Param") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ActionQueryParams && + id == other.id && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(id, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ActionQueryParams{id=$id, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/actions/ActionQueryResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/actions/ActionQueryResponse.kt new file mode 100644 index 000000000..076bbd8f0 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/storage/sqldbs/actions/ActionQueryResponse.kt @@ -0,0 +1,913 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.sqldbs.actions + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.checkKnown +import com.telnyx.sdk.core.toImmutable +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ActionQueryResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of() + ) : this(data, mutableMapOf()) + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ActionQueryResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ActionQueryResponse]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(actionQueryResponse: ActionQueryResponse) = apply { + data = actionQueryResponse.data + additionalProperties = actionQueryResponse.additionalProperties.toMutableMap() + } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ActionQueryResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ActionQueryResponse = + ActionQueryResponse(data, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ActionQueryResponse = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val count: JsonField, + private val duration: JsonField, + private val meta: JsonField, + private val results: JsonField>, + private val success: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("count") @ExcludeMissing count: JsonField = JsonMissing.of(), + @JsonProperty("duration") + @ExcludeMissing + duration: JsonField = JsonMissing.of(), + @JsonProperty("meta") @ExcludeMissing meta: JsonField = JsonMissing.of(), + @JsonProperty("results") + @ExcludeMissing + results: JsonField> = JsonMissing.of(), + @JsonProperty("success") @ExcludeMissing success: JsonField = JsonMissing.of(), + ) : this(count, duration, meta, results, success, mutableMapOf()) + + /** + * Number of rows returned. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun count(): Optional = count.getOptional("count") + + /** + * Wall-clock duration of the request, in milliseconds. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun duration(): Optional = duration.getOptional("duration") + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun meta(): Optional = meta.getOptional("meta") + + /** + * The result rows, each a map of column name to value. Empty for statements that return no + * rows. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun results(): Optional> = results.getOptional("results") + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun success(): Optional = success.getOptional("success") + + /** + * Returns the raw JSON value of [count]. + * + * Unlike [count], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("count") @ExcludeMissing fun _count(): JsonField = count + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [meta]. + * + * Unlike [meta], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("meta") @ExcludeMissing fun _meta(): JsonField = meta + + /** + * Returns the raw JSON value of [results]. + * + * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results + + /** + * Returns the raw JSON value of [success]. + * + * Unlike [success], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("success") @ExcludeMissing fun _success(): JsonField = success + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var count: JsonField = JsonMissing.of() + private var duration: JsonField = JsonMissing.of() + private var meta: JsonField = JsonMissing.of() + private var results: JsonField>? = null + private var success: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + count = data.count + duration = data.duration + meta = data.meta + results = data.results.map { it.toMutableList() } + success = data.success + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** Number of rows returned. */ + fun count(count: Long) = count(JsonField.of(count)) + + /** + * Sets [Builder.count] to an arbitrary JSON value. + * + * You should usually call [Builder.count] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun count(count: JsonField) = apply { this.count = count } + + /** Wall-clock duration of the request, in milliseconds. */ + fun duration(duration: Double) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + fun meta(meta: Meta) = meta(JsonField.of(meta)) + + /** + * Sets [Builder.meta] to an arbitrary JSON value. + * + * You should usually call [Builder.meta] with a well-typed [Meta] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun meta(meta: JsonField) = apply { this.meta = meta } + + /** + * The result rows, each a map of column name to value. Empty for statements that return + * no rows. + */ + fun results(results: List) = results(JsonField.of(results)) + + /** + * Sets [Builder.results] to an arbitrary JSON value. + * + * You should usually call [Builder.results] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun results(results: JsonField>) = apply { + this.results = results.map { it.toMutableList() } + } + + /** + * Adds a single [Result] to [results]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResult(result: Result) = apply { + results = + (results ?: JsonField.of(mutableListOf())).also { + checkKnown("results", it).add(result) + } + } + + fun success(success: Boolean) = success(JsonField.of(success)) + + /** + * Sets [Builder.success] to an arbitrary JSON value. + * + * You should usually call [Builder.success] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun success(success: JsonField) = apply { this.success = success } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = + Data( + count, + duration, + meta, + (results ?: JsonMissing.of()).map { it.toImmutable() }, + success, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Data = apply { + if (validated) { + return@apply + } + + count() + duration() + meta().ifPresent { it.validate() } + results().ifPresent { it.forEach { it.validate() } } + success() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (count.asKnown().isPresent) 1 else 0) + + (if (duration.asKnown().isPresent) 1 else 0) + + (meta.asKnown().getOrNull()?.validity() ?: 0) + + (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (success.asKnown().isPresent) 1 else 0) + + class Meta + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val changes: JsonField, + private val duration: JsonField, + private val lastRowId: JsonField, + private val rowsRead: JsonField, + private val rowsWritten: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("changes") + @ExcludeMissing + changes: JsonField = JsonMissing.of(), + @JsonProperty("duration") + @ExcludeMissing + duration: JsonField = JsonMissing.of(), + @JsonProperty("last_row_id") + @ExcludeMissing + lastRowId: JsonField = JsonMissing.of(), + @JsonProperty("rows_read") + @ExcludeMissing + rowsRead: JsonField = JsonMissing.of(), + @JsonProperty("rows_written") + @ExcludeMissing + rowsWritten: JsonField = JsonMissing.of(), + ) : this(changes, duration, lastRowId, rowsRead, rowsWritten, mutableMapOf()) + + /** + * Number of rows added, changed, or removed by the statement. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun changes(): Optional = changes.getOptional("changes") + + /** + * Wall-clock duration of the statement, in milliseconds. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun duration(): Optional = duration.getOptional("duration") + + /** + * Rowid of the last inserted row, when applicable. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lastRowId(): Optional = lastRowId.getOptional("last_row_id") + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rowsRead(): Optional = rowsRead.getOptional("rows_read") + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rowsWritten(): Optional = rowsWritten.getOptional("rows_written") + + /** + * Returns the raw JSON value of [changes]. + * + * Unlike [changes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("changes") @ExcludeMissing fun _changes(): JsonField = changes + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [lastRowId]. + * + * Unlike [lastRowId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("last_row_id") + @ExcludeMissing + fun _lastRowId(): JsonField = lastRowId + + /** + * Returns the raw JSON value of [rowsRead]. + * + * Unlike [rowsRead], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rows_read") @ExcludeMissing fun _rowsRead(): JsonField = rowsRead + + /** + * Returns the raw JSON value of [rowsWritten]. + * + * Unlike [rowsWritten], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("rows_written") + @ExcludeMissing + fun _rowsWritten(): JsonField = rowsWritten + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Meta]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Meta]. */ + class Builder internal constructor() { + + private var changes: JsonField = JsonMissing.of() + private var duration: JsonField = JsonMissing.of() + private var lastRowId: JsonField = JsonMissing.of() + private var rowsRead: JsonField = JsonMissing.of() + private var rowsWritten: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(meta: Meta) = apply { + changes = meta.changes + duration = meta.duration + lastRowId = meta.lastRowId + rowsRead = meta.rowsRead + rowsWritten = meta.rowsWritten + additionalProperties = meta.additionalProperties.toMutableMap() + } + + /** Number of rows added, changed, or removed by the statement. */ + fun changes(changes: Long) = changes(JsonField.of(changes)) + + /** + * Sets [Builder.changes] to an arbitrary JSON value. + * + * You should usually call [Builder.changes] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun changes(changes: JsonField) = apply { this.changes = changes } + + /** Wall-clock duration of the statement, in milliseconds. */ + fun duration(duration: Double) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** Rowid of the last inserted row, when applicable. */ + fun lastRowId(lastRowId: Long) = lastRowId(JsonField.of(lastRowId)) + + /** + * Sets [Builder.lastRowId] to an arbitrary JSON value. + * + * You should usually call [Builder.lastRowId] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun lastRowId(lastRowId: JsonField) = apply { this.lastRowId = lastRowId } + + fun rowsRead(rowsRead: Long) = rowsRead(JsonField.of(rowsRead)) + + /** + * Sets [Builder.rowsRead] to an arbitrary JSON value. + * + * You should usually call [Builder.rowsRead] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun rowsRead(rowsRead: JsonField) = apply { this.rowsRead = rowsRead } + + fun rowsWritten(rowsWritten: Long) = rowsWritten(JsonField.of(rowsWritten)) + + /** + * Sets [Builder.rowsWritten] to an arbitrary JSON value. + * + * You should usually call [Builder.rowsWritten] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun rowsWritten(rowsWritten: JsonField) = apply { + this.rowsWritten = rowsWritten + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Meta]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Meta = + Meta( + changes, + duration, + lastRowId, + rowsRead, + rowsWritten, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Meta = apply { + if (validated) { + return@apply + } + + changes() + duration() + lastRowId() + rowsRead() + rowsWritten() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (changes.asKnown().isPresent) 1 else 0) + + (if (duration.asKnown().isPresent) 1 else 0) + + (if (lastRowId.asKnown().isPresent) 1 else 0) + + (if (rowsRead.asKnown().isPresent) 1 else 0) + + (if (rowsWritten.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Meta && + changes == other.changes && + duration == other.duration && + lastRowId == other.lastRowId && + rowsRead == other.rowsRead && + rowsWritten == other.rowsWritten && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + changes, + duration, + lastRowId, + rowsRead, + rowsWritten, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Meta{changes=$changes, duration=$duration, lastRowId=$lastRowId, rowsRead=$rowsRead, rowsWritten=$rowsWritten, additionalProperties=$additionalProperties}" + } + + class Result + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Result]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Result]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(result: Result) = apply { + additionalProperties = result.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Result]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Result = Result(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Result = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Result && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Result{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + count == other.count && + duration == other.duration && + meta == other.meta && + results == other.results && + success == other.success && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(count, duration, meta, results, success, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{count=$count, duration=$duration, meta=$meta, results=$results, success=$success, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ActionQueryResponse && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ActionQueryResponse{data=$data, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/WebSearchContentsParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/WebSearchContentsParams.kt new file mode 100644 index 000000000..4d95a59c0 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/WebSearchContentsParams.kt @@ -0,0 +1,851 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.websearch + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.telnyx.sdk.core.Enum +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.checkKnown +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.core.toImmutable +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Retrieves clean HTML or Markdown content from a list of URLs. Supports up to 20 URLs per request + * (public API limit). Specify which formats to return: `html`, `markdown`, `metadata`. + */ +class WebSearchContentsParams +private constructor( + private val body: Body, + private val additionalHeaders: com.telnyx.sdk.core.http.Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * List of URLs to retrieve content from (max 20 for public API). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun urls(): List = body.urls() + + /** + * Timeout for crawling each URL, in seconds (1-60). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun crawlTimeout(): Optional = body.crawlTimeout() + + /** + * Content formats to return. If omitted, `html` and `metadata` are returned by default. + * Retrieval is best-effort per URL: a format field appears only when that content could be + * produced, and a freshly crawled page may also include `html` even when not requested. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun formats(): Optional> = body.formats() + + /** + * Maximum age of cached content in seconds. `null` means no limit. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxAge(): Optional = body.maxAge() + + /** + * Returns the raw JSON value of [urls]. + * + * Unlike [urls], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _urls(): JsonField> = body._urls() + + /** + * Returns the raw JSON value of [crawlTimeout]. + * + * Unlike [crawlTimeout], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _crawlTimeout(): JsonField = body._crawlTimeout() + + /** + * Returns the raw JSON value of [formats]. + * + * Unlike [formats], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _formats(): JsonField> = body._formats() + + /** + * Returns the raw JSON value of [maxAge]. + * + * Unlike [maxAge], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _maxAge(): JsonField = body._maxAge() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [WebSearchContentsParams]. + * + * The following fields are required: + * ```java + * .urls() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebSearchContentsParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: com.telnyx.sdk.core.http.Headers.Builder = + com.telnyx.sdk.core.http.Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(webSearchContentsParams: WebSearchContentsParams) = apply { + body = webSearchContentsParams.body.toBuilder() + additionalHeaders = webSearchContentsParams.additionalHeaders.toBuilder() + additionalQueryParams = webSearchContentsParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [urls] + * - [crawlTimeout] + * - [formats] + * - [maxAge] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** List of URLs to retrieve content from (max 20 for public API). */ + fun urls(urls: List) = apply { body.urls(urls) } + + /** + * Sets [Builder.urls] to an arbitrary JSON value. + * + * You should usually call [Builder.urls] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun urls(urls: JsonField>) = apply { body.urls(urls) } + + /** + * Adds a single [String] to [urls]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUrl(url: String) = apply { body.addUrl(url) } + + /** Timeout for crawling each URL, in seconds (1-60). */ + fun crawlTimeout(crawlTimeout: Long) = apply { body.crawlTimeout(crawlTimeout) } + + /** + * Sets [Builder.crawlTimeout] to an arbitrary JSON value. + * + * You should usually call [Builder.crawlTimeout] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun crawlTimeout(crawlTimeout: JsonField) = apply { body.crawlTimeout(crawlTimeout) } + + /** + * Content formats to return. If omitted, `html` and `metadata` are returned by default. + * Retrieval is best-effort per URL: a format field appears only when that content could be + * produced, and a freshly crawled page may also include `html` even when not requested. + */ + fun formats(formats: List) = apply { body.formats(formats) } + + /** + * Sets [Builder.formats] to an arbitrary JSON value. + * + * You should usually call [Builder.formats] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun formats(formats: JsonField>) = apply { body.formats(formats) } + + /** + * Adds a single [Format] to [formats]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFormat(format: Format) = apply { body.addFormat(format) } + + /** Maximum age of cached content in seconds. `null` means no limit. */ + fun maxAge(maxAge: Long?) = apply { body.maxAge(maxAge) } + + /** + * Alias for [Builder.maxAge]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxAge(maxAge: Long) = maxAge(maxAge as Long?) + + /** Alias for calling [Builder.maxAge] with `maxAge.orElse(null)`. */ + fun maxAge(maxAge: Optional) = maxAge(maxAge.getOrNull()) + + /** + * Sets [Builder.maxAge] to an arbitrary JSON value. + * + * You should usually call [Builder.maxAge] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun maxAge(maxAge: JsonField) = apply { body.maxAge(maxAge) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [WebSearchContentsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .urls() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WebSearchContentsParams = + WebSearchContentsParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val urls: JsonField>, + private val crawlTimeout: JsonField, + private val formats: JsonField>, + private val maxAge: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("urls") @ExcludeMissing urls: JsonField> = JsonMissing.of(), + @JsonProperty("crawl_timeout") + @ExcludeMissing + crawlTimeout: JsonField = JsonMissing.of(), + @JsonProperty("formats") + @ExcludeMissing + formats: JsonField> = JsonMissing.of(), + @JsonProperty("max_age") @ExcludeMissing maxAge: JsonField = JsonMissing.of(), + ) : this(urls, crawlTimeout, formats, maxAge, mutableMapOf()) + + /** + * List of URLs to retrieve content from (max 20 for public API). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun urls(): List = urls.getRequired("urls") + + /** + * Timeout for crawling each URL, in seconds (1-60). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun crawlTimeout(): Optional = crawlTimeout.getOptional("crawl_timeout") + + /** + * Content formats to return. If omitted, `html` and `metadata` are returned by default. + * Retrieval is best-effort per URL: a format field appears only when that content could be + * produced, and a freshly crawled page may also include `html` even when not requested. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun formats(): Optional> = formats.getOptional("formats") + + /** + * Maximum age of cached content in seconds. `null` means no limit. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxAge(): Optional = maxAge.getOptional("max_age") + + /** + * Returns the raw JSON value of [urls]. + * + * Unlike [urls], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("urls") @ExcludeMissing fun _urls(): JsonField> = urls + + /** + * Returns the raw JSON value of [crawlTimeout]. + * + * Unlike [crawlTimeout], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("crawl_timeout") + @ExcludeMissing + fun _crawlTimeout(): JsonField = crawlTimeout + + /** + * Returns the raw JSON value of [formats]. + * + * Unlike [formats], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("formats") @ExcludeMissing fun _formats(): JsonField> = formats + + /** + * Returns the raw JSON value of [maxAge]. + * + * Unlike [maxAge], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("max_age") @ExcludeMissing fun _maxAge(): JsonField = maxAge + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .urls() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var urls: JsonField>? = null + private var crawlTimeout: JsonField = JsonMissing.of() + private var formats: JsonField>? = null + private var maxAge: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + urls = body.urls.map { it.toMutableList() } + crawlTimeout = body.crawlTimeout + formats = body.formats.map { it.toMutableList() } + maxAge = body.maxAge + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** List of URLs to retrieve content from (max 20 for public API). */ + fun urls(urls: List) = urls(JsonField.of(urls)) + + /** + * Sets [Builder.urls] to an arbitrary JSON value. + * + * You should usually call [Builder.urls] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun urls(urls: JsonField>) = apply { + this.urls = urls.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [urls]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUrl(url: String) = apply { + urls = + (urls ?: JsonField.of(mutableListOf())).also { checkKnown("urls", it).add(url) } + } + + /** Timeout for crawling each URL, in seconds (1-60). */ + fun crawlTimeout(crawlTimeout: Long) = crawlTimeout(JsonField.of(crawlTimeout)) + + /** + * Sets [Builder.crawlTimeout] to an arbitrary JSON value. + * + * You should usually call [Builder.crawlTimeout] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun crawlTimeout(crawlTimeout: JsonField) = apply { + this.crawlTimeout = crawlTimeout + } + + /** + * Content formats to return. If omitted, `html` and `metadata` are returned by default. + * Retrieval is best-effort per URL: a format field appears only when that content could + * be produced, and a freshly crawled page may also include `html` even when not + * requested. + */ + fun formats(formats: List) = formats(JsonField.of(formats)) + + /** + * Sets [Builder.formats] to an arbitrary JSON value. + * + * You should usually call [Builder.formats] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun formats(formats: JsonField>) = apply { + this.formats = formats.map { it.toMutableList() } + } + + /** + * Adds a single [Format] to [formats]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFormat(format: Format) = apply { + formats = + (formats ?: JsonField.of(mutableListOf())).also { + checkKnown("formats", it).add(format) + } + } + + /** Maximum age of cached content in seconds. `null` means no limit. */ + fun maxAge(maxAge: Long?) = maxAge(JsonField.ofNullable(maxAge)) + + /** + * Alias for [Builder.maxAge]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun maxAge(maxAge: Long) = maxAge(maxAge as Long?) + + /** Alias for calling [Builder.maxAge] with `maxAge.orElse(null)`. */ + fun maxAge(maxAge: Optional) = maxAge(maxAge.getOrNull()) + + /** + * Sets [Builder.maxAge] to an arbitrary JSON value. + * + * You should usually call [Builder.maxAge] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun maxAge(maxAge: JsonField) = apply { this.maxAge = maxAge } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .urls() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("urls", urls).map { it.toImmutable() }, + crawlTimeout, + (formats ?: JsonMissing.of()).map { it.toImmutable() }, + maxAge, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + urls() + crawlTimeout() + formats().ifPresent { it.forEach { it.validate() } } + maxAge() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (urls.asKnown().getOrNull()?.size ?: 0) + + (if (crawlTimeout.asKnown().isPresent) 1 else 0) + + (formats.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (maxAge.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + urls == other.urls && + crawlTimeout == other.crawlTimeout && + formats == other.formats && + maxAge == other.maxAge && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(urls, crawlTimeout, formats, maxAge, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{urls=$urls, crawlTimeout=$crawlTimeout, formats=$formats, maxAge=$maxAge, additionalProperties=$additionalProperties}" + } + + class Format @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val HTML = of("html") + + @JvmField val MARKDOWN = of("markdown") + + @JvmField val METADATA = of("metadata") + + @JvmStatic fun of(value: String) = Format(JsonField.of(value)) + } + + /** An enum containing [Format]'s known values. */ + enum class Known { + HTML, + MARKDOWN, + METADATA, + } + + /** + * An enum containing [Format]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Format] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HTML, + MARKDOWN, + METADATA, + /** An enum member indicating that [Format] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HTML -> Value.HTML + MARKDOWN -> Value.MARKDOWN + METADATA -> Value.METADATA + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + HTML -> Known.HTML + MARKDOWN -> Known.MARKDOWN + METADATA -> Known.METADATA + else -> throw TelnyxInvalidDataException("Unknown Format: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { TelnyxInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Format = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Format && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WebSearchContentsParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "WebSearchContentsParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/WebSearchContentsResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/WebSearchContentsResponse.kt new file mode 100644 index 000000000..216ecf569 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/WebSearchContentsResponse.kt @@ -0,0 +1,871 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.websearch + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.checkKnown +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.toImmutable +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class WebSearchContentsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of() + ) : this(data, mutableMapOf()) + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [WebSearchContentsResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebSearchContentsResponse]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webSearchContentsResponse: WebSearchContentsResponse) = apply { + data = webSearchContentsResponse.data + additionalProperties = webSearchContentsResponse.additionalProperties.toMutableMap() + } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [WebSearchContentsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WebSearchContentsResponse = + WebSearchContentsResponse(data, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): WebSearchContentsResponse = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val results: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("results") + @ExcludeMissing + results: JsonField> = JsonMissing.of() + ) : this(results, mutableMapOf()) + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun results(): Optional> = results.getOptional("results") + + /** + * Returns the raw JSON value of [results]. + * + * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var results: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + results = data.results.map { it.toMutableList() } + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun results(results: List) = results(JsonField.of(results)) + + /** + * Sets [Builder.results] to an arbitrary JSON value. + * + * You should usually call [Builder.results] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun results(results: JsonField>) = apply { + this.results = results.map { it.toMutableList() } + } + + /** + * Adds a single [Result] to [results]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResult(result: Result) = apply { + results = + (results ?: JsonField.of(mutableListOf())).also { + checkKnown("results", it).add(result) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = + Data( + (results ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Data = apply { + if (validated) { + return@apply + } + + results().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Result + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val url: JsonField, + private val html: JsonField, + private val markdown: JsonField, + private val metadata: JsonField, + private val title: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("html") @ExcludeMissing html: JsonField = JsonMissing.of(), + @JsonProperty("markdown") + @ExcludeMissing + markdown: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), + ) : this(url, html, markdown, metadata, title, mutableMapOf()) + + /** + * The source URL. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun url(): String = url.getRequired("url") + + /** + * Cleaned HTML content (if `html` format requested; may also be present on freshly + * crawled pages). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun html(): Optional = html.getOptional("html") + + /** + * Markdown content (if `markdown` format requested). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun markdown(): Optional = markdown.getOptional("markdown") + + /** + * Page metadata (if `metadata` format requested). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * Page title (if available). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun title(): Optional = title.getOptional("title") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [html]. + * + * Unlike [html], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("html") @ExcludeMissing fun _html(): JsonField = html + + /** + * Returns the raw JSON value of [markdown]. + * + * Unlike [markdown], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("markdown") @ExcludeMissing fun _markdown(): JsonField = markdown + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Result]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Result]. */ + class Builder internal constructor() { + + private var url: JsonField? = null + private var html: JsonField = JsonMissing.of() + private var markdown: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var title: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(result: Result) = apply { + url = result.url + html = result.html + markdown = result.markdown + metadata = result.metadata + title = result.title + additionalProperties = result.additionalProperties.toMutableMap() + } + + /** The source URL. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** + * Cleaned HTML content (if `html` format requested; may also be present on freshly + * crawled pages). + */ + fun html(html: String) = html(JsonField.of(html)) + + /** + * Sets [Builder.html] to an arbitrary JSON value. + * + * You should usually call [Builder.html] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun html(html: JsonField) = apply { this.html = html } + + /** Markdown content (if `markdown` format requested). */ + fun markdown(markdown: String) = markdown(JsonField.of(markdown)) + + /** + * Sets [Builder.markdown] to an arbitrary JSON value. + * + * You should usually call [Builder.markdown] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun markdown(markdown: JsonField) = apply { this.markdown = markdown } + + /** Page metadata (if `metadata` format requested). */ + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + /** Page title (if available). */ + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Result]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Result = + Result( + checkRequired("url", url), + html, + markdown, + metadata, + title, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Result = apply { + if (validated) { + return@apply + } + + url() + html() + markdown() + metadata().ifPresent { it.validate() } + title() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (url.asKnown().isPresent) 1 else 0) + + (if (html.asKnown().isPresent) 1 else 0) + + (if (markdown.asKnown().isPresent) 1 else 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (title.asKnown().isPresent) 1 else 0) + + /** Page metadata (if `metadata` format requested). */ + class Metadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val faviconUrl: JsonField, + private val siteName: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("favicon_url") + @ExcludeMissing + faviconUrl: JsonField = JsonMissing.of(), + @JsonProperty("site_name") + @ExcludeMissing + siteName: JsonField = JsonMissing.of(), + ) : this(faviconUrl, siteName, mutableMapOf()) + + /** + * Favicon URL (if available). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun faviconUrl(): Optional = faviconUrl.getOptional("favicon_url") + + /** + * Site name. Often empty. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun siteName(): Optional = siteName.getOptional("site_name") + + /** + * Returns the raw JSON value of [faviconUrl]. + * + * Unlike [faviconUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("favicon_url") + @ExcludeMissing + fun _faviconUrl(): JsonField = faviconUrl + + /** + * Returns the raw JSON value of [siteName]. + * + * Unlike [siteName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("site_name") + @ExcludeMissing + fun _siteName(): JsonField = siteName + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var faviconUrl: JsonField = JsonMissing.of() + private var siteName: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + faviconUrl = metadata.faviconUrl + siteName = metadata.siteName + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + /** Favicon URL (if available). */ + fun faviconUrl(faviconUrl: String) = faviconUrl(JsonField.of(faviconUrl)) + + /** + * Sets [Builder.faviconUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.faviconUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun faviconUrl(faviconUrl: JsonField) = apply { + this.faviconUrl = faviconUrl + } + + /** Site name. Often empty. */ + fun siteName(siteName: String) = siteName(JsonField.of(siteName)) + + /** + * Sets [Builder.siteName] to an arbitrary JSON value. + * + * You should usually call [Builder.siteName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun siteName(siteName: JsonField) = apply { this.siteName = siteName } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = + Metadata(faviconUrl, siteName, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + faviconUrl() + siteName() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (faviconUrl.asKnown().isPresent) 1 else 0) + + (if (siteName.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + faviconUrl == other.faviconUrl && + siteName == other.siteName && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(faviconUrl, siteName, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Metadata{faviconUrl=$faviconUrl, siteName=$siteName, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Result && + url == other.url && + html == other.html && + markdown == other.markdown && + metadata == other.metadata && + title == other.title && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(url, html, markdown, metadata, title, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Result{url=$url, html=$html, markdown=$markdown, metadata=$metadata, title=$title, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + results == other.results && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(results, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{results=$results, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WebSearchContentsResponse && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WebSearchContentsResponse{data=$data, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/WebSearchCreateParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/WebSearchCreateParams.kt new file mode 100644 index 000000000..832e55641 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/WebSearchCreateParams.kt @@ -0,0 +1,1127 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.websearch + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.telnyx.sdk.core.Enum +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.checkKnown +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.core.toImmutable +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Performs a real-time web search and returns structured, LLM-ready JSON results with titles, URLs, + * descriptions, and snippets. Supports filtering by domain, country, safe search, freshness, and + * live crawl. + * + * **Note:** `include_domains` and `exclude_domains` cannot be used in the same request. Use one or + * the other. + */ +class WebSearchCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: com.telnyx.sdk.core.http.Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The search query text. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun query(): String = body.query() + + /** + * Number of results to return (1-100). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun count(): Optional = body.count() + + /** + * Two-letter country code (ISO 3166-1 alpha-2) to bias results. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun country(): Optional = body.country() + + /** + * Exclude results from these domains (bare hostnames, e.g. `pinterest.com`). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun excludeDomains(): Optional> = body.excludeDomains() + + /** + * Time-based filter for results. Common values: `day`, `week`, `month`, `year`. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun freshness(): Optional = body.freshness() + + /** + * Restrict results to these domains (bare hostnames, e.g. `arxiv.org`). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun includeDomains(): Optional> = body.includeDomains() + + /** + * When true, the provider crawls pages in real-time for fresh content. The boolean is + * translated to the provider's internal enum internally; callers always pass `true` or `false`. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun livecrawl(): Optional = body.livecrawl() + + /** + * Safe search filter level. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun safesearch(): Optional = body.safesearch() + + /** + * Returns the raw JSON value of [query]. + * + * Unlike [query], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _query(): JsonField = body._query() + + /** + * Returns the raw JSON value of [count]. + * + * Unlike [count], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _count(): JsonField = body._count() + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _country(): JsonField = body._country() + + /** + * Returns the raw JSON value of [excludeDomains]. + * + * Unlike [excludeDomains], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _excludeDomains(): JsonField> = body._excludeDomains() + + /** + * Returns the raw JSON value of [freshness]. + * + * Unlike [freshness], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _freshness(): JsonField = body._freshness() + + /** + * Returns the raw JSON value of [includeDomains]. + * + * Unlike [includeDomains], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _includeDomains(): JsonField> = body._includeDomains() + + /** + * Returns the raw JSON value of [livecrawl]. + * + * Unlike [livecrawl], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _livecrawl(): JsonField = body._livecrawl() + + /** + * Returns the raw JSON value of [safesearch]. + * + * Unlike [safesearch], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _safesearch(): JsonField = body._safesearch() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [WebSearchCreateParams]. + * + * The following fields are required: + * ```java + * .query() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebSearchCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: com.telnyx.sdk.core.http.Headers.Builder = + com.telnyx.sdk.core.http.Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(webSearchCreateParams: WebSearchCreateParams) = apply { + body = webSearchCreateParams.body.toBuilder() + additionalHeaders = webSearchCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = webSearchCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [query] + * - [count] + * - [country] + * - [excludeDomains] + * - [freshness] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The search query text. */ + fun query(query: String) = apply { body.query(query) } + + /** + * Sets [Builder.query] to an arbitrary JSON value. + * + * You should usually call [Builder.query] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun query(query: JsonField) = apply { body.query(query) } + + /** Number of results to return (1-100). */ + fun count(count: Long) = apply { body.count(count) } + + /** + * Sets [Builder.count] to an arbitrary JSON value. + * + * You should usually call [Builder.count] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun count(count: JsonField) = apply { body.count(count) } + + /** Two-letter country code (ISO 3166-1 alpha-2) to bias results. */ + fun country(country: String) = apply { body.country(country) } + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun country(country: JsonField) = apply { body.country(country) } + + /** Exclude results from these domains (bare hostnames, e.g. `pinterest.com`). */ + fun excludeDomains(excludeDomains: List) = apply { + body.excludeDomains(excludeDomains) + } + + /** + * Sets [Builder.excludeDomains] to an arbitrary JSON value. + * + * You should usually call [Builder.excludeDomains] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun excludeDomains(excludeDomains: JsonField>) = apply { + body.excludeDomains(excludeDomains) + } + + /** + * Adds a single [String] to [excludeDomains]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExcludeDomain(excludeDomain: String) = apply { body.addExcludeDomain(excludeDomain) } + + /** Time-based filter for results. Common values: `day`, `week`, `month`, `year`. */ + fun freshness(freshness: String) = apply { body.freshness(freshness) } + + /** + * Sets [Builder.freshness] to an arbitrary JSON value. + * + * You should usually call [Builder.freshness] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun freshness(freshness: JsonField) = apply { body.freshness(freshness) } + + /** Restrict results to these domains (bare hostnames, e.g. `arxiv.org`). */ + fun includeDomains(includeDomains: List) = apply { + body.includeDomains(includeDomains) + } + + /** + * Sets [Builder.includeDomains] to an arbitrary JSON value. + * + * You should usually call [Builder.includeDomains] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun includeDomains(includeDomains: JsonField>) = apply { + body.includeDomains(includeDomains) + } + + /** + * Adds a single [String] to [includeDomains]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIncludeDomain(includeDomain: String) = apply { body.addIncludeDomain(includeDomain) } + + /** + * When true, the provider crawls pages in real-time for fresh content. The boolean is + * translated to the provider's internal enum internally; callers always pass `true` or + * `false`. + */ + fun livecrawl(livecrawl: Boolean) = apply { body.livecrawl(livecrawl) } + + /** + * Sets [Builder.livecrawl] to an arbitrary JSON value. + * + * You should usually call [Builder.livecrawl] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun livecrawl(livecrawl: JsonField) = apply { body.livecrawl(livecrawl) } + + /** Safe search filter level. */ + fun safesearch(safesearch: Safesearch) = apply { body.safesearch(safesearch) } + + /** + * Sets [Builder.safesearch] to an arbitrary JSON value. + * + * You should usually call [Builder.safesearch] with a well-typed [Safesearch] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun safesearch(safesearch: JsonField) = apply { body.safesearch(safesearch) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [WebSearchCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .query() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WebSearchCreateParams = + WebSearchCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val query: JsonField, + private val count: JsonField, + private val country: JsonField, + private val excludeDomains: JsonField>, + private val freshness: JsonField, + private val includeDomains: JsonField>, + private val livecrawl: JsonField, + private val safesearch: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("query") @ExcludeMissing query: JsonField = JsonMissing.of(), + @JsonProperty("count") @ExcludeMissing count: JsonField = JsonMissing.of(), + @JsonProperty("country") @ExcludeMissing country: JsonField = JsonMissing.of(), + @JsonProperty("exclude_domains") + @ExcludeMissing + excludeDomains: JsonField> = JsonMissing.of(), + @JsonProperty("freshness") + @ExcludeMissing + freshness: JsonField = JsonMissing.of(), + @JsonProperty("include_domains") + @ExcludeMissing + includeDomains: JsonField> = JsonMissing.of(), + @JsonProperty("livecrawl") + @ExcludeMissing + livecrawl: JsonField = JsonMissing.of(), + @JsonProperty("safesearch") + @ExcludeMissing + safesearch: JsonField = JsonMissing.of(), + ) : this( + query, + count, + country, + excludeDomains, + freshness, + includeDomains, + livecrawl, + safesearch, + mutableMapOf(), + ) + + /** + * The search query text. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun query(): String = query.getRequired("query") + + /** + * Number of results to return (1-100). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun count(): Optional = count.getOptional("count") + + /** + * Two-letter country code (ISO 3166-1 alpha-2) to bias results. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun country(): Optional = country.getOptional("country") + + /** + * Exclude results from these domains (bare hostnames, e.g. `pinterest.com`). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun excludeDomains(): Optional> = excludeDomains.getOptional("exclude_domains") + + /** + * Time-based filter for results. Common values: `day`, `week`, `month`, `year`. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun freshness(): Optional = freshness.getOptional("freshness") + + /** + * Restrict results to these domains (bare hostnames, e.g. `arxiv.org`). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun includeDomains(): Optional> = includeDomains.getOptional("include_domains") + + /** + * When true, the provider crawls pages in real-time for fresh content. The boolean is + * translated to the provider's internal enum internally; callers always pass `true` or + * `false`. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun livecrawl(): Optional = livecrawl.getOptional("livecrawl") + + /** + * Safe search filter level. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun safesearch(): Optional = safesearch.getOptional("safesearch") + + /** + * Returns the raw JSON value of [query]. + * + * Unlike [query], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("query") @ExcludeMissing fun _query(): JsonField = query + + /** + * Returns the raw JSON value of [count]. + * + * Unlike [count], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("count") @ExcludeMissing fun _count(): JsonField = count + + /** + * Returns the raw JSON value of [country]. + * + * Unlike [country], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + /** + * Returns the raw JSON value of [excludeDomains]. + * + * Unlike [excludeDomains], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("exclude_domains") + @ExcludeMissing + fun _excludeDomains(): JsonField> = excludeDomains + + /** + * Returns the raw JSON value of [freshness]. + * + * Unlike [freshness], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("freshness") @ExcludeMissing fun _freshness(): JsonField = freshness + + /** + * Returns the raw JSON value of [includeDomains]. + * + * Unlike [includeDomains], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("include_domains") + @ExcludeMissing + fun _includeDomains(): JsonField> = includeDomains + + /** + * Returns the raw JSON value of [livecrawl]. + * + * Unlike [livecrawl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("livecrawl") @ExcludeMissing fun _livecrawl(): JsonField = livecrawl + + /** + * Returns the raw JSON value of [safesearch]. + * + * Unlike [safesearch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("safesearch") + @ExcludeMissing + fun _safesearch(): JsonField = safesearch + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .query() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var query: JsonField? = null + private var count: JsonField = JsonMissing.of() + private var country: JsonField = JsonMissing.of() + private var excludeDomains: JsonField>? = null + private var freshness: JsonField = JsonMissing.of() + private var includeDomains: JsonField>? = null + private var livecrawl: JsonField = JsonMissing.of() + private var safesearch: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + query = body.query + count = body.count + country = body.country + excludeDomains = body.excludeDomains.map { it.toMutableList() } + freshness = body.freshness + includeDomains = body.includeDomains.map { it.toMutableList() } + livecrawl = body.livecrawl + safesearch = body.safesearch + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The search query text. */ + fun query(query: String) = query(JsonField.of(query)) + + /** + * Sets [Builder.query] to an arbitrary JSON value. + * + * You should usually call [Builder.query] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun query(query: JsonField) = apply { this.query = query } + + /** Number of results to return (1-100). */ + fun count(count: Long) = count(JsonField.of(count)) + + /** + * Sets [Builder.count] to an arbitrary JSON value. + * + * You should usually call [Builder.count] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun count(count: JsonField) = apply { this.count = count } + + /** Two-letter country code (ISO 3166-1 alpha-2) to bias results. */ + fun country(country: String) = country(JsonField.of(country)) + + /** + * Sets [Builder.country] to an arbitrary JSON value. + * + * You should usually call [Builder.country] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun country(country: JsonField) = apply { this.country = country } + + /** Exclude results from these domains (bare hostnames, e.g. `pinterest.com`). */ + fun excludeDomains(excludeDomains: List) = + excludeDomains(JsonField.of(excludeDomains)) + + /** + * Sets [Builder.excludeDomains] to an arbitrary JSON value. + * + * You should usually call [Builder.excludeDomains] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun excludeDomains(excludeDomains: JsonField>) = apply { + this.excludeDomains = excludeDomains.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [excludeDomains]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExcludeDomain(excludeDomain: String) = apply { + excludeDomains = + (excludeDomains ?: JsonField.of(mutableListOf())).also { + checkKnown("excludeDomains", it).add(excludeDomain) + } + } + + /** Time-based filter for results. Common values: `day`, `week`, `month`, `year`. */ + fun freshness(freshness: String) = freshness(JsonField.of(freshness)) + + /** + * Sets [Builder.freshness] to an arbitrary JSON value. + * + * You should usually call [Builder.freshness] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun freshness(freshness: JsonField) = apply { this.freshness = freshness } + + /** Restrict results to these domains (bare hostnames, e.g. `arxiv.org`). */ + fun includeDomains(includeDomains: List) = + includeDomains(JsonField.of(includeDomains)) + + /** + * Sets [Builder.includeDomains] to an arbitrary JSON value. + * + * You should usually call [Builder.includeDomains] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun includeDomains(includeDomains: JsonField>) = apply { + this.includeDomains = includeDomains.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [includeDomains]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIncludeDomain(includeDomain: String) = apply { + includeDomains = + (includeDomains ?: JsonField.of(mutableListOf())).also { + checkKnown("includeDomains", it).add(includeDomain) + } + } + + /** + * When true, the provider crawls pages in real-time for fresh content. The boolean is + * translated to the provider's internal enum internally; callers always pass `true` or + * `false`. + */ + fun livecrawl(livecrawl: Boolean) = livecrawl(JsonField.of(livecrawl)) + + /** + * Sets [Builder.livecrawl] to an arbitrary JSON value. + * + * You should usually call [Builder.livecrawl] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun livecrawl(livecrawl: JsonField) = apply { this.livecrawl = livecrawl } + + /** Safe search filter level. */ + fun safesearch(safesearch: Safesearch) = safesearch(JsonField.of(safesearch)) + + /** + * Sets [Builder.safesearch] to an arbitrary JSON value. + * + * You should usually call [Builder.safesearch] with a well-typed [Safesearch] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun safesearch(safesearch: JsonField) = apply { + this.safesearch = safesearch + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .query() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("query", query), + count, + country, + (excludeDomains ?: JsonMissing.of()).map { it.toImmutable() }, + freshness, + (includeDomains ?: JsonMissing.of()).map { it.toImmutable() }, + livecrawl, + safesearch, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + query() + count() + country() + excludeDomains() + freshness() + includeDomains() + livecrawl() + safesearch().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (query.asKnown().isPresent) 1 else 0) + + (if (count.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (excludeDomains.asKnown().getOrNull()?.size ?: 0) + + (if (freshness.asKnown().isPresent) 1 else 0) + + (includeDomains.asKnown().getOrNull()?.size ?: 0) + + (if (livecrawl.asKnown().isPresent) 1 else 0) + + (safesearch.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + query == other.query && + count == other.count && + country == other.country && + excludeDomains == other.excludeDomains && + freshness == other.freshness && + includeDomains == other.includeDomains && + livecrawl == other.livecrawl && + safesearch == other.safesearch && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + query, + count, + country, + excludeDomains, + freshness, + includeDomains, + livecrawl, + safesearch, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{query=$query, count=$count, country=$country, excludeDomains=$excludeDomains, freshness=$freshness, includeDomains=$includeDomains, livecrawl=$livecrawl, safesearch=$safesearch, additionalProperties=$additionalProperties}" + } + + /** Safe search filter level. */ + class Safesearch @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val OFF = of("off") + + @JvmField val MODERATE = of("moderate") + + @JvmField val STRICT = of("strict") + + @JvmStatic fun of(value: String) = Safesearch(JsonField.of(value)) + } + + /** An enum containing [Safesearch]'s known values. */ + enum class Known { + OFF, + MODERATE, + STRICT, + } + + /** + * An enum containing [Safesearch]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Safesearch] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + OFF, + MODERATE, + STRICT, + /** + * An enum member indicating that [Safesearch] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + OFF -> Value.OFF + MODERATE -> Value.MODERATE + STRICT -> Value.STRICT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + OFF -> Known.OFF + MODERATE -> Known.MODERATE + STRICT -> Known.STRICT + else -> throw TelnyxInvalidDataException("Unknown Safesearch: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { TelnyxInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Safesearch = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Safesearch && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WebSearchCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "WebSearchCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/WebSearchCreateResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/WebSearchCreateResponse.kt new file mode 100644 index 000000000..38eb55e6f --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/WebSearchCreateResponse.kt @@ -0,0 +1,557 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.websearch + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.checkKnown +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.toImmutable +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class WebSearchCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of() + ) : this(data, mutableMapOf()) + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [WebSearchCreateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebSearchCreateResponse]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webSearchCreateResponse: WebSearchCreateResponse) = apply { + data = webSearchCreateResponse.data + additionalProperties = webSearchCreateResponse.additionalProperties.toMutableMap() + } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [WebSearchCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WebSearchCreateResponse = + WebSearchCreateResponse(data, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): WebSearchCreateResponse = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val results: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("results") @ExcludeMissing results: JsonField = JsonMissing.of() + ) : this(results, mutableMapOf()) + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun results(): Optional = results.getOptional("results") + + /** + * Returns the raw JSON value of [results]. + * + * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("results") @ExcludeMissing fun _results(): JsonField = results + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var results: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + results = data.results + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun results(results: Results) = results(JsonField.of(results)) + + /** + * Sets [Builder.results] to an arbitrary JSON value. + * + * You should usually call [Builder.results] with a well-typed [Results] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun results(results: JsonField) = apply { this.results = results } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = Data(results, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Data = apply { + if (validated) { + return@apply + } + + results().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (results.asKnown().getOrNull()?.validity() ?: 0) + + class Results + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val web: JsonField>, + private val news: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("web") + @ExcludeMissing + web: JsonField> = JsonMissing.of(), + @JsonProperty("news") + @ExcludeMissing + news: JsonField> = JsonMissing.of(), + ) : this(web, news, mutableMapOf()) + + /** + * Web search results. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun web(): List = web.getRequired("web") + + /** + * News search results. Present only when the query surfaces news results. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun news(): Optional> = news.getOptional("news") + + /** + * Returns the raw JSON value of [web]. + * + * Unlike [web], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("web") @ExcludeMissing fun _web(): JsonField> = web + + /** + * Returns the raw JSON value of [news]. + * + * Unlike [news], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("news") + @ExcludeMissing + fun _news(): JsonField> = news + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Results]. + * + * The following fields are required: + * ```java + * .web() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Results]. */ + class Builder internal constructor() { + + private var web: JsonField>? = null + private var news: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(results: Results) = apply { + web = results.web.map { it.toMutableList() } + news = results.news.map { it.toMutableList() } + additionalProperties = results.additionalProperties.toMutableMap() + } + + /** Web search results. */ + fun web(web: List) = web(JsonField.of(web)) + + /** + * Sets [Builder.web] to an arbitrary JSON value. + * + * You should usually call [Builder.web] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun web(web: JsonField>) = apply { + this.web = web.map { it.toMutableList() } + } + + /** + * Adds a single [WebSearchResult] to [Builder.web]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWeb(web: WebSearchResult) = apply { + this.web = + (this.web ?: JsonField.of(mutableListOf())).also { + checkKnown("web", it).add(web) + } + } + + /** News search results. Present only when the query surfaces news results. */ + fun news(news: List) = news(JsonField.of(news)) + + /** + * Sets [Builder.news] to an arbitrary JSON value. + * + * You should usually call [Builder.news] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun news(news: JsonField>) = apply { + this.news = news.map { it.toMutableList() } + } + + /** + * Adds a single [WebSearchResult] to [Builder.news]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addNews(news: WebSearchResult) = apply { + this.news = + (this.news ?: JsonField.of(mutableListOf())).also { + checkKnown("news", it).add(news) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Results]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .web() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Results = + Results( + checkRequired("web", web).map { it.toImmutable() }, + (news ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Results = apply { + if (validated) { + return@apply + } + + web().forEach { it.validate() } + news().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (web.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (news.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Results && + web == other.web && + news == other.news && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(web, news, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Results{web=$web, news=$news, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + results == other.results && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(results, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{results=$results, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WebSearchCreateResponse && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WebSearchCreateResponse{data=$data, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/WebSearchResult.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/WebSearchResult.kt new file mode 100644 index 000000000..35efe6704 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/WebSearchResult.kt @@ -0,0 +1,403 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.websearch + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.checkKnown +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.toImmutable +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class WebSearchResult +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val description: JsonField, + private val snippets: JsonField>, + private val title: JsonField, + private val url: JsonField, + private val faviconUrl: JsonField, + private val thumbnailUrl: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("snippets") + @ExcludeMissing + snippets: JsonField> = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("favicon_url") + @ExcludeMissing + faviconUrl: JsonField = JsonMissing.of(), + @JsonProperty("thumbnail_url") + @ExcludeMissing + thumbnailUrl: JsonField = JsonMissing.of(), + ) : this(description, snippets, title, url, faviconUrl, thumbnailUrl, mutableMapOf()) + + /** + * Short description or excerpt. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun description(): String = description.getRequired("description") + + /** + * Relevant text snippets from the page. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun snippets(): List = snippets.getRequired("snippets") + + /** + * Result title. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun title(): String = title.getRequired("title") + + /** + * Result URL. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * Favicon URL (if available). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun faviconUrl(): Optional = faviconUrl.getOptional("favicon_url") + + /** + * Thumbnail image URL (if available). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun thumbnailUrl(): Optional = thumbnailUrl.getOptional("thumbnail_url") + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [snippets]. + * + * Unlike [snippets], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("snippets") @ExcludeMissing fun _snippets(): JsonField> = snippets + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [faviconUrl]. + * + * Unlike [faviconUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("favicon_url") @ExcludeMissing fun _faviconUrl(): JsonField = faviconUrl + + /** + * Returns the raw JSON value of [thumbnailUrl]. + * + * Unlike [thumbnailUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("thumbnail_url") + @ExcludeMissing + fun _thumbnailUrl(): JsonField = thumbnailUrl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [WebSearchResult]. + * + * The following fields are required: + * ```java + * .description() + * .snippets() + * .title() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebSearchResult]. */ + class Builder internal constructor() { + + private var description: JsonField? = null + private var snippets: JsonField>? = null + private var title: JsonField? = null + private var url: JsonField? = null + private var faviconUrl: JsonField = JsonMissing.of() + private var thumbnailUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webSearchResult: WebSearchResult) = apply { + description = webSearchResult.description + snippets = webSearchResult.snippets.map { it.toMutableList() } + title = webSearchResult.title + url = webSearchResult.url + faviconUrl = webSearchResult.faviconUrl + thumbnailUrl = webSearchResult.thumbnailUrl + additionalProperties = webSearchResult.additionalProperties.toMutableMap() + } + + /** Short description or excerpt. */ + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { this.description = description } + + /** Relevant text snippets from the page. */ + fun snippets(snippets: List) = snippets(JsonField.of(snippets)) + + /** + * Sets [Builder.snippets] to an arbitrary JSON value. + * + * You should usually call [Builder.snippets] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun snippets(snippets: JsonField>) = apply { + this.snippets = snippets.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [snippets]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSnippet(snippet: String) = apply { + snippets = + (snippets ?: JsonField.of(mutableListOf())).also { + checkKnown("snippets", it).add(snippet) + } + } + + /** Result title. */ + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + /** Result URL. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** Favicon URL (if available). */ + fun faviconUrl(faviconUrl: String) = faviconUrl(JsonField.of(faviconUrl)) + + /** + * Sets [Builder.faviconUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.faviconUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun faviconUrl(faviconUrl: JsonField) = apply { this.faviconUrl = faviconUrl } + + /** Thumbnail image URL (if available). */ + fun thumbnailUrl(thumbnailUrl: String) = thumbnailUrl(JsonField.of(thumbnailUrl)) + + /** + * Sets [Builder.thumbnailUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.thumbnailUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun thumbnailUrl(thumbnailUrl: JsonField) = apply { + this.thumbnailUrl = thumbnailUrl + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [WebSearchResult]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .description() + * .snippets() + * .title() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WebSearchResult = + WebSearchResult( + checkRequired("description", description), + checkRequired("snippets", snippets).map { it.toImmutable() }, + checkRequired("title", title), + checkRequired("url", url), + faviconUrl, + thumbnailUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): WebSearchResult = apply { + if (validated) { + return@apply + } + + description() + snippets() + title() + url() + faviconUrl() + thumbnailUrl() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (description.asKnown().isPresent) 1 else 0) + + (snippets.asKnown().getOrNull()?.size ?: 0) + + (if (title.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (faviconUrl.asKnown().isPresent) 1 else 0) + + (if (thumbnailUrl.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WebSearchResult && + description == other.description && + snippets == other.snippets && + title == other.title && + url == other.url && + faviconUrl == other.faviconUrl && + thumbnailUrl == other.thumbnailUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + description, + snippets, + title, + url, + faviconUrl, + thumbnailUrl, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WebSearchResult{description=$description, snippets=$snippets, title=$title, url=$url, faviconUrl=$faviconUrl, thumbnailUrl=$thumbnailUrl, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/research/ResearchCitation.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/research/ResearchCitation.kt new file mode 100644 index 000000000..aa1e08833 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/research/ResearchCitation.kt @@ -0,0 +1,254 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.websearch.research + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +class ResearchCitation +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val title: JsonField, + private val url: JsonField, + private val snippet: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("snippet") @ExcludeMissing snippet: JsonField = JsonMissing.of(), + ) : this(title, url, snippet, mutableMapOf()) + + /** + * Title of the source page. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun title(): String = title.getRequired("title") + + /** + * Source URL. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * Relevant excerpt from the source (if available). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun snippet(): Optional = snippet.getOptional("snippet") + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [snippet]. + * + * Unlike [snippet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("snippet") @ExcludeMissing fun _snippet(): JsonField = snippet + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ResearchCitation]. + * + * The following fields are required: + * ```java + * .title() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ResearchCitation]. */ + class Builder internal constructor() { + + private var title: JsonField? = null + private var url: JsonField? = null + private var snippet: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(researchCitation: ResearchCitation) = apply { + title = researchCitation.title + url = researchCitation.url + snippet = researchCitation.snippet + additionalProperties = researchCitation.additionalProperties.toMutableMap() + } + + /** Title of the source page. */ + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + /** Source URL. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** Relevant excerpt from the source (if available). */ + fun snippet(snippet: String) = snippet(JsonField.of(snippet)) + + /** + * Sets [Builder.snippet] to an arbitrary JSON value. + * + * You should usually call [Builder.snippet] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun snippet(snippet: JsonField) = apply { this.snippet = snippet } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ResearchCitation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .title() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ResearchCitation = + ResearchCitation( + checkRequired("title", title), + checkRequired("url", url), + snippet, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ResearchCitation = apply { + if (validated) { + return@apply + } + + title() + url() + snippet() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (title.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (snippet.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResearchCitation && + title == other.title && + url == other.url && + snippet == other.snippet && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(title, url, snippet, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ResearchCitation{title=$title, url=$url, snippet=$snippet, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/research/ResearchCreateParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/research/ResearchCreateParams.kt new file mode 100644 index 000000000..6e8f17710 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/research/ResearchCreateParams.kt @@ -0,0 +1,813 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.websearch.research + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.telnyx.sdk.core.Enum +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.http.QueryParams +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Starts a deep research task that runs multiple searches, reads sources, and synthesizes an answer + * with citations. + * + * ## Synchronous mode (default) + * + * When `background` is `false` or omitted, the request blocks until the research completes and + * returns the answer with citations. This can take up to 120 seconds depending on + * `research_effort`. + * + * ## Asynchronous mode + * + * When `background` is `true`, the request returns immediately with a `task_id` and `status: + * pending`. Poll `GET /web_search/research/{task_id}` to check when the research completes and + * retrieve the answer. + */ +class ResearchCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: com.telnyx.sdk.core.http.Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The research question or topic. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun query(): String = body.query() + + /** + * When `true`, the research runs asynchronously. The response returns a `task_id` immediately + * instead of waiting for the result. Poll `GET /web_search/research/{task_id}` to check status. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun background(): Optional = body.background() + + /** + * Maximum number of sources to use. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxSources(): Optional = body.maxSources() + + /** + * Research depth level. `lite` is fastest, `deep` is most thorough. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun researchEffort(): Optional = body.researchEffort() + + /** + * Returns the raw JSON value of [query]. + * + * Unlike [query], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _query(): JsonField = body._query() + + /** + * Returns the raw JSON value of [background]. + * + * Unlike [background], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _background(): JsonField = body._background() + + /** + * Returns the raw JSON value of [maxSources]. + * + * Unlike [maxSources], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _maxSources(): JsonField = body._maxSources() + + /** + * Returns the raw JSON value of [researchEffort]. + * + * Unlike [researchEffort], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _researchEffort(): JsonField = body._researchEffort() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ResearchCreateParams]. + * + * The following fields are required: + * ```java + * .query() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ResearchCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: com.telnyx.sdk.core.http.Headers.Builder = + com.telnyx.sdk.core.http.Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(researchCreateParams: ResearchCreateParams) = apply { + body = researchCreateParams.body.toBuilder() + additionalHeaders = researchCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = researchCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [query] + * - [background] + * - [maxSources] + * - [researchEffort] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The research question or topic. */ + fun query(query: String) = apply { body.query(query) } + + /** + * Sets [Builder.query] to an arbitrary JSON value. + * + * You should usually call [Builder.query] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun query(query: JsonField) = apply { body.query(query) } + + /** + * When `true`, the research runs asynchronously. The response returns a `task_id` + * immediately instead of waiting for the result. Poll `GET /web_search/research/{task_id}` + * to check status. + */ + fun background(background: Boolean) = apply { body.background(background) } + + /** + * Sets [Builder.background] to an arbitrary JSON value. + * + * You should usually call [Builder.background] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun background(background: JsonField) = apply { body.background(background) } + + /** Maximum number of sources to use. */ + fun maxSources(maxSources: Long) = apply { body.maxSources(maxSources) } + + /** + * Sets [Builder.maxSources] to an arbitrary JSON value. + * + * You should usually call [Builder.maxSources] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun maxSources(maxSources: JsonField) = apply { body.maxSources(maxSources) } + + /** Research depth level. `lite` is fastest, `deep` is most thorough. */ + fun researchEffort(researchEffort: ResearchEffort) = apply { + body.researchEffort(researchEffort) + } + + /** + * Sets [Builder.researchEffort] to an arbitrary JSON value. + * + * You should usually call [Builder.researchEffort] with a well-typed [ResearchEffort] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun researchEffort(researchEffort: JsonField) = apply { + body.researchEffort(researchEffort) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ResearchCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .query() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ResearchCreateParams = + ResearchCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val query: JsonField, + private val background: JsonField, + private val maxSources: JsonField, + private val researchEffort: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("query") @ExcludeMissing query: JsonField = JsonMissing.of(), + @JsonProperty("background") + @ExcludeMissing + background: JsonField = JsonMissing.of(), + @JsonProperty("max_sources") + @ExcludeMissing + maxSources: JsonField = JsonMissing.of(), + @JsonProperty("research_effort") + @ExcludeMissing + researchEffort: JsonField = JsonMissing.of(), + ) : this(query, background, maxSources, researchEffort, mutableMapOf()) + + /** + * The research question or topic. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun query(): String = query.getRequired("query") + + /** + * When `true`, the research runs asynchronously. The response returns a `task_id` + * immediately instead of waiting for the result. Poll `GET /web_search/research/{task_id}` + * to check status. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun background(): Optional = background.getOptional("background") + + /** + * Maximum number of sources to use. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maxSources(): Optional = maxSources.getOptional("max_sources") + + /** + * Research depth level. `lite` is fastest, `deep` is most thorough. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun researchEffort(): Optional = + researchEffort.getOptional("research_effort") + + /** + * Returns the raw JSON value of [query]. + * + * Unlike [query], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("query") @ExcludeMissing fun _query(): JsonField = query + + /** + * Returns the raw JSON value of [background]. + * + * Unlike [background], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("background") + @ExcludeMissing + fun _background(): JsonField = background + + /** + * Returns the raw JSON value of [maxSources]. + * + * Unlike [maxSources], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("max_sources") @ExcludeMissing fun _maxSources(): JsonField = maxSources + + /** + * Returns the raw JSON value of [researchEffort]. + * + * Unlike [researchEffort], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("research_effort") + @ExcludeMissing + fun _researchEffort(): JsonField = researchEffort + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .query() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var query: JsonField? = null + private var background: JsonField = JsonMissing.of() + private var maxSources: JsonField = JsonMissing.of() + private var researchEffort: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + query = body.query + background = body.background + maxSources = body.maxSources + researchEffort = body.researchEffort + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The research question or topic. */ + fun query(query: String) = query(JsonField.of(query)) + + /** + * Sets [Builder.query] to an arbitrary JSON value. + * + * You should usually call [Builder.query] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun query(query: JsonField) = apply { this.query = query } + + /** + * When `true`, the research runs asynchronously. The response returns a `task_id` + * immediately instead of waiting for the result. Poll `GET + * /web_search/research/{task_id}` to check status. + */ + fun background(background: Boolean) = background(JsonField.of(background)) + + /** + * Sets [Builder.background] to an arbitrary JSON value. + * + * You should usually call [Builder.background] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun background(background: JsonField) = apply { this.background = background } + + /** Maximum number of sources to use. */ + fun maxSources(maxSources: Long) = maxSources(JsonField.of(maxSources)) + + /** + * Sets [Builder.maxSources] to an arbitrary JSON value. + * + * You should usually call [Builder.maxSources] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun maxSources(maxSources: JsonField) = apply { this.maxSources = maxSources } + + /** Research depth level. `lite` is fastest, `deep` is most thorough. */ + fun researchEffort(researchEffort: ResearchEffort) = + researchEffort(JsonField.of(researchEffort)) + + /** + * Sets [Builder.researchEffort] to an arbitrary JSON value. + * + * You should usually call [Builder.researchEffort] with a well-typed [ResearchEffort] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun researchEffort(researchEffort: JsonField) = apply { + this.researchEffort = researchEffort + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .query() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("query", query), + background, + maxSources, + researchEffort, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Body = apply { + if (validated) { + return@apply + } + + query() + background() + maxSources() + researchEffort().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (query.asKnown().isPresent) 1 else 0) + + (if (background.asKnown().isPresent) 1 else 0) + + (if (maxSources.asKnown().isPresent) 1 else 0) + + (researchEffort.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + query == other.query && + background == other.background && + maxSources == other.maxSources && + researchEffort == other.researchEffort && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(query, background, maxSources, researchEffort, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{query=$query, background=$background, maxSources=$maxSources, researchEffort=$researchEffort, additionalProperties=$additionalProperties}" + } + + /** Research depth level. `lite` is fastest, `deep` is most thorough. */ + class ResearchEffort @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LITE = of("lite") + + @JvmField val STANDARD = of("standard") + + @JvmField val DEEP = of("deep") + + @JvmStatic fun of(value: String) = ResearchEffort(JsonField.of(value)) + } + + /** An enum containing [ResearchEffort]'s known values. */ + enum class Known { + LITE, + STANDARD, + DEEP, + } + + /** + * An enum containing [ResearchEffort]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ResearchEffort] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LITE, + STANDARD, + DEEP, + /** + * An enum member indicating that [ResearchEffort] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LITE -> Value.LITE + STANDARD -> Value.STANDARD + DEEP -> Value.DEEP + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LITE -> Known.LITE + STANDARD -> Known.STANDARD + DEEP -> Known.DEEP + else -> throw TelnyxInvalidDataException("Unknown ResearchEffort: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { TelnyxInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ResearchEffort = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResearchEffort && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResearchCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ResearchCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/research/ResearchCreateResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/research/ResearchCreateResponse.kt new file mode 100644 index 000000000..ad3b65328 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/research/ResearchCreateResponse.kt @@ -0,0 +1,1036 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.websearch.research + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.BaseDeserializer +import com.telnyx.sdk.core.BaseSerializer +import com.telnyx.sdk.core.Enum +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.allMaxBy +import com.telnyx.sdk.core.checkKnown +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.getOrThrow +import com.telnyx.sdk.core.toImmutable +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ResearchCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of() + ) : this(data, mutableMapOf()) + + /** + * Synchronous research response (when `background` is false or unset). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ResearchCreateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ResearchCreateResponse]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(researchCreateResponse: ResearchCreateResponse) = apply { + data = researchCreateResponse.data + additionalProperties = researchCreateResponse.additionalProperties.toMutableMap() + } + + /** Synchronous research response (when `background` is false or unset). */ + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + /** Alias for calling [data] with `Data.ofResearchResponseSync(researchResponseSync)`. */ + fun data(researchResponseSync: Data.ResearchResponseSync) = + data(Data.ofResearchResponseSync(researchResponseSync)) + + /** Alias for calling [data] with `Data.ofResearchResponseAsync(researchResponseAsync)`. */ + fun data(researchResponseAsync: Data.ResearchResponseAsync) = + data(Data.ofResearchResponseAsync(researchResponseAsync)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ResearchCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ResearchCreateResponse = + ResearchCreateResponse(data, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ResearchCreateResponse = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (data.asKnown().getOrNull()?.validity() ?: 0) + + /** Synchronous research response (when `background` is false or unset). */ + @JsonDeserialize(using = Data.Deserializer::class) + @JsonSerialize(using = Data.Serializer::class) + class Data + private constructor( + private val researchResponseSync: ResearchResponseSync? = null, + private val researchResponseAsync: ResearchResponseAsync? = null, + private val _json: JsonValue? = null, + ) { + + /** Synchronous research response (when `background` is false or unset). */ + fun researchResponseSync(): Optional = + Optional.ofNullable(researchResponseSync) + + /** Asynchronous research response (when `background` is true). */ + fun researchResponseAsync(): Optional = + Optional.ofNullable(researchResponseAsync) + + fun isResearchResponseSync(): Boolean = researchResponseSync != null + + fun isResearchResponseAsync(): Boolean = researchResponseAsync != null + + /** Synchronous research response (when `background` is false or unset). */ + fun asResearchResponseSync(): ResearchResponseSync = + researchResponseSync.getOrThrow("researchResponseSync") + + /** Asynchronous research response (when `background` is true). */ + fun asResearchResponseAsync(): ResearchResponseAsync = + researchResponseAsync.getOrThrow("researchResponseAsync") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of + * the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.telnyx.sdk.core.JsonValue; + * import java.util.Optional; + * + * Optional result = data.accept(new Data.Visitor>() { + * @Override + * public Optional visitResearchResponseSync(ResearchResponseSync researchResponseSync) { + * return Optional.of(researchResponseSync.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws TelnyxInvalidDataException if [Visitor.unknown] is not overridden in [visitor] + * and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + researchResponseSync != null -> + visitor.visitResearchResponseSync(researchResponseSync) + researchResponseAsync != null -> + visitor.visitResearchResponseAsync(researchResponseAsync) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Data = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitResearchResponseSync( + researchResponseSync: ResearchResponseSync + ) { + researchResponseSync.validate() + } + + override fun visitResearchResponseAsync( + researchResponseAsync: ResearchResponseAsync + ) { + researchResponseAsync.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitResearchResponseSync( + researchResponseSync: ResearchResponseSync + ) = researchResponseSync.validity() + + override fun visitResearchResponseAsync( + researchResponseAsync: ResearchResponseAsync + ) = researchResponseAsync.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + researchResponseSync == other.researchResponseSync && + researchResponseAsync == other.researchResponseAsync + } + + override fun hashCode(): Int = Objects.hash(researchResponseSync, researchResponseAsync) + + override fun toString(): String = + when { + researchResponseSync != null -> "Data{researchResponseSync=$researchResponseSync}" + researchResponseAsync != null -> + "Data{researchResponseAsync=$researchResponseAsync}" + _json != null -> "Data{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Data") + } + + companion object { + + /** Synchronous research response (when `background` is false or unset). */ + @JvmStatic + fun ofResearchResponseSync(researchResponseSync: ResearchResponseSync) = + Data(researchResponseSync = researchResponseSync) + + /** Asynchronous research response (when `background` is true). */ + @JvmStatic + fun ofResearchResponseAsync(researchResponseAsync: ResearchResponseAsync) = + Data(researchResponseAsync = researchResponseAsync) + } + + /** An interface that defines how to map each variant of [Data] to a value of type [T]. */ + interface Visitor { + + /** Synchronous research response (when `background` is false or unset). */ + fun visitResearchResponseSync(researchResponseSync: ResearchResponseSync): T + + /** Asynchronous research response (when `background` is true). */ + fun visitResearchResponseAsync(researchResponseAsync: ResearchResponseAsync): T + + /** + * Maps an unknown variant of [Data] to a value of type [T]. + * + * An instance of [Data] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws TelnyxInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw TelnyxInvalidDataException("Unknown Data: $json") + } + } + + internal class Deserializer : BaseDeserializer(Data::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Data { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Data(researchResponseSync = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Data(researchResponseAsync = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Data(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Data::class) { + + override fun serialize( + value: Data, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.researchResponseSync != null -> + generator.writeObject(value.researchResponseSync) + value.researchResponseAsync != null -> + generator.writeObject(value.researchResponseAsync) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Data") + } + } + } + + /** Synchronous research response (when `background` is false or unset). */ + class ResearchResponseSync + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val answer: JsonField, + private val citations: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("answer") + @ExcludeMissing + answer: JsonField = JsonMissing.of(), + @JsonProperty("citations") + @ExcludeMissing + citations: JsonField> = JsonMissing.of(), + ) : this(answer, citations, mutableMapOf()) + + /** + * The synthesized research answer. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun answer(): String = answer.getRequired("answer") + + /** + * Sources cited in the answer. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun citations(): Optional> = citations.getOptional("citations") + + /** + * Returns the raw JSON value of [answer]. + * + * Unlike [answer], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("answer") @ExcludeMissing fun _answer(): JsonField = answer + + /** + * Returns the raw JSON value of [citations]. + * + * Unlike [citations], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("citations") + @ExcludeMissing + fun _citations(): JsonField> = citations + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ResearchResponseSync]. + * + * The following fields are required: + * ```java + * .answer() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ResearchResponseSync]. */ + class Builder internal constructor() { + + private var answer: JsonField? = null + private var citations: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(researchResponseSync: ResearchResponseSync) = apply { + answer = researchResponseSync.answer + citations = researchResponseSync.citations.map { it.toMutableList() } + additionalProperties = researchResponseSync.additionalProperties.toMutableMap() + } + + /** The synthesized research answer. */ + fun answer(answer: String) = answer(JsonField.of(answer)) + + /** + * Sets [Builder.answer] to an arbitrary JSON value. + * + * You should usually call [Builder.answer] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun answer(answer: JsonField) = apply { this.answer = answer } + + /** Sources cited in the answer. */ + fun citations(citations: List) = + citations(JsonField.of(citations)) + + /** + * Sets [Builder.citations] to an arbitrary JSON value. + * + * You should usually call [Builder.citations] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun citations(citations: JsonField>) = apply { + this.citations = citations.map { it.toMutableList() } + } + + /** + * Adds a single [ResearchCitation] to [citations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCitation(citation: ResearchCitation) = apply { + citations = + (citations ?: JsonField.of(mutableListOf())).also { + checkKnown("citations", it).add(citation) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ResearchResponseSync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .answer() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ResearchResponseSync = + ResearchResponseSync( + checkRequired("answer", answer), + (citations ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ResearchResponseSync = apply { + if (validated) { + return@apply + } + + answer() + citations().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (answer.asKnown().isPresent) 1 else 0) + + (citations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResearchResponseSync && + answer == other.answer && + citations == other.citations && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(answer, citations, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ResearchResponseSync{answer=$answer, citations=$citations, additionalProperties=$additionalProperties}" + } + + /** Asynchronous research response (when `background` is true). */ + class ResearchResponseAsync + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val status: JsonField, + private val taskId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("task_id") + @ExcludeMissing + taskId: JsonField = JsonMissing.of(), + ) : this(status, taskId, mutableMapOf()) + + /** + * Current status of the research task. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun status(): Status = status.getRequired("status") + + /** + * Unique identifier for the research task. Use this to poll the status. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun taskId(): String = taskId.getRequired("task_id") + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [taskId]. + * + * Unlike [taskId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("task_id") @ExcludeMissing fun _taskId(): JsonField = taskId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [ResearchResponseAsync]. + * + * The following fields are required: + * ```java + * .status() + * .taskId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ResearchResponseAsync]. */ + class Builder internal constructor() { + + private var status: JsonField? = null + private var taskId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(researchResponseAsync: ResearchResponseAsync) = apply { + status = researchResponseAsync.status + taskId = researchResponseAsync.taskId + additionalProperties = researchResponseAsync.additionalProperties.toMutableMap() + } + + /** Current status of the research task. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** Unique identifier for the research task. Use this to poll the status. */ + fun taskId(taskId: String) = taskId(JsonField.of(taskId)) + + /** + * Sets [Builder.taskId] to an arbitrary JSON value. + * + * You should usually call [Builder.taskId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taskId(taskId: JsonField) = apply { this.taskId = taskId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ResearchResponseAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .status() + * .taskId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ResearchResponseAsync = + ResearchResponseAsync( + checkRequired("status", status), + checkRequired("taskId", taskId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ResearchResponseAsync = apply { + if (validated) { + return@apply + } + + status().validate() + taskId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (taskId.asKnown().isPresent) 1 else 0) + + /** Current status of the research task. */ + class Status @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PENDING = of("pending") + + @JvmField val RUNNING = of("running") + + @JvmField val COMPLETED = of("completed") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + PENDING, + RUNNING, + COMPLETED, + FAILED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PENDING, + RUNNING, + COMPLETED, + FAILED, + /** + * An enum member indicating that [Status] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PENDING -> Value.PENDING + RUNNING -> Value.RUNNING + COMPLETED -> Value.COMPLETED + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws TelnyxInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + RUNNING -> Known.RUNNING + COMPLETED -> Known.COMPLETED + FAILED -> Known.FAILED + else -> throw TelnyxInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws TelnyxInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + TelnyxInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResearchResponseAsync && + status == other.status && + taskId == other.taskId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(status, taskId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ResearchResponseAsync{status=$status, taskId=$taskId, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResearchCreateResponse && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ResearchCreateResponse{data=$data, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/research/ResearchRetrieveParams.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/research/ResearchRetrieveParams.kt new file mode 100644 index 000000000..f31116227 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/research/ResearchRetrieveParams.kt @@ -0,0 +1,194 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.websearch.research + +import com.telnyx.sdk.core.Params +import com.telnyx.sdk.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Polls the status of a previously started asynchronous research task. When the status is + * `completed`, the response includes the answer and citations. When the status is `failed`, the + * response includes an error message. + */ +class ResearchRetrieveParams +private constructor( + private val taskId: String?, + private val additionalHeaders: com.telnyx.sdk.core.http.Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun taskId(): Optional = Optional.ofNullable(taskId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ResearchRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ResearchRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ResearchRetrieveParams]. */ + class Builder internal constructor() { + + private var taskId: String? = null + private var additionalHeaders: com.telnyx.sdk.core.http.Headers.Builder = + com.telnyx.sdk.core.http.Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(researchRetrieveParams: ResearchRetrieveParams) = apply { + taskId = researchRetrieveParams.taskId + additionalHeaders = researchRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = researchRetrieveParams.additionalQueryParams.toBuilder() + } + + fun taskId(taskId: String?) = apply { this.taskId = taskId } + + /** Alias for calling [Builder.taskId] with `taskId.orElse(null)`. */ + fun taskId(taskId: Optional) = taskId(taskId.getOrNull()) + + fun additionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: com.telnyx.sdk.core.http.Headers) = + apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ResearchRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ResearchRetrieveParams = + ResearchRetrieveParams(taskId, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> taskId ?: "" + else -> "" + } + + override fun _headers(): com.telnyx.sdk.core.http.Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResearchRetrieveParams && + taskId == other.taskId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(taskId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ResearchRetrieveParams{taskId=$taskId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/research/ResearchRetrieveResponse.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/research/ResearchRetrieveResponse.kt new file mode 100644 index 000000000..42b18eba8 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/models/websearch/research/ResearchRetrieveResponse.kt @@ -0,0 +1,653 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.websearch.research + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.telnyx.sdk.core.Enum +import com.telnyx.sdk.core.ExcludeMissing +import com.telnyx.sdk.core.JsonField +import com.telnyx.sdk.core.JsonMissing +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.checkKnown +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.toImmutable +import com.telnyx.sdk.errors.TelnyxInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ResearchRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of() + ) : this(data, mutableMapOf()) + + /** + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ResearchRetrieveResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ResearchRetrieveResponse]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(researchRetrieveResponse: ResearchRetrieveResponse) = apply { + data = researchRetrieveResponse.data + additionalProperties = researchRetrieveResponse.additionalProperties.toMutableMap() + } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ResearchRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ResearchRetrieveResponse = + ResearchRetrieveResponse(data, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ResearchRetrieveResponse = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (data.asKnown().getOrNull()?.validity() ?: 0) + + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val status: JsonField, + private val taskId: JsonField, + private val answer: JsonField, + private val citations: JsonField>, + private val error: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("task_id") @ExcludeMissing taskId: JsonField = JsonMissing.of(), + @JsonProperty("answer") @ExcludeMissing answer: JsonField = JsonMissing.of(), + @JsonProperty("citations") + @ExcludeMissing + citations: JsonField> = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + ) : this(status, taskId, answer, citations, error, mutableMapOf()) + + /** + * Current status of the research task. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * The research task identifier. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun taskId(): String = taskId.getRequired("task_id") + + /** + * The synthesized research answer (present when status is `completed`). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun answer(): Optional = answer.getOptional("answer") + + /** + * Sources cited in the answer (present when status is `completed`). + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun citations(): Optional> = citations.getOptional("citations") + + /** + * Always present in poll responses; `null` unless the task failed. + * + * @throws TelnyxInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun error(): Optional = error.getOptional("error") + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [taskId]. + * + * Unlike [taskId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("task_id") @ExcludeMissing fun _taskId(): JsonField = taskId + + /** + * Returns the raw JSON value of [answer]. + * + * Unlike [answer], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("answer") @ExcludeMissing fun _answer(): JsonField = answer + + /** + * Returns the raw JSON value of [citations]. + * + * Unlike [citations], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("citations") + @ExcludeMissing + fun _citations(): JsonField> = citations + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .status() + * .taskId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var status: JsonField? = null + private var taskId: JsonField? = null + private var answer: JsonField = JsonMissing.of() + private var citations: JsonField>? = null + private var error: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + status = data.status + taskId = data.taskId + answer = data.answer + citations = data.citations.map { it.toMutableList() } + error = data.error + additionalProperties = data.additionalProperties.toMutableMap() + } + + /** Current status of the research task. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The research task identifier. */ + fun taskId(taskId: String) = taskId(JsonField.of(taskId)) + + /** + * Sets [Builder.taskId] to an arbitrary JSON value. + * + * You should usually call [Builder.taskId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taskId(taskId: JsonField) = apply { this.taskId = taskId } + + /** The synthesized research answer (present when status is `completed`). */ + fun answer(answer: String) = answer(JsonField.of(answer)) + + /** + * Sets [Builder.answer] to an arbitrary JSON value. + * + * You should usually call [Builder.answer] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun answer(answer: JsonField) = apply { this.answer = answer } + + /** Sources cited in the answer (present when status is `completed`). */ + fun citations(citations: List) = citations(JsonField.of(citations)) + + /** + * Sets [Builder.citations] to an arbitrary JSON value. + * + * You should usually call [Builder.citations] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun citations(citations: JsonField>) = apply { + this.citations = citations.map { it.toMutableList() } + } + + /** + * Adds a single [ResearchCitation] to [citations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCitation(citation: ResearchCitation) = apply { + citations = + (citations ?: JsonField.of(mutableListOf())).also { + checkKnown("citations", it).add(citation) + } + } + + /** Always present in poll responses; `null` unless the task failed. */ + fun error(error: String?) = error(JsonField.ofNullable(error)) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun error(error: JsonField) = apply { this.error = error } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .status() + * .taskId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("status", status), + checkRequired("taskId", taskId), + answer, + (citations ?: JsonMissing.of()).map { it.toImmutable() }, + error, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Data = apply { + if (validated) { + return@apply + } + + status().validate() + taskId() + answer() + citations().ifPresent { it.forEach { it.validate() } } + error() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (taskId.asKnown().isPresent) 1 else 0) + + (if (answer.asKnown().isPresent) 1 else 0) + + (citations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (error.asKnown().isPresent) 1 else 0) + + /** Current status of the research task. */ + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PENDING = of("pending") + + @JvmField val RUNNING = of("running") + + @JvmField val COMPLETED = of("completed") + + @JvmField val FAILED = of("failed") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + PENDING, + RUNNING, + COMPLETED, + FAILED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PENDING, + RUNNING, + COMPLETED, + FAILED, + /** + * An enum member indicating that [Status] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PENDING -> Value.PENDING + RUNNING -> Value.RUNNING + COMPLETED -> Value.COMPLETED + FAILED -> Value.FAILED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws TelnyxInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + RUNNING -> Known.RUNNING + COMPLETED -> Known.COMPLETED + FAILED -> Known.FAILED + else -> throw TelnyxInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws TelnyxInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + TelnyxInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws TelnyxInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: TelnyxInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + status == other.status && + taskId == other.taskId && + answer == other.answer && + citations == other.citations && + error == other.error && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(status, taskId, answer, citations, error, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{status=$status, taskId=$taskId, answer=$answer, citations=$citations, error=$error, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ResearchRetrieveResponse && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ResearchRetrieveResponse{data=$data, additionalProperties=$additionalProperties}" +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/StorageServiceAsync.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/StorageServiceAsync.kt index 5a31c5793..01990847b 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/StorageServiceAsync.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/StorageServiceAsync.kt @@ -12,6 +12,7 @@ import com.telnyx.sdk.services.async.storage.CloudfServiceAsync import com.telnyx.sdk.services.async.storage.KvServiceAsync import com.telnyx.sdk.services.async.storage.MigrationServiceAsync import com.telnyx.sdk.services.async.storage.MigrationSourceServiceAsync +import com.telnyx.sdk.services.async.storage.SqldbServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -47,6 +48,9 @@ interface StorageServiceAsync { */ fun cloudfs(): CloudfServiceAsync + /** Manage SQL databases and run SQL against them */ + fun sqldbs(): SqldbServiceAsync + /** List the external storage providers and regions supported as migration sources. */ fun listMigrationSourceCoverage(): CompletableFuture = @@ -104,6 +108,9 @@ interface StorageServiceAsync { */ fun cloudfs(): CloudfServiceAsync.WithRawResponse + /** Manage SQL databases and run SQL against them */ + fun sqldbs(): SqldbServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /storage/migration_source_coverage`, but is * otherwise the same as [StorageServiceAsync.listMigrationSourceCoverage]. diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/StorageServiceAsyncImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/StorageServiceAsyncImpl.kt index 288a0b85e..67d790743 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/StorageServiceAsyncImpl.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/StorageServiceAsyncImpl.kt @@ -26,6 +26,8 @@ import com.telnyx.sdk.services.async.storage.MigrationServiceAsync import com.telnyx.sdk.services.async.storage.MigrationServiceAsyncImpl import com.telnyx.sdk.services.async.storage.MigrationSourceServiceAsync import com.telnyx.sdk.services.async.storage.MigrationSourceServiceAsyncImpl +import com.telnyx.sdk.services.async.storage.SqldbServiceAsync +import com.telnyx.sdk.services.async.storage.SqldbServiceAsyncImpl import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -51,6 +53,8 @@ class StorageServiceAsyncImpl internal constructor(private val clientOptions: Cl private val cloudfs: CloudfServiceAsync by lazy { CloudfServiceAsyncImpl(clientOptions) } + private val sqldbs: SqldbServiceAsync by lazy { SqldbServiceAsyncImpl(clientOptions) } + override fun withRawResponse(): StorageServiceAsync.WithRawResponse = withRawResponse override fun withOptions(modifier: Consumer): StorageServiceAsync = @@ -73,6 +77,9 @@ class StorageServiceAsyncImpl internal constructor(private val clientOptions: Cl */ override fun cloudfs(): CloudfServiceAsync = cloudfs + /** Manage SQL databases and run SQL against them */ + override fun sqldbs(): SqldbServiceAsync = sqldbs + override fun listMigrationSourceCoverage( params: StorageListMigrationSourceCoverageParams, requestOptions: RequestOptions, @@ -108,6 +115,10 @@ class StorageServiceAsyncImpl internal constructor(private val clientOptions: Cl CloudfServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val sqldbs: SqldbServiceAsync.WithRawResponse by lazy { + SqldbServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): StorageServiceAsync.WithRawResponse = @@ -134,6 +145,9 @@ class StorageServiceAsyncImpl internal constructor(private val clientOptions: Cl */ override fun cloudfs(): CloudfServiceAsync.WithRawResponse = cloudfs + /** Manage SQL databases and run SQL against them */ + override fun sqldbs(): SqldbServiceAsync.WithRawResponse = sqldbs + private val listMigrationSourceCoverageHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/WebSearchServiceAsync.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/WebSearchServiceAsync.kt new file mode 100644 index 000000000..90966254d --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/WebSearchServiceAsync.kt @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.models.websearch.WebSearchContentsParams +import com.telnyx.sdk.models.websearch.WebSearchContentsResponse +import com.telnyx.sdk.models.websearch.WebSearchCreateParams +import com.telnyx.sdk.models.websearch.WebSearchCreateResponse +import com.telnyx.sdk.services.async.websearch.ResearchServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface WebSearchServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): WebSearchServiceAsync + + /** Deep research with citations and async task polling. */ + fun research(): ResearchServiceAsync + + /** + * Performs a real-time web search and returns structured, LLM-ready JSON results with titles, + * URLs, descriptions, and snippets. Supports filtering by domain, country, safe search, + * freshness, and live crawl. + * + * **Note:** `include_domains` and `exclude_domains` cannot be used in the same request. Use one + * or the other. + */ + fun create(params: WebSearchCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: WebSearchCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Retrieves clean HTML or Markdown content from a list of URLs. Supports up to 20 URLs per + * request (public API limit). Specify which formats to return: `html`, `markdown`, `metadata`. + */ + fun contents(params: WebSearchContentsParams): CompletableFuture = + contents(params, RequestOptions.none()) + + /** @see contents */ + fun contents( + params: WebSearchContentsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [WebSearchServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): WebSearchServiceAsync.WithRawResponse + + /** Deep research with citations and async task polling. */ + fun research(): ResearchServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /web_search`, but is otherwise the same as + * [WebSearchServiceAsync.create]. + */ + fun create( + params: WebSearchCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: WebSearchCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /web_search/contents`, but is otherwise the same as + * [WebSearchServiceAsync.contents]. + */ + fun contents( + params: WebSearchContentsParams + ): CompletableFuture> = + contents(params, RequestOptions.none()) + + /** @see contents */ + fun contents( + params: WebSearchContentsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/WebSearchServiceAsyncImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/WebSearchServiceAsyncImpl.kt new file mode 100644 index 000000000..b62660804 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/WebSearchServiceAsyncImpl.kt @@ -0,0 +1,140 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.handlers.errorBodyHandler +import com.telnyx.sdk.core.handlers.errorHandler +import com.telnyx.sdk.core.handlers.jsonHandler +import com.telnyx.sdk.core.http.HttpMethod +import com.telnyx.sdk.core.http.HttpRequest +import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponse.Handler +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.core.http.json +import com.telnyx.sdk.core.http.parseable +import com.telnyx.sdk.core.prepareAsync +import com.telnyx.sdk.models.websearch.WebSearchContentsParams +import com.telnyx.sdk.models.websearch.WebSearchContentsResponse +import com.telnyx.sdk.models.websearch.WebSearchCreateParams +import com.telnyx.sdk.models.websearch.WebSearchCreateResponse +import com.telnyx.sdk.services.async.websearch.ResearchServiceAsync +import com.telnyx.sdk.services.async.websearch.ResearchServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class WebSearchServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + WebSearchServiceAsync { + + private val withRawResponse: WebSearchServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val research: ResearchServiceAsync by lazy { ResearchServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): WebSearchServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): WebSearchServiceAsync = + WebSearchServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + /** Deep research with citations and async task polling. */ + override fun research(): ResearchServiceAsync = research + + override fun create( + params: WebSearchCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /web_search + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun contents( + params: WebSearchContentsParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /web_search/contents + withRawResponse().contents(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + WebSearchServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val research: ResearchServiceAsync.WithRawResponse by lazy { + ResearchServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): WebSearchServiceAsync.WithRawResponse = + WebSearchServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + /** Deep research with citations and async task polling. */ + override fun research(): ResearchServiceAsync.WithRawResponse = research + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: WebSearchCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("web_search") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val contentsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun contents( + params: WebSearchContentsParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("web_search", "contents") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { contentsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/phonenumbers/VoicemailServiceAsync.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/phonenumbers/VoicemailServiceAsync.kt index 0c831fcf9..b57b0e8e1 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/phonenumbers/VoicemailServiceAsync.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/phonenumbers/VoicemailServiceAsync.kt @@ -29,7 +29,12 @@ interface VoicemailServiceAsync { */ fun withOptions(modifier: Consumer): VoicemailServiceAsync - /** Create voicemail settings for a phone number */ + /** + * Create voicemail settings for a phone number. You can also configure a custom greeting by + * setting the `greeting` object: use `mode` `custom_greeting` together with a `media_name` that + * points to an audio file uploaded through the Media Storage API, or `mode` `default` to use + * the standard system greeting. + */ fun create( phoneNumberId: String, params: VoicemailCreateParams, @@ -90,7 +95,12 @@ interface VoicemailServiceAsync { ): CompletableFuture = retrieve(phoneNumberId, VoicemailRetrieveParams.none(), requestOptions) - /** Update voicemail settings for a phone number */ + /** + * Update voicemail settings for a phone number. You can also configure a custom greeting by + * setting the `greeting` object: use `mode` `custom_greeting` together with a `media_name` that + * points to an audio file uploaded through the Media Storage API, or `mode` `default` to use + * the standard system greeting. + */ fun update( phoneNumberId: String, params: VoicemailUpdateParams, diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/simcards/ActionServiceAsync.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/simcards/ActionServiceAsync.kt index 1e5ce93ac..9631df8da 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/simcards/ActionServiceAsync.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/simcards/ActionServiceAsync.kt @@ -13,8 +13,12 @@ import com.telnyx.sdk.models.simcards.actions.ActionBulkSetPublicIpsParams import com.telnyx.sdk.models.simcards.actions.ActionBulkSetPublicIpsResponse import com.telnyx.sdk.models.simcards.actions.ActionDisableParams import com.telnyx.sdk.models.simcards.actions.ActionDisableResponse +import com.telnyx.sdk.models.simcards.actions.ActionDisableVoiceParams +import com.telnyx.sdk.models.simcards.actions.ActionDisableVoiceResponse import com.telnyx.sdk.models.simcards.actions.ActionEnableParams import com.telnyx.sdk.models.simcards.actions.ActionEnableResponse +import com.telnyx.sdk.models.simcards.actions.ActionEnableVoiceParams +import com.telnyx.sdk.models.simcards.actions.ActionEnableVoiceResponse import com.telnyx.sdk.models.simcards.actions.ActionListPageAsync import com.telnyx.sdk.models.simcards.actions.ActionListParams import com.telnyx.sdk.models.simcards.actions.ActionRemovePublicIpParams @@ -207,6 +211,49 @@ interface ActionServiceAsync { ): CompletableFuture = disable(id, ActionDisableParams.none(), requestOptions) + /** + * This API disables voice calling on a SIM card. The SIM card will no longer be able to make or + * receive calls.
    The API will trigger an asynchronous operation called a SIM Card Action. + * The status of the SIM Card Action can be followed through the + * [List SIM Card Action](https://developers.telnyx.com/api-reference/sim-card-actions/list-sim-card-actions) + * API. + */ + fun disableVoice(id: String): CompletableFuture = + disableVoice(id, ActionDisableVoiceParams.none()) + + /** @see disableVoice */ + fun disableVoice( + id: String, + params: ActionDisableVoiceParams = ActionDisableVoiceParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + disableVoice(params.toBuilder().id(id).build(), requestOptions) + + /** @see disableVoice */ + fun disableVoice( + id: String, + params: ActionDisableVoiceParams = ActionDisableVoiceParams.none(), + ): CompletableFuture = + disableVoice(id, params, RequestOptions.none()) + + /** @see disableVoice */ + fun disableVoice( + params: ActionDisableVoiceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see disableVoice */ + fun disableVoice( + params: ActionDisableVoiceParams + ): CompletableFuture = disableVoice(params, RequestOptions.none()) + + /** @see disableVoice */ + fun disableVoice( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = + disableVoice(id, ActionDisableVoiceParams.none(), requestOptions) + /** * This API enables a SIM card, connecting it to the network and making it possible to consume * data.
    To enable a SIM card, it must be associated with a SIM card group.
    The API @@ -250,6 +297,49 @@ interface ActionServiceAsync { ): CompletableFuture = enable(id, ActionEnableParams.none(), requestOptions) + /** + * This API enables voice calling on a SIM card. When a connection_id is provided, + * the SIM is associated with the specified Mobile Voice Connection. The connection must be + * owned by the same user and of type mobile_voice.
    The API will trigger an + * asynchronous operation called a SIM Card Action. The status of the SIM Card Action can be + * followed through the + * [List SIM Card Action](https://developers.telnyx.com/api-reference/sim-card-actions/list-sim-card-actions) + * API. + */ + fun enableVoice(id: String): CompletableFuture = + enableVoice(id, ActionEnableVoiceParams.none()) + + /** @see enableVoice */ + fun enableVoice( + id: String, + params: ActionEnableVoiceParams = ActionEnableVoiceParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + enableVoice(params.toBuilder().id(id).build(), requestOptions) + + /** @see enableVoice */ + fun enableVoice( + id: String, + params: ActionEnableVoiceParams = ActionEnableVoiceParams.none(), + ): CompletableFuture = enableVoice(id, params, RequestOptions.none()) + + /** @see enableVoice */ + fun enableVoice( + params: ActionEnableVoiceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see enableVoice */ + fun enableVoice(params: ActionEnableVoiceParams): CompletableFuture = + enableVoice(params, RequestOptions.none()) + + /** @see enableVoice */ + fun enableVoice( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = + enableVoice(id, ActionEnableVoiceParams.none(), requestOptions) + /** * This API removes an existing public IP from a SIM card.

    The API will trigger an * asynchronous operation called a SIM Card Action. The status of the SIM Card Action can be @@ -568,6 +658,49 @@ interface ActionServiceAsync { ): CompletableFuture> = disable(id, ActionDisableParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /sim_cards/{id}/actions/disable_voice`, but is + * otherwise the same as [ActionServiceAsync.disableVoice]. + */ + fun disableVoice( + id: String + ): CompletableFuture> = + disableVoice(id, ActionDisableVoiceParams.none()) + + /** @see disableVoice */ + fun disableVoice( + id: String, + params: ActionDisableVoiceParams = ActionDisableVoiceParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + disableVoice(params.toBuilder().id(id).build(), requestOptions) + + /** @see disableVoice */ + fun disableVoice( + id: String, + params: ActionDisableVoiceParams = ActionDisableVoiceParams.none(), + ): CompletableFuture> = + disableVoice(id, params, RequestOptions.none()) + + /** @see disableVoice */ + fun disableVoice( + params: ActionDisableVoiceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see disableVoice */ + fun disableVoice( + params: ActionDisableVoiceParams + ): CompletableFuture> = + disableVoice(params, RequestOptions.none()) + + /** @see disableVoice */ + fun disableVoice( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + disableVoice(id, ActionDisableVoiceParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /sim_cards/{id}/actions/enable`, but is otherwise * the same as [ActionServiceAsync.enable]. @@ -609,6 +742,47 @@ interface ActionServiceAsync { ): CompletableFuture> = enable(id, ActionEnableParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /sim_cards/{id}/actions/enable_voice`, but is + * otherwise the same as [ActionServiceAsync.enableVoice]. + */ + fun enableVoice(id: String): CompletableFuture> = + enableVoice(id, ActionEnableVoiceParams.none()) + + /** @see enableVoice */ + fun enableVoice( + id: String, + params: ActionEnableVoiceParams = ActionEnableVoiceParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + enableVoice(params.toBuilder().id(id).build(), requestOptions) + + /** @see enableVoice */ + fun enableVoice( + id: String, + params: ActionEnableVoiceParams = ActionEnableVoiceParams.none(), + ): CompletableFuture> = + enableVoice(id, params, RequestOptions.none()) + + /** @see enableVoice */ + fun enableVoice( + params: ActionEnableVoiceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see enableVoice */ + fun enableVoice( + params: ActionEnableVoiceParams + ): CompletableFuture> = + enableVoice(params, RequestOptions.none()) + + /** @see enableVoice */ + fun enableVoice( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + enableVoice(id, ActionEnableVoiceParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /sim_cards/{id}/actions/remove_public_ip`, but is * otherwise the same as [ActionServiceAsync.removePublicIp]. diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/simcards/ActionServiceAsyncImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/simcards/ActionServiceAsyncImpl.kt index 2db438395..f9d578a66 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/simcards/ActionServiceAsyncImpl.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/simcards/ActionServiceAsyncImpl.kt @@ -24,8 +24,12 @@ import com.telnyx.sdk.models.simcards.actions.ActionBulkSetPublicIpsParams import com.telnyx.sdk.models.simcards.actions.ActionBulkSetPublicIpsResponse import com.telnyx.sdk.models.simcards.actions.ActionDisableParams import com.telnyx.sdk.models.simcards.actions.ActionDisableResponse +import com.telnyx.sdk.models.simcards.actions.ActionDisableVoiceParams +import com.telnyx.sdk.models.simcards.actions.ActionDisableVoiceResponse import com.telnyx.sdk.models.simcards.actions.ActionEnableParams import com.telnyx.sdk.models.simcards.actions.ActionEnableResponse +import com.telnyx.sdk.models.simcards.actions.ActionEnableVoiceParams +import com.telnyx.sdk.models.simcards.actions.ActionEnableVoiceResponse import com.telnyx.sdk.models.simcards.actions.ActionListPageAsync import com.telnyx.sdk.models.simcards.actions.ActionListPageResponse import com.telnyx.sdk.models.simcards.actions.ActionListParams @@ -97,6 +101,13 @@ class ActionServiceAsyncImpl internal constructor(private val clientOptions: Cli // post /sim_cards/{id}/actions/disable withRawResponse().disable(params, requestOptions).thenApply { it.parse() } + override fun disableVoice( + params: ActionDisableVoiceParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /sim_cards/{id}/actions/disable_voice + withRawResponse().disableVoice(params, requestOptions).thenApply { it.parse() } + override fun enable( params: ActionEnableParams, requestOptions: RequestOptions, @@ -104,6 +115,13 @@ class ActionServiceAsyncImpl internal constructor(private val clientOptions: Cli // post /sim_cards/{id}/actions/enable withRawResponse().enable(params, requestOptions).thenApply { it.parse() } + override fun enableVoice( + params: ActionEnableVoiceParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /sim_cards/{id}/actions/enable_voice + withRawResponse().enableVoice(params, requestOptions).thenApply { it.parse() } + override fun removePublicIp( params: ActionRemovePublicIpParams, requestOptions: RequestOptions, @@ -343,6 +361,40 @@ class ActionServiceAsyncImpl internal constructor(private val clientOptions: Cli } } + private val disableVoiceHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun disableVoice( + params: ActionDisableVoiceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("sim_cards", params._pathParam(0), "actions", "disable_voice") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { disableVoiceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val enableHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -377,6 +429,40 @@ class ActionServiceAsyncImpl internal constructor(private val clientOptions: Cli } } + private val enableVoiceHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun enableVoice( + params: ActionEnableVoiceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("sim_cards", params._pathParam(0), "actions", "enable_voice") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { enableVoiceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val removePublicIpHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/storage/SqldbServiceAsync.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/storage/SqldbServiceAsync.kt new file mode 100644 index 000000000..2340b1337 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/storage/SqldbServiceAsync.kt @@ -0,0 +1,273 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async.storage + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.models.storage.sqldbs.SqlDatabaseResponseWrapper +import com.telnyx.sdk.models.storage.sqldbs.SqldbCreateParams +import com.telnyx.sdk.models.storage.sqldbs.SqldbDeleteParams +import com.telnyx.sdk.models.storage.sqldbs.SqldbListPageAsync +import com.telnyx.sdk.models.storage.sqldbs.SqldbListParams +import com.telnyx.sdk.models.storage.sqldbs.SqldbRetrieveParams +import com.telnyx.sdk.services.async.storage.sqldbs.ActionServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +/** Manage SQL databases and run SQL against them */ +interface SqldbServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SqldbServiceAsync + + /** Manage SQL databases and run SQL against them */ + fun actions(): ActionServiceAsync + + /** + * Creates a new SQL database. Provisioning is asynchronous: the database is returned with + * status `pending` and becomes usable once it reaches `provision_ok`. + */ + fun create(params: SqldbCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SqldbCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Retrieves a SQL database by its ID, including its provisioning status. */ + fun retrieve(id: String): CompletableFuture = + retrieve(id, SqldbRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + id: String, + params: SqldbRetrieveParams = SqldbRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + id: String, + params: SqldbRetrieveParams = SqldbRetrieveParams.none(), + ): CompletableFuture = retrieve(id, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: SqldbRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: SqldbRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(id, SqldbRetrieveParams.none(), requestOptions) + + /** + * Lists the SQL databases for the authenticated user's organization. Results use page-based + * pagination (`page[number]`/`page[size]`) and can be filtered and sorted. + */ + fun list(): CompletableFuture = list(SqldbListParams.none()) + + /** @see list */ + fun list( + params: SqldbListParams = SqldbListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: SqldbListParams = SqldbListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(SqldbListParams.none(), requestOptions) + + /** + * Deletes a SQL database and all of the data it holds. Deletion is asynchronous and returns + * `202` with an empty body — the record is not removed synchronously. Poll `GET + * /storage/sqldbs/{id}`, which returns `404` once the database has been purged; there is no + * durable `deleted` state. A database still bound by a function is refused with `409` unless + * `force=true`. + */ + fun delete(id: String): CompletableFuture = delete(id, SqldbDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: SqldbDeleteParams = SqldbDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: SqldbDeleteParams = SqldbDeleteParams.none(), + ): CompletableFuture = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: SqldbDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: SqldbDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions): CompletableFuture = + delete(id, SqldbDeleteParams.none(), requestOptions) + + /** A view of [SqldbServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SqldbServiceAsync.WithRawResponse + + /** Manage SQL databases and run SQL against them */ + fun actions(): ActionServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /storage/sqldbs`, but is otherwise the same as + * [SqldbServiceAsync.create]. + */ + fun create( + params: SqldbCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SqldbCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /storage/sqldbs/{id}`, but is otherwise the same as + * [SqldbServiceAsync.retrieve]. + */ + fun retrieve(id: String): CompletableFuture> = + retrieve(id, SqldbRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + id: String, + params: SqldbRetrieveParams = SqldbRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + id: String, + params: SqldbRetrieveParams = SqldbRetrieveParams.none(), + ): CompletableFuture> = + retrieve(id, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: SqldbRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: SqldbRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(id, SqldbRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /storage/sqldbs`, but is otherwise the same as + * [SqldbServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(SqldbListParams.none()) + + /** @see list */ + fun list( + params: SqldbListParams = SqldbListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: SqldbListParams = SqldbListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(SqldbListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /storage/sqldbs/{id}`, but is otherwise the same + * as [SqldbServiceAsync.delete]. + */ + fun delete(id: String): CompletableFuture = + delete(id, SqldbDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: SqldbDeleteParams = SqldbDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete( + id: String, + params: SqldbDeleteParams = SqldbDeleteParams.none(), + ): CompletableFuture = delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: SqldbDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: SqldbDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions): CompletableFuture = + delete(id, SqldbDeleteParams.none(), requestOptions) + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/storage/SqldbServiceAsyncImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/storage/SqldbServiceAsyncImpl.kt new file mode 100644 index 000000000..6017c3106 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/storage/SqldbServiceAsyncImpl.kt @@ -0,0 +1,228 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async.storage + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.handlers.emptyHandler +import com.telnyx.sdk.core.handlers.errorBodyHandler +import com.telnyx.sdk.core.handlers.errorHandler +import com.telnyx.sdk.core.handlers.jsonHandler +import com.telnyx.sdk.core.http.HttpMethod +import com.telnyx.sdk.core.http.HttpRequest +import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponse.Handler +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.core.http.json +import com.telnyx.sdk.core.http.parseable +import com.telnyx.sdk.core.prepareAsync +import com.telnyx.sdk.models.storage.sqldbs.SqlDatabaseResponseWrapper +import com.telnyx.sdk.models.storage.sqldbs.SqldbCreateParams +import com.telnyx.sdk.models.storage.sqldbs.SqldbDeleteParams +import com.telnyx.sdk.models.storage.sqldbs.SqldbListPageAsync +import com.telnyx.sdk.models.storage.sqldbs.SqldbListPageResponse +import com.telnyx.sdk.models.storage.sqldbs.SqldbListParams +import com.telnyx.sdk.models.storage.sqldbs.SqldbRetrieveParams +import com.telnyx.sdk.services.async.storage.sqldbs.ActionServiceAsync +import com.telnyx.sdk.services.async.storage.sqldbs.ActionServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +/** Manage SQL databases and run SQL against them */ +class SqldbServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SqldbServiceAsync { + + private val withRawResponse: SqldbServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val actions: ActionServiceAsync by lazy { ActionServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): SqldbServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): SqldbServiceAsync = + SqldbServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + /** Manage SQL databases and run SQL against them */ + override fun actions(): ActionServiceAsync = actions + + override fun create( + params: SqldbCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /storage/sqldbs + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: SqldbRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /storage/sqldbs/{id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: SqldbListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /storage/sqldbs + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: SqldbDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /storage/sqldbs/{id} + withRawResponse().delete(params, requestOptions).thenAccept {} + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SqldbServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val actions: ActionServiceAsync.WithRawResponse by lazy { + ActionServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): SqldbServiceAsync.WithRawResponse = + SqldbServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + /** Manage SQL databases and run SQL against them */ + override fun actions(): ActionServiceAsync.WithRawResponse = actions + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: SqldbCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("storage", "sqldbs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: SqldbRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("storage", "sqldbs", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: SqldbListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("storage", "sqldbs") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + SqldbListPageAsync.builder() + .service(SqldbServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: SqldbDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("storage", "sqldbs", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/storage/sqldbs/ActionServiceAsync.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/storage/sqldbs/ActionServiceAsync.kt new file mode 100644 index 000000000..b7163a119 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/storage/sqldbs/ActionServiceAsync.kt @@ -0,0 +1,98 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async.storage.sqldbs + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.models.storage.sqldbs.actions.ActionQueryParams +import com.telnyx.sdk.models.storage.sqldbs.actions.ActionQueryResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +/** Manage SQL databases and run SQL against them */ +interface ActionServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ActionServiceAsync + + /** + * Runs SQL against the database and returns the resulting rows — empty for statements that + * return none, such as DDL. Bind positional `?` placeholders with `params` rather than + * interpolating values into the SQL string. + */ + fun query(id: String, params: ActionQueryParams): CompletableFuture = + query(id, params, RequestOptions.none()) + + /** @see query */ + fun query( + id: String, + params: ActionQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + query(params.toBuilder().id(id).build(), requestOptions) + + /** @see query */ + fun query(params: ActionQueryParams): CompletableFuture = + query(params, RequestOptions.none()) + + /** @see query */ + fun query( + params: ActionQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [ActionServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ActionServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /storage/sqldbs/{id}/actions/query`, but is + * otherwise the same as [ActionServiceAsync.query]. + */ + fun query( + id: String, + params: ActionQueryParams, + ): CompletableFuture> = + query(id, params, RequestOptions.none()) + + /** @see query */ + fun query( + id: String, + params: ActionQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + query(params.toBuilder().id(id).build(), requestOptions) + + /** @see query */ + fun query( + params: ActionQueryParams + ): CompletableFuture> = + query(params, RequestOptions.none()) + + /** @see query */ + fun query( + params: ActionQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/storage/sqldbs/ActionServiceAsyncImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/storage/sqldbs/ActionServiceAsyncImpl.kt new file mode 100644 index 000000000..5607b23af --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/storage/sqldbs/ActionServiceAsyncImpl.kt @@ -0,0 +1,92 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async.storage.sqldbs + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.handlers.errorBodyHandler +import com.telnyx.sdk.core.handlers.errorHandler +import com.telnyx.sdk.core.handlers.jsonHandler +import com.telnyx.sdk.core.http.HttpMethod +import com.telnyx.sdk.core.http.HttpRequest +import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponse.Handler +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.core.http.json +import com.telnyx.sdk.core.http.parseable +import com.telnyx.sdk.core.prepareAsync +import com.telnyx.sdk.models.storage.sqldbs.actions.ActionQueryParams +import com.telnyx.sdk.models.storage.sqldbs.actions.ActionQueryResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +/** Manage SQL databases and run SQL against them */ +class ActionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ActionServiceAsync { + + private val withRawResponse: ActionServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ActionServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ActionServiceAsync = + ActionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun query( + params: ActionQueryParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /storage/sqldbs/{id}/actions/query + withRawResponse().query(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ActionServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ActionServiceAsync.WithRawResponse = + ActionServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val queryHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun query( + params: ActionQueryParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("storage", "sqldbs", params._pathParam(0), "actions", "query") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { queryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/websearch/ResearchServiceAsync.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/websearch/ResearchServiceAsync.kt new file mode 100644 index 000000000..3db7b2ed1 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/websearch/ResearchServiceAsync.kt @@ -0,0 +1,164 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async.websearch + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.models.websearch.research.ResearchCreateParams +import com.telnyx.sdk.models.websearch.research.ResearchCreateResponse +import com.telnyx.sdk.models.websearch.research.ResearchRetrieveParams +import com.telnyx.sdk.models.websearch.research.ResearchRetrieveResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +/** Deep research with citations and async task polling. */ +interface ResearchServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ResearchServiceAsync + + /** + * Starts a deep research task that runs multiple searches, reads sources, and synthesizes an + * answer with citations. + * + * ## Synchronous mode (default) + * + * When `background` is `false` or omitted, the request blocks until the research completes and + * returns the answer with citations. This can take up to 120 seconds depending on + * `research_effort`. + * + * ## Asynchronous mode + * + * When `background` is `true`, the request returns immediately with a `task_id` and `status: + * pending`. Poll `GET /web_search/research/{task_id}` to check when the research completes and + * retrieve the answer. + */ + fun create(params: ResearchCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ResearchCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Polls the status of a previously started asynchronous research task. When the status is + * `completed`, the response includes the answer and citations. When the status is `failed`, the + * response includes an error message. + */ + fun retrieve(taskId: String): CompletableFuture = + retrieve(taskId, ResearchRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + taskId: String, + params: ResearchRetrieveParams = ResearchRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().taskId(taskId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + taskId: String, + params: ResearchRetrieveParams = ResearchRetrieveParams.none(), + ): CompletableFuture = retrieve(taskId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ResearchRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: ResearchRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + taskId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(taskId, ResearchRetrieveParams.none(), requestOptions) + + /** + * A view of [ResearchServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ResearchServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /web_search/research`, but is otherwise the same as + * [ResearchServiceAsync.create]. + */ + fun create( + params: ResearchCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ResearchCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /web_search/research/{task_id}`, but is otherwise + * the same as [ResearchServiceAsync.retrieve]. + */ + fun retrieve(taskId: String): CompletableFuture> = + retrieve(taskId, ResearchRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + taskId: String, + params: ResearchRetrieveParams = ResearchRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().taskId(taskId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + taskId: String, + params: ResearchRetrieveParams = ResearchRetrieveParams.none(), + ): CompletableFuture> = + retrieve(taskId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ResearchRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: ResearchRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + taskId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(taskId, ResearchRetrieveParams.none(), requestOptions) + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/websearch/ResearchServiceAsyncImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/websearch/ResearchServiceAsyncImpl.kt new file mode 100644 index 000000000..e99068c92 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/async/websearch/ResearchServiceAsyncImpl.kt @@ -0,0 +1,131 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async.websearch + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.handlers.errorBodyHandler +import com.telnyx.sdk.core.handlers.errorHandler +import com.telnyx.sdk.core.handlers.jsonHandler +import com.telnyx.sdk.core.http.HttpMethod +import com.telnyx.sdk.core.http.HttpRequest +import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponse.Handler +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.core.http.json +import com.telnyx.sdk.core.http.parseable +import com.telnyx.sdk.core.prepareAsync +import com.telnyx.sdk.models.websearch.research.ResearchCreateParams +import com.telnyx.sdk.models.websearch.research.ResearchCreateResponse +import com.telnyx.sdk.models.websearch.research.ResearchRetrieveParams +import com.telnyx.sdk.models.websearch.research.ResearchRetrieveResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +/** Deep research with citations and async task polling. */ +class ResearchServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ResearchServiceAsync { + + private val withRawResponse: ResearchServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ResearchServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ResearchServiceAsync = + ResearchServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: ResearchCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /web_search/research + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: ResearchRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /web_search/research/{task_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ResearchServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ResearchServiceAsync.WithRawResponse = + ResearchServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: ResearchCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("web_search", "research") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: ResearchRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("taskId", params.taskId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("web_search", "research", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/StorageService.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/StorageService.kt index 19b8cd567..1f6dd0b00 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/StorageService.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/StorageService.kt @@ -13,6 +13,7 @@ import com.telnyx.sdk.services.blocking.storage.CloudfService import com.telnyx.sdk.services.blocking.storage.KvService import com.telnyx.sdk.services.blocking.storage.MigrationService import com.telnyx.sdk.services.blocking.storage.MigrationSourceService +import com.telnyx.sdk.services.blocking.storage.SqldbService import java.util.function.Consumer /** Migrate data from an external provider into Telnyx Cloud Storage */ @@ -47,6 +48,9 @@ interface StorageService { */ fun cloudfs(): CloudfService + /** Manage SQL databases and run SQL against them */ + fun sqldbs(): SqldbService + /** List the external storage providers and regions supported as migration sources. */ fun listMigrationSourceCoverage(): StorageListMigrationSourceCoverageResponse = listMigrationSourceCoverage(StorageListMigrationSourceCoverageParams.none()) @@ -99,6 +103,9 @@ interface StorageService { */ fun cloudfs(): CloudfService.WithRawResponse + /** Manage SQL databases and run SQL against them */ + fun sqldbs(): SqldbService.WithRawResponse + /** * Returns a raw HTTP response for `get /storage/migration_source_coverage`, but is * otherwise the same as [StorageService.listMigrationSourceCoverage]. diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/StorageServiceImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/StorageServiceImpl.kt index 3e150f39c..b0155771b 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/StorageServiceImpl.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/StorageServiceImpl.kt @@ -26,6 +26,8 @@ import com.telnyx.sdk.services.blocking.storage.MigrationService import com.telnyx.sdk.services.blocking.storage.MigrationServiceImpl import com.telnyx.sdk.services.blocking.storage.MigrationSourceService import com.telnyx.sdk.services.blocking.storage.MigrationSourceServiceImpl +import com.telnyx.sdk.services.blocking.storage.SqldbService +import com.telnyx.sdk.services.blocking.storage.SqldbServiceImpl import java.util.function.Consumer /** Migrate data from an external provider into Telnyx Cloud Storage */ @@ -48,6 +50,8 @@ class StorageServiceImpl internal constructor(private val clientOptions: ClientO private val cloudfs: CloudfService by lazy { CloudfServiceImpl(clientOptions) } + private val sqldbs: SqldbService by lazy { SqldbServiceImpl(clientOptions) } + override fun withRawResponse(): StorageService.WithRawResponse = withRawResponse override fun withOptions(modifier: Consumer): StorageService = @@ -70,6 +74,9 @@ class StorageServiceImpl internal constructor(private val clientOptions: ClientO */ override fun cloudfs(): CloudfService = cloudfs + /** Manage SQL databases and run SQL against them */ + override fun sqldbs(): SqldbService = sqldbs + override fun listMigrationSourceCoverage( params: StorageListMigrationSourceCoverageParams, requestOptions: RequestOptions, @@ -103,6 +110,10 @@ class StorageServiceImpl internal constructor(private val clientOptions: ClientO CloudfServiceImpl.WithRawResponseImpl(clientOptions) } + private val sqldbs: SqldbService.WithRawResponse by lazy { + SqldbServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): StorageService.WithRawResponse = @@ -128,6 +139,9 @@ class StorageServiceImpl internal constructor(private val clientOptions: ClientO */ override fun cloudfs(): CloudfService.WithRawResponse = cloudfs + /** Manage SQL databases and run SQL against them */ + override fun sqldbs(): SqldbService.WithRawResponse = sqldbs + private val listMigrationSourceCoverageHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/WebSearchService.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/WebSearchService.kt new file mode 100644 index 000000000..95cd8550d --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/WebSearchService.kt @@ -0,0 +1,106 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.models.websearch.WebSearchContentsParams +import com.telnyx.sdk.models.websearch.WebSearchContentsResponse +import com.telnyx.sdk.models.websearch.WebSearchCreateParams +import com.telnyx.sdk.models.websearch.WebSearchCreateResponse +import com.telnyx.sdk.services.blocking.websearch.ResearchService +import java.util.function.Consumer + +interface WebSearchService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): WebSearchService + + /** Deep research with citations and async task polling. */ + fun research(): ResearchService + + /** + * Performs a real-time web search and returns structured, LLM-ready JSON results with titles, + * URLs, descriptions, and snippets. Supports filtering by domain, country, safe search, + * freshness, and live crawl. + * + * **Note:** `include_domains` and `exclude_domains` cannot be used in the same request. Use one + * or the other. + */ + fun create(params: WebSearchCreateParams): WebSearchCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: WebSearchCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): WebSearchCreateResponse + + /** + * Retrieves clean HTML or Markdown content from a list of URLs. Supports up to 20 URLs per + * request (public API limit). Specify which formats to return: `html`, `markdown`, `metadata`. + */ + fun contents(params: WebSearchContentsParams): WebSearchContentsResponse = + contents(params, RequestOptions.none()) + + /** @see contents */ + fun contents( + params: WebSearchContentsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): WebSearchContentsResponse + + /** A view of [WebSearchService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): WebSearchService.WithRawResponse + + /** Deep research with citations and async task polling. */ + fun research(): ResearchService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /web_search`, but is otherwise the same as + * [WebSearchService.create]. + */ + @MustBeClosed + fun create(params: WebSearchCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: WebSearchCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /web_search/contents`, but is otherwise the same as + * [WebSearchService.contents]. + */ + @MustBeClosed + fun contents(params: WebSearchContentsParams): HttpResponseFor = + contents(params, RequestOptions.none()) + + /** @see contents */ + @MustBeClosed + fun contents( + params: WebSearchContentsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/WebSearchServiceImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/WebSearchServiceImpl.kt new file mode 100644 index 000000000..4755e5315 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/WebSearchServiceImpl.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.handlers.errorBodyHandler +import com.telnyx.sdk.core.handlers.errorHandler +import com.telnyx.sdk.core.handlers.jsonHandler +import com.telnyx.sdk.core.http.HttpMethod +import com.telnyx.sdk.core.http.HttpRequest +import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponse.Handler +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.core.http.json +import com.telnyx.sdk.core.http.parseable +import com.telnyx.sdk.core.prepare +import com.telnyx.sdk.models.websearch.WebSearchContentsParams +import com.telnyx.sdk.models.websearch.WebSearchContentsResponse +import com.telnyx.sdk.models.websearch.WebSearchCreateParams +import com.telnyx.sdk.models.websearch.WebSearchCreateResponse +import com.telnyx.sdk.services.blocking.websearch.ResearchService +import com.telnyx.sdk.services.blocking.websearch.ResearchServiceImpl +import java.util.function.Consumer + +class WebSearchServiceImpl internal constructor(private val clientOptions: ClientOptions) : + WebSearchService { + + private val withRawResponse: WebSearchService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val research: ResearchService by lazy { ResearchServiceImpl(clientOptions) } + + override fun withRawResponse(): WebSearchService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): WebSearchService = + WebSearchServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + /** Deep research with citations and async task polling. */ + override fun research(): ResearchService = research + + override fun create( + params: WebSearchCreateParams, + requestOptions: RequestOptions, + ): WebSearchCreateResponse = + // post /web_search + withRawResponse().create(params, requestOptions).parse() + + override fun contents( + params: WebSearchContentsParams, + requestOptions: RequestOptions, + ): WebSearchContentsResponse = + // post /web_search/contents + withRawResponse().contents(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + WebSearchService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val research: ResearchService.WithRawResponse by lazy { + ResearchServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): WebSearchService.WithRawResponse = + WebSearchServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + /** Deep research with citations and async task polling. */ + override fun research(): ResearchService.WithRawResponse = research + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: WebSearchCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("web_search") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val contentsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun contents( + params: WebSearchContentsParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("web_search", "contents") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { contentsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/phonenumbers/VoicemailService.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/phonenumbers/VoicemailService.kt index cc42f30cc..a73dc71a4 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/phonenumbers/VoicemailService.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/phonenumbers/VoicemailService.kt @@ -29,7 +29,12 @@ interface VoicemailService { */ fun withOptions(modifier: Consumer): VoicemailService - /** Create voicemail settings for a phone number */ + /** + * Create voicemail settings for a phone number. You can also configure a custom greeting by + * setting the `greeting` object: use `mode` `custom_greeting` together with a `media_name` that + * points to an audio file uploaded through the Media Storage API, or `mode` `default` to use + * the standard system greeting. + */ fun create(phoneNumberId: String, params: VoicemailCreateParams): VoicemailCreateResponse = create(phoneNumberId, params, RequestOptions.none()) @@ -83,7 +88,12 @@ interface VoicemailService { fun retrieve(phoneNumberId: String, requestOptions: RequestOptions): VoicemailRetrieveResponse = retrieve(phoneNumberId, VoicemailRetrieveParams.none(), requestOptions) - /** Update voicemail settings for a phone number */ + /** + * Update voicemail settings for a phone number. You can also configure a custom greeting by + * setting the `greeting` object: use `mode` `custom_greeting` together with a `media_name` that + * points to an audio file uploaded through the Media Storage API, or `mode` `default` to use + * the standard system greeting. + */ fun update(phoneNumberId: String, params: VoicemailUpdateParams): VoicemailUpdateResponse = update(phoneNumberId, params, RequestOptions.none()) diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/simcards/ActionService.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/simcards/ActionService.kt index c5668439f..5c487475b 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/simcards/ActionService.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/simcards/ActionService.kt @@ -14,8 +14,12 @@ import com.telnyx.sdk.models.simcards.actions.ActionBulkSetPublicIpsParams import com.telnyx.sdk.models.simcards.actions.ActionBulkSetPublicIpsResponse import com.telnyx.sdk.models.simcards.actions.ActionDisableParams import com.telnyx.sdk.models.simcards.actions.ActionDisableResponse +import com.telnyx.sdk.models.simcards.actions.ActionDisableVoiceParams +import com.telnyx.sdk.models.simcards.actions.ActionDisableVoiceResponse import com.telnyx.sdk.models.simcards.actions.ActionEnableParams import com.telnyx.sdk.models.simcards.actions.ActionEnableResponse +import com.telnyx.sdk.models.simcards.actions.ActionEnableVoiceParams +import com.telnyx.sdk.models.simcards.actions.ActionEnableVoiceResponse import com.telnyx.sdk.models.simcards.actions.ActionListPage import com.telnyx.sdk.models.simcards.actions.ActionListParams import com.telnyx.sdk.models.simcards.actions.ActionRemovePublicIpParams @@ -190,6 +194,43 @@ interface ActionService { fun disable(id: String, requestOptions: RequestOptions): ActionDisableResponse = disable(id, ActionDisableParams.none(), requestOptions) + /** + * This API disables voice calling on a SIM card. The SIM card will no longer be able to make or + * receive calls.
    The API will trigger an asynchronous operation called a SIM Card Action. + * The status of the SIM Card Action can be followed through the + * [List SIM Card Action](https://developers.telnyx.com/api-reference/sim-card-actions/list-sim-card-actions) + * API. + */ + fun disableVoice(id: String): ActionDisableVoiceResponse = + disableVoice(id, ActionDisableVoiceParams.none()) + + /** @see disableVoice */ + fun disableVoice( + id: String, + params: ActionDisableVoiceParams = ActionDisableVoiceParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ActionDisableVoiceResponse = disableVoice(params.toBuilder().id(id).build(), requestOptions) + + /** @see disableVoice */ + fun disableVoice( + id: String, + params: ActionDisableVoiceParams = ActionDisableVoiceParams.none(), + ): ActionDisableVoiceResponse = disableVoice(id, params, RequestOptions.none()) + + /** @see disableVoice */ + fun disableVoice( + params: ActionDisableVoiceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ActionDisableVoiceResponse + + /** @see disableVoice */ + fun disableVoice(params: ActionDisableVoiceParams): ActionDisableVoiceResponse = + disableVoice(params, RequestOptions.none()) + + /** @see disableVoice */ + fun disableVoice(id: String, requestOptions: RequestOptions): ActionDisableVoiceResponse = + disableVoice(id, ActionDisableVoiceParams.none(), requestOptions) + /** * This API enables a SIM card, connecting it to the network and making it possible to consume * data.
    To enable a SIM card, it must be associated with a SIM card group.
    The API @@ -228,6 +269,45 @@ interface ActionService { fun enable(id: String, requestOptions: RequestOptions): ActionEnableResponse = enable(id, ActionEnableParams.none(), requestOptions) + /** + * This API enables voice calling on a SIM card. When a connection_id is provided, + * the SIM is associated with the specified Mobile Voice Connection. The connection must be + * owned by the same user and of type mobile_voice.
    The API will trigger an + * asynchronous operation called a SIM Card Action. The status of the SIM Card Action can be + * followed through the + * [List SIM Card Action](https://developers.telnyx.com/api-reference/sim-card-actions/list-sim-card-actions) + * API. + */ + fun enableVoice(id: String): ActionEnableVoiceResponse = + enableVoice(id, ActionEnableVoiceParams.none()) + + /** @see enableVoice */ + fun enableVoice( + id: String, + params: ActionEnableVoiceParams = ActionEnableVoiceParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ActionEnableVoiceResponse = enableVoice(params.toBuilder().id(id).build(), requestOptions) + + /** @see enableVoice */ + fun enableVoice( + id: String, + params: ActionEnableVoiceParams = ActionEnableVoiceParams.none(), + ): ActionEnableVoiceResponse = enableVoice(id, params, RequestOptions.none()) + + /** @see enableVoice */ + fun enableVoice( + params: ActionEnableVoiceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ActionEnableVoiceResponse + + /** @see enableVoice */ + fun enableVoice(params: ActionEnableVoiceParams): ActionEnableVoiceResponse = + enableVoice(params, RequestOptions.none()) + + /** @see enableVoice */ + fun enableVoice(id: String, requestOptions: RequestOptions): ActionEnableVoiceResponse = + enableVoice(id, ActionEnableVoiceParams.none(), requestOptions) + /** * This API removes an existing public IP from a SIM card.

    The API will trigger an * asynchronous operation called a SIM Card Action. The status of the SIM Card Action can be @@ -539,6 +619,52 @@ interface ActionService { ): HttpResponseFor = disable(id, ActionDisableParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /sim_cards/{id}/actions/disable_voice`, but is + * otherwise the same as [ActionService.disableVoice]. + */ + @MustBeClosed + fun disableVoice(id: String): HttpResponseFor = + disableVoice(id, ActionDisableVoiceParams.none()) + + /** @see disableVoice */ + @MustBeClosed + fun disableVoice( + id: String, + params: ActionDisableVoiceParams = ActionDisableVoiceParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + disableVoice(params.toBuilder().id(id).build(), requestOptions) + + /** @see disableVoice */ + @MustBeClosed + fun disableVoice( + id: String, + params: ActionDisableVoiceParams = ActionDisableVoiceParams.none(), + ): HttpResponseFor = + disableVoice(id, params, RequestOptions.none()) + + /** @see disableVoice */ + @MustBeClosed + fun disableVoice( + params: ActionDisableVoiceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see disableVoice */ + @MustBeClosed + fun disableVoice( + params: ActionDisableVoiceParams + ): HttpResponseFor = disableVoice(params, RequestOptions.none()) + + /** @see disableVoice */ + @MustBeClosed + fun disableVoice( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + disableVoice(id, ActionDisableVoiceParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /sim_cards/{id}/actions/enable`, but is otherwise * the same as [ActionService.enable]. @@ -583,6 +709,52 @@ interface ActionService { ): HttpResponseFor = enable(id, ActionEnableParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /sim_cards/{id}/actions/enable_voice`, but is + * otherwise the same as [ActionService.enableVoice]. + */ + @MustBeClosed + fun enableVoice(id: String): HttpResponseFor = + enableVoice(id, ActionEnableVoiceParams.none()) + + /** @see enableVoice */ + @MustBeClosed + fun enableVoice( + id: String, + params: ActionEnableVoiceParams = ActionEnableVoiceParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + enableVoice(params.toBuilder().id(id).build(), requestOptions) + + /** @see enableVoice */ + @MustBeClosed + fun enableVoice( + id: String, + params: ActionEnableVoiceParams = ActionEnableVoiceParams.none(), + ): HttpResponseFor = + enableVoice(id, params, RequestOptions.none()) + + /** @see enableVoice */ + @MustBeClosed + fun enableVoice( + params: ActionEnableVoiceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see enableVoice */ + @MustBeClosed + fun enableVoice( + params: ActionEnableVoiceParams + ): HttpResponseFor = enableVoice(params, RequestOptions.none()) + + /** @see enableVoice */ + @MustBeClosed + fun enableVoice( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + enableVoice(id, ActionEnableVoiceParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /sim_cards/{id}/actions/remove_public_ip`, but is * otherwise the same as [ActionService.removePublicIp]. diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/simcards/ActionServiceImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/simcards/ActionServiceImpl.kt index 15c9a96bb..c98e29991 100644 --- a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/simcards/ActionServiceImpl.kt +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/simcards/ActionServiceImpl.kt @@ -24,8 +24,12 @@ import com.telnyx.sdk.models.simcards.actions.ActionBulkSetPublicIpsParams import com.telnyx.sdk.models.simcards.actions.ActionBulkSetPublicIpsResponse import com.telnyx.sdk.models.simcards.actions.ActionDisableParams import com.telnyx.sdk.models.simcards.actions.ActionDisableResponse +import com.telnyx.sdk.models.simcards.actions.ActionDisableVoiceParams +import com.telnyx.sdk.models.simcards.actions.ActionDisableVoiceResponse import com.telnyx.sdk.models.simcards.actions.ActionEnableParams import com.telnyx.sdk.models.simcards.actions.ActionEnableResponse +import com.telnyx.sdk.models.simcards.actions.ActionEnableVoiceParams +import com.telnyx.sdk.models.simcards.actions.ActionEnableVoiceResponse import com.telnyx.sdk.models.simcards.actions.ActionListPage import com.telnyx.sdk.models.simcards.actions.ActionListPageResponse import com.telnyx.sdk.models.simcards.actions.ActionListParams @@ -93,6 +97,13 @@ class ActionServiceImpl internal constructor(private val clientOptions: ClientOp // post /sim_cards/{id}/actions/disable withRawResponse().disable(params, requestOptions).parse() + override fun disableVoice( + params: ActionDisableVoiceParams, + requestOptions: RequestOptions, + ): ActionDisableVoiceResponse = + // post /sim_cards/{id}/actions/disable_voice + withRawResponse().disableVoice(params, requestOptions).parse() + override fun enable( params: ActionEnableParams, requestOptions: RequestOptions, @@ -100,6 +111,13 @@ class ActionServiceImpl internal constructor(private val clientOptions: ClientOp // post /sim_cards/{id}/actions/enable withRawResponse().enable(params, requestOptions).parse() + override fun enableVoice( + params: ActionEnableVoiceParams, + requestOptions: RequestOptions, + ): ActionEnableVoiceResponse = + // post /sim_cards/{id}/actions/enable_voice + withRawResponse().enableVoice(params, requestOptions).parse() + override fun removePublicIp( params: ActionRemovePublicIpParams, requestOptions: RequestOptions, @@ -320,6 +338,37 @@ class ActionServiceImpl internal constructor(private val clientOptions: ClientOp } } + private val disableVoiceHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun disableVoice( + params: ActionDisableVoiceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("sim_cards", params._pathParam(0), "actions", "disable_voice") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { disableVoiceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val enableHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -351,6 +400,37 @@ class ActionServiceImpl internal constructor(private val clientOptions: ClientOp } } + private val enableVoiceHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun enableVoice( + params: ActionEnableVoiceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("sim_cards", params._pathParam(0), "actions", "enable_voice") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { enableVoiceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val removePublicIpHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/storage/SqldbService.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/storage/SqldbService.kt new file mode 100644 index 000000000..c7cbd8a35 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/storage/SqldbService.kt @@ -0,0 +1,260 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking.storage + +import com.google.errorprone.annotations.MustBeClosed +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.models.storage.sqldbs.SqlDatabaseResponseWrapper +import com.telnyx.sdk.models.storage.sqldbs.SqldbCreateParams +import com.telnyx.sdk.models.storage.sqldbs.SqldbDeleteParams +import com.telnyx.sdk.models.storage.sqldbs.SqldbListPage +import com.telnyx.sdk.models.storage.sqldbs.SqldbListParams +import com.telnyx.sdk.models.storage.sqldbs.SqldbRetrieveParams +import com.telnyx.sdk.services.blocking.storage.sqldbs.ActionService +import java.util.function.Consumer + +/** Manage SQL databases and run SQL against them */ +interface SqldbService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SqldbService + + /** Manage SQL databases and run SQL against them */ + fun actions(): ActionService + + /** + * Creates a new SQL database. Provisioning is asynchronous: the database is returned with + * status `pending` and becomes usable once it reaches `provision_ok`. + */ + fun create(params: SqldbCreateParams): SqlDatabaseResponseWrapper = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SqldbCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SqlDatabaseResponseWrapper + + /** Retrieves a SQL database by its ID, including its provisioning status. */ + fun retrieve(id: String): SqlDatabaseResponseWrapper = retrieve(id, SqldbRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + id: String, + params: SqldbRetrieveParams = SqldbRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SqlDatabaseResponseWrapper = retrieve(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + id: String, + params: SqldbRetrieveParams = SqldbRetrieveParams.none(), + ): SqlDatabaseResponseWrapper = retrieve(id, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: SqldbRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SqlDatabaseResponseWrapper + + /** @see retrieve */ + fun retrieve(params: SqldbRetrieveParams): SqlDatabaseResponseWrapper = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(id: String, requestOptions: RequestOptions): SqlDatabaseResponseWrapper = + retrieve(id, SqldbRetrieveParams.none(), requestOptions) + + /** + * Lists the SQL databases for the authenticated user's organization. Results use page-based + * pagination (`page[number]`/`page[size]`) and can be filtered and sorted. + */ + fun list(): SqldbListPage = list(SqldbListParams.none()) + + /** @see list */ + fun list( + params: SqldbListParams = SqldbListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SqldbListPage + + /** @see list */ + fun list(params: SqldbListParams = SqldbListParams.none()): SqldbListPage = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): SqldbListPage = + list(SqldbListParams.none(), requestOptions) + + /** + * Deletes a SQL database and all of the data it holds. Deletion is asynchronous and returns + * `202` with an empty body — the record is not removed synchronously. Poll `GET + * /storage/sqldbs/{id}`, which returns `404` once the database has been purged; there is no + * durable `deleted` state. A database still bound by a function is refused with `409` unless + * `force=true`. + */ + fun delete(id: String) = delete(id, SqldbDeleteParams.none()) + + /** @see delete */ + fun delete( + id: String, + params: SqldbDeleteParams = SqldbDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + fun delete(id: String, params: SqldbDeleteParams = SqldbDeleteParams.none()) = + delete(id, params, RequestOptions.none()) + + /** @see delete */ + fun delete(params: SqldbDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) + + /** @see delete */ + fun delete(params: SqldbDeleteParams) = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(id: String, requestOptions: RequestOptions) = + delete(id, SqldbDeleteParams.none(), requestOptions) + + /** A view of [SqldbService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SqldbService.WithRawResponse + + /** Manage SQL databases and run SQL against them */ + fun actions(): ActionService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /storage/sqldbs`, but is otherwise the same as + * [SqldbService.create]. + */ + @MustBeClosed + fun create(params: SqldbCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: SqldbCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /storage/sqldbs/{id}`, but is otherwise the same as + * [SqldbService.retrieve]. + */ + @MustBeClosed + fun retrieve(id: String): HttpResponseFor = + retrieve(id, SqldbRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + id: String, + params: SqldbRetrieveParams = SqldbRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + id: String, + params: SqldbRetrieveParams = SqldbRetrieveParams.none(), + ): HttpResponseFor = retrieve(id, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: SqldbRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: SqldbRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(id, SqldbRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /storage/sqldbs`, but is otherwise the same as + * [SqldbService.list]. + */ + @MustBeClosed fun list(): HttpResponseFor = list(SqldbListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: SqldbListParams = SqldbListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list(params: SqldbListParams = SqldbListParams.none()): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(SqldbListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /storage/sqldbs/{id}`, but is otherwise the same + * as [SqldbService.delete]. + */ + @MustBeClosed fun delete(id: String): HttpResponse = delete(id, SqldbDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + id: String, + params: SqldbDeleteParams = SqldbDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = delete(params.toBuilder().id(id).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete(id: String, params: SqldbDeleteParams = SqldbDeleteParams.none()): HttpResponse = + delete(id, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: SqldbDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see delete */ + @MustBeClosed + fun delete(params: SqldbDeleteParams): HttpResponse = delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete(id: String, requestOptions: RequestOptions): HttpResponse = + delete(id, SqldbDeleteParams.none(), requestOptions) + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/storage/SqldbServiceImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/storage/SqldbServiceImpl.kt new file mode 100644 index 000000000..aee28661d --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/storage/SqldbServiceImpl.kt @@ -0,0 +1,209 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking.storage + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.handlers.emptyHandler +import com.telnyx.sdk.core.handlers.errorBodyHandler +import com.telnyx.sdk.core.handlers.errorHandler +import com.telnyx.sdk.core.handlers.jsonHandler +import com.telnyx.sdk.core.http.HttpMethod +import com.telnyx.sdk.core.http.HttpRequest +import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponse.Handler +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.core.http.json +import com.telnyx.sdk.core.http.parseable +import com.telnyx.sdk.core.prepare +import com.telnyx.sdk.models.storage.sqldbs.SqlDatabaseResponseWrapper +import com.telnyx.sdk.models.storage.sqldbs.SqldbCreateParams +import com.telnyx.sdk.models.storage.sqldbs.SqldbDeleteParams +import com.telnyx.sdk.models.storage.sqldbs.SqldbListPage +import com.telnyx.sdk.models.storage.sqldbs.SqldbListPageResponse +import com.telnyx.sdk.models.storage.sqldbs.SqldbListParams +import com.telnyx.sdk.models.storage.sqldbs.SqldbRetrieveParams +import com.telnyx.sdk.services.blocking.storage.sqldbs.ActionService +import com.telnyx.sdk.services.blocking.storage.sqldbs.ActionServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +/** Manage SQL databases and run SQL against them */ +class SqldbServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SqldbService { + + private val withRawResponse: SqldbService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val actions: ActionService by lazy { ActionServiceImpl(clientOptions) } + + override fun withRawResponse(): SqldbService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): SqldbService = + SqldbServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + /** Manage SQL databases and run SQL against them */ + override fun actions(): ActionService = actions + + override fun create( + params: SqldbCreateParams, + requestOptions: RequestOptions, + ): SqlDatabaseResponseWrapper = + // post /storage/sqldbs + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: SqldbRetrieveParams, + requestOptions: RequestOptions, + ): SqlDatabaseResponseWrapper = + // get /storage/sqldbs/{id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list(params: SqldbListParams, requestOptions: RequestOptions): SqldbListPage = + // get /storage/sqldbs + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: SqldbDeleteParams, requestOptions: RequestOptions) { + // delete /storage/sqldbs/{id} + withRawResponse().delete(params, requestOptions) + } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SqldbService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val actions: ActionService.WithRawResponse by lazy { + ActionServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): SqldbService.WithRawResponse = + SqldbServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + /** Manage SQL databases and run SQL against them */ + override fun actions(): ActionService.WithRawResponse = actions + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: SqldbCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("storage", "sqldbs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: SqldbRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("storage", "sqldbs", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: SqldbListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("storage", "sqldbs") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + SqldbListPage.builder() + .service(SqldbServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: SqldbDeleteParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("storage", "sqldbs", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/storage/sqldbs/ActionService.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/storage/sqldbs/ActionService.kt new file mode 100644 index 000000000..cb05e103b --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/storage/sqldbs/ActionService.kt @@ -0,0 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking.storage.sqldbs + +import com.google.errorprone.annotations.MustBeClosed +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.models.storage.sqldbs.actions.ActionQueryParams +import com.telnyx.sdk.models.storage.sqldbs.actions.ActionQueryResponse +import java.util.function.Consumer + +/** Manage SQL databases and run SQL against them */ +interface ActionService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ActionService + + /** + * Runs SQL against the database and returns the resulting rows — empty for statements that + * return none, such as DDL. Bind positional `?` placeholders with `params` rather than + * interpolating values into the SQL string. + */ + fun query(id: String, params: ActionQueryParams): ActionQueryResponse = + query(id, params, RequestOptions.none()) + + /** @see query */ + fun query( + id: String, + params: ActionQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ActionQueryResponse = query(params.toBuilder().id(id).build(), requestOptions) + + /** @see query */ + fun query(params: ActionQueryParams): ActionQueryResponse = query(params, RequestOptions.none()) + + /** @see query */ + fun query( + params: ActionQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ActionQueryResponse + + /** A view of [ActionService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ActionService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /storage/sqldbs/{id}/actions/query`, but is + * otherwise the same as [ActionService.query]. + */ + @MustBeClosed + fun query(id: String, params: ActionQueryParams): HttpResponseFor = + query(id, params, RequestOptions.none()) + + /** @see query */ + @MustBeClosed + fun query( + id: String, + params: ActionQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + query(params.toBuilder().id(id).build(), requestOptions) + + /** @see query */ + @MustBeClosed + fun query(params: ActionQueryParams): HttpResponseFor = + query(params, RequestOptions.none()) + + /** @see query */ + @MustBeClosed + fun query( + params: ActionQueryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/storage/sqldbs/ActionServiceImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/storage/sqldbs/ActionServiceImpl.kt new file mode 100644 index 000000000..bbf356448 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/storage/sqldbs/ActionServiceImpl.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking.storage.sqldbs + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.handlers.errorBodyHandler +import com.telnyx.sdk.core.handlers.errorHandler +import com.telnyx.sdk.core.handlers.jsonHandler +import com.telnyx.sdk.core.http.HttpMethod +import com.telnyx.sdk.core.http.HttpRequest +import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponse.Handler +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.core.http.json +import com.telnyx.sdk.core.http.parseable +import com.telnyx.sdk.core.prepare +import com.telnyx.sdk.models.storage.sqldbs.actions.ActionQueryParams +import com.telnyx.sdk.models.storage.sqldbs.actions.ActionQueryResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +/** Manage SQL databases and run SQL against them */ +class ActionServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ActionService { + + private val withRawResponse: ActionService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ActionService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ActionService = + ActionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun query( + params: ActionQueryParams, + requestOptions: RequestOptions, + ): ActionQueryResponse = + // post /storage/sqldbs/{id}/actions/query + withRawResponse().query(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ActionService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ActionService.WithRawResponse = + ActionServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val queryHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun query( + params: ActionQueryParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("storage", "sqldbs", params._pathParam(0), "actions", "query") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { queryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/websearch/ResearchService.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/websearch/ResearchService.kt new file mode 100644 index 000000000..53d279b73 --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/websearch/ResearchService.kt @@ -0,0 +1,161 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking.websearch + +import com.google.errorprone.annotations.MustBeClosed +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.models.websearch.research.ResearchCreateParams +import com.telnyx.sdk.models.websearch.research.ResearchCreateResponse +import com.telnyx.sdk.models.websearch.research.ResearchRetrieveParams +import com.telnyx.sdk.models.websearch.research.ResearchRetrieveResponse +import java.util.function.Consumer + +/** Deep research with citations and async task polling. */ +interface ResearchService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ResearchService + + /** + * Starts a deep research task that runs multiple searches, reads sources, and synthesizes an + * answer with citations. + * + * ## Synchronous mode (default) + * + * When `background` is `false` or omitted, the request blocks until the research completes and + * returns the answer with citations. This can take up to 120 seconds depending on + * `research_effort`. + * + * ## Asynchronous mode + * + * When `background` is `true`, the request returns immediately with a `task_id` and `status: + * pending`. Poll `GET /web_search/research/{task_id}` to check when the research completes and + * retrieve the answer. + */ + fun create(params: ResearchCreateParams): ResearchCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ResearchCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ResearchCreateResponse + + /** + * Polls the status of a previously started asynchronous research task. When the status is + * `completed`, the response includes the answer and citations. When the status is `failed`, the + * response includes an error message. + */ + fun retrieve(taskId: String): ResearchRetrieveResponse = + retrieve(taskId, ResearchRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + taskId: String, + params: ResearchRetrieveParams = ResearchRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ResearchRetrieveResponse = + retrieve(params.toBuilder().taskId(taskId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + taskId: String, + params: ResearchRetrieveParams = ResearchRetrieveParams.none(), + ): ResearchRetrieveResponse = retrieve(taskId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ResearchRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ResearchRetrieveResponse + + /** @see retrieve */ + fun retrieve(params: ResearchRetrieveParams): ResearchRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(taskId: String, requestOptions: RequestOptions): ResearchRetrieveResponse = + retrieve(taskId, ResearchRetrieveParams.none(), requestOptions) + + /** A view of [ResearchService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ResearchService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /web_search/research`, but is otherwise the same as + * [ResearchService.create]. + */ + @MustBeClosed + fun create(params: ResearchCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: ResearchCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /web_search/research/{task_id}`, but is otherwise + * the same as [ResearchService.retrieve]. + */ + @MustBeClosed + fun retrieve(taskId: String): HttpResponseFor = + retrieve(taskId, ResearchRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + taskId: String, + params: ResearchRetrieveParams = ResearchRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().taskId(taskId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + taskId: String, + params: ResearchRetrieveParams = ResearchRetrieveParams.none(), + ): HttpResponseFor = + retrieve(taskId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: ResearchRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: ResearchRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + taskId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(taskId, ResearchRetrieveParams.none(), requestOptions) + } +} diff --git a/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/websearch/ResearchServiceImpl.kt b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/websearch/ResearchServiceImpl.kt new file mode 100644 index 000000000..cd4fa79ff --- /dev/null +++ b/telnyx-core/src/main/kotlin/com/telnyx/sdk/services/blocking/websearch/ResearchServiceImpl.kt @@ -0,0 +1,124 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking.websearch + +import com.telnyx.sdk.core.ClientOptions +import com.telnyx.sdk.core.RequestOptions +import com.telnyx.sdk.core.checkRequired +import com.telnyx.sdk.core.handlers.errorBodyHandler +import com.telnyx.sdk.core.handlers.errorHandler +import com.telnyx.sdk.core.handlers.jsonHandler +import com.telnyx.sdk.core.http.HttpMethod +import com.telnyx.sdk.core.http.HttpRequest +import com.telnyx.sdk.core.http.HttpResponse +import com.telnyx.sdk.core.http.HttpResponse.Handler +import com.telnyx.sdk.core.http.HttpResponseFor +import com.telnyx.sdk.core.http.json +import com.telnyx.sdk.core.http.parseable +import com.telnyx.sdk.core.prepare +import com.telnyx.sdk.models.websearch.research.ResearchCreateParams +import com.telnyx.sdk.models.websearch.research.ResearchCreateResponse +import com.telnyx.sdk.models.websearch.research.ResearchRetrieveParams +import com.telnyx.sdk.models.websearch.research.ResearchRetrieveResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +/** Deep research with citations and async task polling. */ +class ResearchServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ResearchService { + + private val withRawResponse: ResearchService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ResearchService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ResearchService = + ResearchServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: ResearchCreateParams, + requestOptions: RequestOptions, + ): ResearchCreateResponse = + // post /web_search/research + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: ResearchRetrieveParams, + requestOptions: RequestOptions, + ): ResearchRetrieveResponse = + // get /web_search/research/{task_id} + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ResearchService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ResearchService.WithRawResponse = + ResearchServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: ResearchCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("web_search", "research") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: ResearchRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("taskId", params.taskId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("web_search", "research", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/calls/CallDialParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/calls/CallDialParamsTest.kt index c3d5753c9..c45e7f189 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/calls/CallDialParamsTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/calls/CallDialParamsTest.kt @@ -341,11 +341,11 @@ internal class CallDialParamsTest { CallDialParams.WebhookUrls.builder() .putAdditionalProperty( "call.hangup", - JsonValue.from("https://www.example.com/webhooks/hangup"), + JsonValue.from(listOf("https://www.example.com/webhooks/hangup")), ) .putAdditionalProperty( "call.bridge", - JsonValue.from("https://www.example.com/webhooks/bridge"), + JsonValue.from(listOf("https://www.example.com/webhooks/bridge")), ) .build() ) @@ -680,11 +680,11 @@ internal class CallDialParamsTest { CallDialParams.WebhookUrls.builder() .putAdditionalProperty( "call.hangup", - JsonValue.from("https://www.example.com/webhooks/hangup"), + JsonValue.from(listOf("https://www.example.com/webhooks/hangup")), ) .putAdditionalProperty( "call.bridge", - JsonValue.from("https://www.example.com/webhooks/bridge"), + JsonValue.from(listOf("https://www.example.com/webhooks/bridge")), ) .build() ) @@ -1038,11 +1038,11 @@ internal class CallDialParamsTest { CallDialParams.WebhookUrls.builder() .putAdditionalProperty( "call.hangup", - JsonValue.from("https://www.example.com/webhooks/hangup"), + JsonValue.from(listOf("https://www.example.com/webhooks/hangup")), ) .putAdditionalProperty( "call.bridge", - JsonValue.from("https://www.example.com/webhooks/bridge"), + JsonValue.from(listOf("https://www.example.com/webhooks/bridge")), ) .build() ) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/calls/actions/ActionAnswerParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/calls/actions/ActionAnswerParamsTest.kt index 9c62c4693..14796ee76 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/calls/actions/ActionAnswerParamsTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/calls/actions/ActionAnswerParamsTest.kt @@ -268,11 +268,11 @@ internal class ActionAnswerParamsTest { ActionAnswerParams.WebhookUrls.builder() .putAdditionalProperty( "call.hangup", - JsonValue.from("https://www.example.com/webhooks/hangup"), + JsonValue.from(listOf("https://www.example.com/webhooks/hangup")), ) .putAdditionalProperty( "call.bridge", - JsonValue.from("https://www.example.com/webhooks/bridge"), + JsonValue.from(listOf("https://www.example.com/webhooks/bridge")), ) .build() ) @@ -542,11 +542,11 @@ internal class ActionAnswerParamsTest { ActionAnswerParams.WebhookUrls.builder() .putAdditionalProperty( "call.hangup", - JsonValue.from("https://www.example.com/webhooks/hangup"), + JsonValue.from(listOf("https://www.example.com/webhooks/hangup")), ) .putAdditionalProperty( "call.bridge", - JsonValue.from("https://www.example.com/webhooks/bridge"), + JsonValue.from(listOf("https://www.example.com/webhooks/bridge")), ) .build() ) @@ -810,11 +810,11 @@ internal class ActionAnswerParamsTest { ActionAnswerParams.WebhookUrls.builder() .putAdditionalProperty( "call.hangup", - JsonValue.from("https://www.example.com/webhooks/hangup"), + JsonValue.from(listOf("https://www.example.com/webhooks/hangup")), ) .putAdditionalProperty( "call.bridge", - JsonValue.from("https://www.example.com/webhooks/bridge"), + JsonValue.from(listOf("https://www.example.com/webhooks/bridge")), ) .build() ) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/calls/actions/ActionTransferParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/calls/actions/ActionTransferParamsTest.kt index 3793797fc..eefae24c8 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/calls/actions/ActionTransferParamsTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/calls/actions/ActionTransferParamsTest.kt @@ -88,11 +88,11 @@ internal class ActionTransferParamsTest { ActionTransferParams.WebhookUrls.builder() .putAdditionalProperty( "call.answered", - JsonValue.from("https://www.example.com/webhooks/answered"), + JsonValue.from(listOf("https://www.example.com/webhooks/answered")), ) .putAdditionalProperty( "call.hangup", - JsonValue.from("https://www.example.com/webhooks/hangup"), + JsonValue.from(listOf("https://www.example.com/webhooks/hangup")), ) .build() ) @@ -190,11 +190,11 @@ internal class ActionTransferParamsTest { ActionTransferParams.WebhookUrls.builder() .putAdditionalProperty( "call.answered", - JsonValue.from("https://www.example.com/webhooks/answered"), + JsonValue.from(listOf("https://www.example.com/webhooks/answered")), ) .putAdditionalProperty( "call.hangup", - JsonValue.from("https://www.example.com/webhooks/hangup"), + JsonValue.from(listOf("https://www.example.com/webhooks/hangup")), ) .build() ) @@ -285,11 +285,11 @@ internal class ActionTransferParamsTest { ActionTransferParams.WebhookUrls.builder() .putAdditionalProperty( "call.answered", - JsonValue.from("https://www.example.com/webhooks/answered"), + JsonValue.from(listOf("https://www.example.com/webhooks/answered")), ) .putAdditionalProperty( "call.hangup", - JsonValue.from("https://www.example.com/webhooks/hangup"), + JsonValue.from(listOf("https://www.example.com/webhooks/hangup")), ) .build() ) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailCreateParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailCreateParamsTest.kt index a853c1bc5..966ff5b96 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailCreateParamsTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailCreateParamsTest.kt @@ -11,7 +11,18 @@ internal class VoicemailCreateParamsTest { fun create() { VoicemailCreateParams.builder() .phoneNumberId("123455678900") - .voicemailRequest(VoicemailRequest.builder().enabled(true).pin("1234").build()) + .voicemailRequest( + VoicemailRequest.builder() + .enabled(true) + .greeting( + VoicemailRequest.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailRequest.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() + ) .build() } @@ -33,12 +44,35 @@ internal class VoicemailCreateParamsTest { val params = VoicemailCreateParams.builder() .phoneNumberId("123455678900") - .voicemailRequest(VoicemailRequest.builder().enabled(true).pin("1234").build()) + .voicemailRequest( + VoicemailRequest.builder() + .enabled(true) + .greeting( + VoicemailRequest.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailRequest.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() + ) .build() val body = params._body() - assertThat(body).isEqualTo(VoicemailRequest.builder().enabled(true).pin("1234").build()) + assertThat(body) + .isEqualTo( + VoicemailRequest.builder() + .enabled(true) + .greeting( + VoicemailRequest.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailRequest.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() + ) } @Test diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailCreateResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailCreateResponseTest.kt index b9d5fc86e..ebf57e0b2 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailCreateResponseTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailCreateResponseTest.kt @@ -13,11 +13,33 @@ internal class VoicemailCreateResponseTest { fun create() { val voicemailCreateResponse = VoicemailCreateResponse.builder() - .data(VoicemailPrefResponse.builder().enabled(true).pin("1234").build()) + .data( + VoicemailPrefResponse.builder() + .enabled(true) + .greeting( + VoicemailPrefResponse.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailPrefResponse.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() + ) .build() assertThat(voicemailCreateResponse.data()) - .contains(VoicemailPrefResponse.builder().enabled(true).pin("1234").build()) + .contains( + VoicemailPrefResponse.builder() + .enabled(true) + .greeting( + VoicemailPrefResponse.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailPrefResponse.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() + ) } @Test @@ -25,7 +47,18 @@ internal class VoicemailCreateResponseTest { val jsonMapper = jsonMapper() val voicemailCreateResponse = VoicemailCreateResponse.builder() - .data(VoicemailPrefResponse.builder().enabled(true).pin("1234").build()) + .data( + VoicemailPrefResponse.builder() + .enabled(true) + .greeting( + VoicemailPrefResponse.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailPrefResponse.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() + ) .build() val roundtrippedVoicemailCreateResponse = diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailPrefResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailPrefResponseTest.kt index 2fcd53d4a..617b8f70d 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailPrefResponseTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailPrefResponseTest.kt @@ -12,9 +12,25 @@ internal class VoicemailPrefResponseTest { @Test fun create() { val voicemailPrefResponse = - VoicemailPrefResponse.builder().enabled(true).pin("1234").build() + VoicemailPrefResponse.builder() + .enabled(true) + .greeting( + VoicemailPrefResponse.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailPrefResponse.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() assertThat(voicemailPrefResponse.enabled()).contains(true) + assertThat(voicemailPrefResponse.greeting()) + .contains( + VoicemailPrefResponse.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailPrefResponse.Greeting.Mode.CUSTOM_GREETING) + .build() + ) assertThat(voicemailPrefResponse.pin()).contains("1234") } @@ -22,7 +38,16 @@ internal class VoicemailPrefResponseTest { fun roundtrip() { val jsonMapper = jsonMapper() val voicemailPrefResponse = - VoicemailPrefResponse.builder().enabled(true).pin("1234").build() + VoicemailPrefResponse.builder() + .enabled(true) + .greeting( + VoicemailPrefResponse.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailPrefResponse.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() val roundtrippedVoicemailPrefResponse = jsonMapper.readValue( diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailRequestTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailRequestTest.kt index 65a63a054..52491ff1c 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailRequestTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailRequestTest.kt @@ -11,16 +11,43 @@ internal class VoicemailRequestTest { @Test fun create() { - val voicemailRequest = VoicemailRequest.builder().enabled(true).pin("1234").build() + val voicemailRequest = + VoicemailRequest.builder() + .enabled(true) + .greeting( + VoicemailRequest.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailRequest.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() assertThat(voicemailRequest.enabled()).contains(true) + assertThat(voicemailRequest.greeting()) + .contains( + VoicemailRequest.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailRequest.Greeting.Mode.CUSTOM_GREETING) + .build() + ) assertThat(voicemailRequest.pin()).contains("1234") } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val voicemailRequest = VoicemailRequest.builder().enabled(true).pin("1234").build() + val voicemailRequest = + VoicemailRequest.builder() + .enabled(true) + .greeting( + VoicemailRequest.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailRequest.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() val roundtrippedVoicemailRequest = jsonMapper.readValue( diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailRetrieveResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailRetrieveResponseTest.kt index 76f74f00c..cdccb5607 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailRetrieveResponseTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailRetrieveResponseTest.kt @@ -13,11 +13,33 @@ internal class VoicemailRetrieveResponseTest { fun create() { val voicemailRetrieveResponse = VoicemailRetrieveResponse.builder() - .data(VoicemailPrefResponse.builder().enabled(true).pin("1234").build()) + .data( + VoicemailPrefResponse.builder() + .enabled(true) + .greeting( + VoicemailPrefResponse.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailPrefResponse.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() + ) .build() assertThat(voicemailRetrieveResponse.data()) - .contains(VoicemailPrefResponse.builder().enabled(true).pin("1234").build()) + .contains( + VoicemailPrefResponse.builder() + .enabled(true) + .greeting( + VoicemailPrefResponse.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailPrefResponse.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() + ) } @Test @@ -25,7 +47,18 @@ internal class VoicemailRetrieveResponseTest { val jsonMapper = jsonMapper() val voicemailRetrieveResponse = VoicemailRetrieveResponse.builder() - .data(VoicemailPrefResponse.builder().enabled(true).pin("1234").build()) + .data( + VoicemailPrefResponse.builder() + .enabled(true) + .greeting( + VoicemailPrefResponse.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailPrefResponse.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() + ) .build() val roundtrippedVoicemailRetrieveResponse = diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailUpdateParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailUpdateParamsTest.kt index 1b6f3252e..94ad098ce 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailUpdateParamsTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailUpdateParamsTest.kt @@ -11,7 +11,18 @@ internal class VoicemailUpdateParamsTest { fun create() { VoicemailUpdateParams.builder() .phoneNumberId("123455678900") - .voicemailRequest(VoicemailRequest.builder().enabled(true).pin("1234").build()) + .voicemailRequest( + VoicemailRequest.builder() + .enabled(true) + .greeting( + VoicemailRequest.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailRequest.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() + ) .build() } @@ -33,12 +44,35 @@ internal class VoicemailUpdateParamsTest { val params = VoicemailUpdateParams.builder() .phoneNumberId("123455678900") - .voicemailRequest(VoicemailRequest.builder().enabled(true).pin("1234").build()) + .voicemailRequest( + VoicemailRequest.builder() + .enabled(true) + .greeting( + VoicemailRequest.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailRequest.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() + ) .build() val body = params._body() - assertThat(body).isEqualTo(VoicemailRequest.builder().enabled(true).pin("1234").build()) + assertThat(body) + .isEqualTo( + VoicemailRequest.builder() + .enabled(true) + .greeting( + VoicemailRequest.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailRequest.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() + ) } @Test diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailUpdateResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailUpdateResponseTest.kt index 0dead67a4..81baf3c23 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailUpdateResponseTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/phonenumbers/voicemail/VoicemailUpdateResponseTest.kt @@ -13,11 +13,33 @@ internal class VoicemailUpdateResponseTest { fun create() { val voicemailUpdateResponse = VoicemailUpdateResponse.builder() - .data(VoicemailPrefResponse.builder().enabled(true).pin("1234").build()) + .data( + VoicemailPrefResponse.builder() + .enabled(true) + .greeting( + VoicemailPrefResponse.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailPrefResponse.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() + ) .build() assertThat(voicemailUpdateResponse.data()) - .contains(VoicemailPrefResponse.builder().enabled(true).pin("1234").build()) + .contains( + VoicemailPrefResponse.builder() + .enabled(true) + .greeting( + VoicemailPrefResponse.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailPrefResponse.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() + ) } @Test @@ -25,7 +47,18 @@ internal class VoicemailUpdateResponseTest { val jsonMapper = jsonMapper() val voicemailUpdateResponse = VoicemailUpdateResponse.builder() - .data(VoicemailPrefResponse.builder().enabled(true).pin("1234").build()) + .data( + VoicemailPrefResponse.builder() + .enabled(true) + .greeting( + VoicemailPrefResponse.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailPrefResponse.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() + ) .build() val roundtrippedVoicemailUpdateResponse = diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/simcards/actions/ActionBulkEnableVoiceParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/simcards/actions/ActionBulkEnableVoiceParamsTest.kt index 3b70e47cf..098e77f1b 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/simcards/actions/ActionBulkEnableVoiceParamsTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/simcards/actions/ActionBulkEnableVoiceParamsTest.kt @@ -11,11 +11,26 @@ internal class ActionBulkEnableVoiceParamsTest { fun create() { ActionBulkEnableVoiceParams.builder() .simCardGroupId("6b14e151-8493-4fa1-8664-1cc4e6d14158") + .connectionId("123456789") .build() } @Test fun body() { + val params = + ActionBulkEnableVoiceParams.builder() + .simCardGroupId("6b14e151-8493-4fa1-8664-1cc4e6d14158") + .connectionId("123456789") + .build() + + val body = params._body() + + assertThat(body.simCardGroupId()).isEqualTo("6b14e151-8493-4fa1-8664-1cc4e6d14158") + assertThat(body.connectionId()).contains("123456789") + } + + @Test + fun bodyWithoutOptionalFields() { val params = ActionBulkEnableVoiceParams.builder() .simCardGroupId("6b14e151-8493-4fa1-8664-1cc4e6d14158") diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/simcards/actions/ActionDisableVoiceParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/simcards/actions/ActionDisableVoiceParamsTest.kt new file mode 100644 index 000000000..dcae01254 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/simcards/actions/ActionDisableVoiceParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.simcards.actions + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ActionDisableVoiceParamsTest { + + @Test + fun create() { + ActionDisableVoiceParams.builder().id("6a09cdc3-8948-47f0-aa62-74ac943d6c58").build() + } + + @Test + fun pathParams() { + val params = + ActionDisableVoiceParams.builder().id("6a09cdc3-8948-47f0-aa62-74ac943d6c58").build() + + assertThat(params._pathParam(0)).isEqualTo("6a09cdc3-8948-47f0-aa62-74ac943d6c58") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/simcards/actions/ActionDisableVoiceResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/simcards/actions/ActionDisableVoiceResponseTest.kt new file mode 100644 index 000000000..5bc48807f --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/simcards/actions/ActionDisableVoiceResponseTest.kt @@ -0,0 +1,87 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.simcards.actions + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ActionDisableVoiceResponseTest { + + @Test + fun create() { + val actionDisableVoiceResponse = + ActionDisableVoiceResponse.builder() + .data( + WirelessSimCardAction.builder() + .id("6a09cdc3-8948-47f0-aa62-74ac943d6c58") + .actionType(WirelessSimCardAction.ActionType.ENABLE) + .createdAt("2018-02-02T22:25:27.521Z") + .recordType("sim_card_action") + .settings(WirelessSimCardAction.Settings.builder().build()) + .simCardId("6a09cdc3-8948-47f0-aa62-74ac943d6c58") + .status( + WirelessSimCardAction.Status.builder() + .reason("The data limit was exceeded.") + .value(WirelessSimCardAction.Status.Value_.COMPLETED) + .build() + ) + .updatedAt("2018-02-02T22:25:27.521Z") + .build() + ) + .build() + + assertThat(actionDisableVoiceResponse.data()) + .contains( + WirelessSimCardAction.builder() + .id("6a09cdc3-8948-47f0-aa62-74ac943d6c58") + .actionType(WirelessSimCardAction.ActionType.ENABLE) + .createdAt("2018-02-02T22:25:27.521Z") + .recordType("sim_card_action") + .settings(WirelessSimCardAction.Settings.builder().build()) + .simCardId("6a09cdc3-8948-47f0-aa62-74ac943d6c58") + .status( + WirelessSimCardAction.Status.builder() + .reason("The data limit was exceeded.") + .value(WirelessSimCardAction.Status.Value_.COMPLETED) + .build() + ) + .updatedAt("2018-02-02T22:25:27.521Z") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val actionDisableVoiceResponse = + ActionDisableVoiceResponse.builder() + .data( + WirelessSimCardAction.builder() + .id("6a09cdc3-8948-47f0-aa62-74ac943d6c58") + .actionType(WirelessSimCardAction.ActionType.ENABLE) + .createdAt("2018-02-02T22:25:27.521Z") + .recordType("sim_card_action") + .settings(WirelessSimCardAction.Settings.builder().build()) + .simCardId("6a09cdc3-8948-47f0-aa62-74ac943d6c58") + .status( + WirelessSimCardAction.Status.builder() + .reason("The data limit was exceeded.") + .value(WirelessSimCardAction.Status.Value_.COMPLETED) + .build() + ) + .updatedAt("2018-02-02T22:25:27.521Z") + .build() + ) + .build() + + val roundtrippedActionDisableVoiceResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(actionDisableVoiceResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedActionDisableVoiceResponse).isEqualTo(actionDisableVoiceResponse) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/simcards/actions/ActionEnableVoiceParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/simcards/actions/ActionEnableVoiceParamsTest.kt new file mode 100644 index 000000000..2e6a96938 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/simcards/actions/ActionEnableVoiceParamsTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.simcards.actions + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ActionEnableVoiceParamsTest { + + @Test + fun create() { + ActionEnableVoiceParams.builder() + .id("6a09cdc3-8948-47f0-aa62-74ac943d6c58") + .connectionId("123456789") + .build() + } + + @Test + fun pathParams() { + val params = + ActionEnableVoiceParams.builder().id("6a09cdc3-8948-47f0-aa62-74ac943d6c58").build() + + assertThat(params._pathParam(0)).isEqualTo("6a09cdc3-8948-47f0-aa62-74ac943d6c58") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + ActionEnableVoiceParams.builder() + .id("6a09cdc3-8948-47f0-aa62-74ac943d6c58") + .connectionId("123456789") + .build() + + val body = params._body() + + assertThat(body.connectionId()).contains("123456789") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ActionEnableVoiceParams.builder().id("6a09cdc3-8948-47f0-aa62-74ac943d6c58").build() + + val body = params._body() + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/simcards/actions/ActionEnableVoiceResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/simcards/actions/ActionEnableVoiceResponseTest.kt new file mode 100644 index 000000000..1108bb85c --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/simcards/actions/ActionEnableVoiceResponseTest.kt @@ -0,0 +1,87 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.simcards.actions + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ActionEnableVoiceResponseTest { + + @Test + fun create() { + val actionEnableVoiceResponse = + ActionEnableVoiceResponse.builder() + .data( + WirelessSimCardAction.builder() + .id("6a09cdc3-8948-47f0-aa62-74ac943d6c58") + .actionType(WirelessSimCardAction.ActionType.ENABLE) + .createdAt("2018-02-02T22:25:27.521Z") + .recordType("sim_card_action") + .settings(WirelessSimCardAction.Settings.builder().build()) + .simCardId("6a09cdc3-8948-47f0-aa62-74ac943d6c58") + .status( + WirelessSimCardAction.Status.builder() + .reason("The data limit was exceeded.") + .value(WirelessSimCardAction.Status.Value_.COMPLETED) + .build() + ) + .updatedAt("2018-02-02T22:25:27.521Z") + .build() + ) + .build() + + assertThat(actionEnableVoiceResponse.data()) + .contains( + WirelessSimCardAction.builder() + .id("6a09cdc3-8948-47f0-aa62-74ac943d6c58") + .actionType(WirelessSimCardAction.ActionType.ENABLE) + .createdAt("2018-02-02T22:25:27.521Z") + .recordType("sim_card_action") + .settings(WirelessSimCardAction.Settings.builder().build()) + .simCardId("6a09cdc3-8948-47f0-aa62-74ac943d6c58") + .status( + WirelessSimCardAction.Status.builder() + .reason("The data limit was exceeded.") + .value(WirelessSimCardAction.Status.Value_.COMPLETED) + .build() + ) + .updatedAt("2018-02-02T22:25:27.521Z") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val actionEnableVoiceResponse = + ActionEnableVoiceResponse.builder() + .data( + WirelessSimCardAction.builder() + .id("6a09cdc3-8948-47f0-aa62-74ac943d6c58") + .actionType(WirelessSimCardAction.ActionType.ENABLE) + .createdAt("2018-02-02T22:25:27.521Z") + .recordType("sim_card_action") + .settings(WirelessSimCardAction.Settings.builder().build()) + .simCardId("6a09cdc3-8948-47f0-aa62-74ac943d6c58") + .status( + WirelessSimCardAction.Status.builder() + .reason("The data limit was exceeded.") + .value(WirelessSimCardAction.Status.Value_.COMPLETED) + .build() + ) + .updatedAt("2018-02-02T22:25:27.521Z") + .build() + ) + .build() + + val roundtrippedActionEnableVoiceResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(actionEnableVoiceResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedActionEnableVoiceResponse).isEqualTo(actionEnableVoiceResponse) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/kvs/EdgeComputePaginationMetaTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/kvs/EdgeComputePaginationMetaTest.kt new file mode 100644 index 000000000..7826969d1 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/kvs/EdgeComputePaginationMetaTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.kvs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class EdgeComputePaginationMetaTest { + + @Test + fun create() { + val edgeComputePaginationMeta = + EdgeComputePaginationMeta.builder() + .pageNumber(1L) + .pageSize(20L) + .totalPages(3L) + .totalResults(52L) + .build() + + assertThat(edgeComputePaginationMeta.pageNumber()).contains(1L) + assertThat(edgeComputePaginationMeta.pageSize()).contains(20L) + assertThat(edgeComputePaginationMeta.totalPages()).contains(3L) + assertThat(edgeComputePaginationMeta.totalResults()).contains(52L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val edgeComputePaginationMeta = + EdgeComputePaginationMeta.builder() + .pageNumber(1L) + .pageSize(20L) + .totalPages(3L) + .totalResults(52L) + .build() + + val roundtrippedEdgeComputePaginationMeta = + jsonMapper.readValue( + jsonMapper.writeValueAsString(edgeComputePaginationMeta), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEdgeComputePaginationMeta).isEqualTo(edgeComputePaginationMeta) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/kvs/KvListPageResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/kvs/KvListPageResponseTest.kt index 92745f7fc..0c65df275 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/kvs/KvListPageResponseTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/kvs/KvListPageResponseTest.kt @@ -26,7 +26,7 @@ internal class KvListPageResponseTest { .build() ) .meta( - KvListPageResponse.Meta.builder() + EdgeComputePaginationMeta.builder() .pageNumber(1L) .pageSize(20L) .totalPages(3L) @@ -48,7 +48,7 @@ internal class KvListPageResponseTest { ) assertThat(kvListPageResponse.meta()) .contains( - KvListPageResponse.Meta.builder() + EdgeComputePaginationMeta.builder() .pageNumber(1L) .pageSize(20L) .totalPages(3L) @@ -73,7 +73,7 @@ internal class KvListPageResponseTest { .build() ) .meta( - KvListPageResponse.Meta.builder() + EdgeComputePaginationMeta.builder() .pageNumber(1L) .pageSize(20L) .totalPages(3L) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqlDatabaseResponseWrapperTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqlDatabaseResponseWrapperTest.kt new file mode 100644 index 000000000..3ec62c288 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqlDatabaseResponseWrapperTest.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.sqldbs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SqlDatabaseResponseWrapperTest { + + @Test + fun create() { + val sqlDatabaseResponseWrapper = + SqlDatabaseResponseWrapper.builder() + .data( + SqlDatabase.builder() + .id("550e8400-e29b-41d4-a716-446655440000") + .createdAt(OffsetDateTime.parse("2026-06-18T14:48:17Z")) + .name("my-database") + .recordType("storage_sqldb") + .status(SqlDatabase.Status.PROVISION_OK) + .updatedAt(OffsetDateTime.parse("2026-06-18T14:48:17Z")) + .build() + ) + .build() + + assertThat(sqlDatabaseResponseWrapper.data()) + .contains( + SqlDatabase.builder() + .id("550e8400-e29b-41d4-a716-446655440000") + .createdAt(OffsetDateTime.parse("2026-06-18T14:48:17Z")) + .name("my-database") + .recordType("storage_sqldb") + .status(SqlDatabase.Status.PROVISION_OK) + .updatedAt(OffsetDateTime.parse("2026-06-18T14:48:17Z")) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val sqlDatabaseResponseWrapper = + SqlDatabaseResponseWrapper.builder() + .data( + SqlDatabase.builder() + .id("550e8400-e29b-41d4-a716-446655440000") + .createdAt(OffsetDateTime.parse("2026-06-18T14:48:17Z")) + .name("my-database") + .recordType("storage_sqldb") + .status(SqlDatabase.Status.PROVISION_OK) + .updatedAt(OffsetDateTime.parse("2026-06-18T14:48:17Z")) + .build() + ) + .build() + + val roundtrippedSqlDatabaseResponseWrapper = + jsonMapper.readValue( + jsonMapper.writeValueAsString(sqlDatabaseResponseWrapper), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSqlDatabaseResponseWrapper).isEqualTo(sqlDatabaseResponseWrapper) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqlDatabaseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqlDatabaseTest.kt new file mode 100644 index 000000000..d6bed0107 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqlDatabaseTest.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.sqldbs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SqlDatabaseTest { + + @Test + fun create() { + val sqlDatabase = + SqlDatabase.builder() + .id("550e8400-e29b-41d4-a716-446655440000") + .createdAt(OffsetDateTime.parse("2026-06-18T14:48:17Z")) + .name("my-database") + .recordType("storage_sqldb") + .status(SqlDatabase.Status.PROVISION_OK) + .updatedAt(OffsetDateTime.parse("2026-06-18T14:48:17Z")) + .build() + + assertThat(sqlDatabase.id()).contains("550e8400-e29b-41d4-a716-446655440000") + assertThat(sqlDatabase.createdAt()).contains(OffsetDateTime.parse("2026-06-18T14:48:17Z")) + assertThat(sqlDatabase.name()).contains("my-database") + assertThat(sqlDatabase.recordType()).contains("storage_sqldb") + assertThat(sqlDatabase.status()).contains(SqlDatabase.Status.PROVISION_OK) + assertThat(sqlDatabase.updatedAt()).contains(OffsetDateTime.parse("2026-06-18T14:48:17Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val sqlDatabase = + SqlDatabase.builder() + .id("550e8400-e29b-41d4-a716-446655440000") + .createdAt(OffsetDateTime.parse("2026-06-18T14:48:17Z")) + .name("my-database") + .recordType("storage_sqldb") + .status(SqlDatabase.Status.PROVISION_OK) + .updatedAt(OffsetDateTime.parse("2026-06-18T14:48:17Z")) + .build() + + val roundtrippedSqlDatabase = + jsonMapper.readValue( + jsonMapper.writeValueAsString(sqlDatabase), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSqlDatabase).isEqualTo(sqlDatabase) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbCreateParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbCreateParamsTest.kt new file mode 100644 index 000000000..dd07cf336 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbCreateParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.sqldbs + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SqldbCreateParamsTest { + + @Test + fun create() { + SqldbCreateParams.builder().name("my-database").build() + } + + @Test + fun body() { + val params = SqldbCreateParams.builder().name("my-database").build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("my-database") + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbDeleteParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbDeleteParamsTest.kt new file mode 100644 index 000000000..55a22762e --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbDeleteParamsTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.sqldbs + +import com.telnyx.sdk.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SqldbDeleteParamsTest { + + @Test + fun create() { + SqldbDeleteParams.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").force(true).build() + } + + @Test + fun pathParams() { + val params = SqldbDeleteParams.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + SqldbDeleteParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .force(true) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("force", "true").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = SqldbDeleteParams.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbListPageResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbListPageResponseTest.kt new file mode 100644 index 000000000..973816602 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbListPageResponseTest.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.sqldbs + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import com.telnyx.sdk.models.storage.kvs.EdgeComputePaginationMeta +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SqldbListPageResponseTest { + + @Test + fun create() { + val sqldbListPageResponse = + SqldbListPageResponse.builder() + .addData( + SqlDatabase.builder() + .id("550e8400-e29b-41d4-a716-446655440000") + .createdAt(OffsetDateTime.parse("2026-06-18T14:48:17Z")) + .name("my-database") + .recordType("storage_sqldb") + .status(SqlDatabase.Status.PROVISION_OK) + .updatedAt(OffsetDateTime.parse("2026-06-18T14:48:17Z")) + .build() + ) + .meta( + EdgeComputePaginationMeta.builder() + .pageNumber(1L) + .pageSize(20L) + .totalPages(3L) + .totalResults(52L) + .build() + ) + .build() + + assertThat(sqldbListPageResponse.data().getOrNull()) + .containsExactly( + SqlDatabase.builder() + .id("550e8400-e29b-41d4-a716-446655440000") + .createdAt(OffsetDateTime.parse("2026-06-18T14:48:17Z")) + .name("my-database") + .recordType("storage_sqldb") + .status(SqlDatabase.Status.PROVISION_OK) + .updatedAt(OffsetDateTime.parse("2026-06-18T14:48:17Z")) + .build() + ) + assertThat(sqldbListPageResponse.meta()) + .contains( + EdgeComputePaginationMeta.builder() + .pageNumber(1L) + .pageSize(20L) + .totalPages(3L) + .totalResults(52L) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val sqldbListPageResponse = + SqldbListPageResponse.builder() + .addData( + SqlDatabase.builder() + .id("550e8400-e29b-41d4-a716-446655440000") + .createdAt(OffsetDateTime.parse("2026-06-18T14:48:17Z")) + .name("my-database") + .recordType("storage_sqldb") + .status(SqlDatabase.Status.PROVISION_OK) + .updatedAt(OffsetDateTime.parse("2026-06-18T14:48:17Z")) + .build() + ) + .meta( + EdgeComputePaginationMeta.builder() + .pageNumber(1L) + .pageSize(20L) + .totalPages(3L) + .totalResults(52L) + .build() + ) + .build() + + val roundtrippedSqldbListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(sqldbListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSqldbListPageResponse).isEqualTo(sqldbListPageResponse) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbListParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbListParamsTest.kt new file mode 100644 index 000000000..ef3aabd2f --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbListParamsTest.kt @@ -0,0 +1,55 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.sqldbs + +import com.telnyx.sdk.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SqldbListParamsTest { + + @Test + fun create() { + SqldbListParams.builder() + .filterName("filter[name]") + .filterStatus(SqldbListParams.FilterStatus.PENDING) + .pageNumber(1L) + .pageSize(1L) + .sort(SqldbListParams.Sort.NAME) + .build() + } + + @Test + fun queryParams() { + val params = + SqldbListParams.builder() + .filterName("filter[name]") + .filterStatus(SqldbListParams.FilterStatus.PENDING) + .pageNumber(1L) + .pageSize(1L) + .sort(SqldbListParams.Sort.NAME) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("filter[name]", "filter[name]") + .put("filter[status]", "pending") + .put("page[number]", "1") + .put("page[size]", "1") + .put("sort", "name") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = SqldbListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbRetrieveParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbRetrieveParamsTest.kt new file mode 100644 index 000000000..7c5b8142b --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/SqldbRetrieveParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.sqldbs + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SqldbRetrieveParamsTest { + + @Test + fun create() { + SqldbRetrieveParams.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + } + + @Test + fun pathParams() { + val params = + SqldbRetrieveParams.builder().id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/actions/ActionQueryParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/actions/ActionQueryParamsTest.kt new file mode 100644 index 000000000..051253df1 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/actions/ActionQueryParamsTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.sqldbs.actions + +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ActionQueryParamsTest { + + @Test + fun create() { + ActionQueryParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sql("SELECT * FROM users WHERE name = ?") + .addParam("alice") + .build() + } + + @Test + fun pathParams() { + val params = + ActionQueryParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sql("SELECT * FROM users WHERE name = ?") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + ActionQueryParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sql("SELECT * FROM users WHERE name = ?") + .addParam("alice") + .build() + + val body = params._body() + + assertThat(body.sql()).isEqualTo("SELECT * FROM users WHERE name = ?") + assertThat(body.params().getOrNull()) + .containsExactly(ActionQueryParams.Param.ofString("alice")) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ActionQueryParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sql("SELECT * FROM users WHERE name = ?") + .build() + + val body = params._body() + + assertThat(body.sql()).isEqualTo("SELECT * FROM users WHERE name = ?") + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/actions/ActionQueryResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/actions/ActionQueryResponseTest.kt new file mode 100644 index 000000000..1f900c737 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/storage/sqldbs/actions/ActionQueryResponseTest.kt @@ -0,0 +1,100 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.storage.sqldbs.actions + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.JsonValue +import com.telnyx.sdk.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ActionQueryResponseTest { + + @Test + fun create() { + val actionQueryResponse = + ActionQueryResponse.builder() + .data( + ActionQueryResponse.Data.builder() + .count(1L) + .duration(2.5) + .meta( + ActionQueryResponse.Data.Meta.builder() + .changes(0L) + .duration(1.2) + .lastRowId(0L) + .rowsRead(3L) + .rowsWritten(0L) + .build() + ) + .addResult( + ActionQueryResponse.Data.Result.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .success(true) + .build() + ) + .build() + + assertThat(actionQueryResponse.data()) + .contains( + ActionQueryResponse.Data.builder() + .count(1L) + .duration(2.5) + .meta( + ActionQueryResponse.Data.Meta.builder() + .changes(0L) + .duration(1.2) + .lastRowId(0L) + .rowsRead(3L) + .rowsWritten(0L) + .build() + ) + .addResult( + ActionQueryResponse.Data.Result.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .success(true) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val actionQueryResponse = + ActionQueryResponse.builder() + .data( + ActionQueryResponse.Data.builder() + .count(1L) + .duration(2.5) + .meta( + ActionQueryResponse.Data.Meta.builder() + .changes(0L) + .duration(1.2) + .lastRowId(0L) + .rowsRead(3L) + .rowsWritten(0L) + .build() + ) + .addResult( + ActionQueryResponse.Data.Result.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .success(true) + .build() + ) + .build() + + val roundtrippedActionQueryResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(actionQueryResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedActionQueryResponse).isEqualTo(actionQueryResponse) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/WebSearchContentsParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/WebSearchContentsParamsTest.kt new file mode 100644 index 000000000..761947870 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/WebSearchContentsParamsTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.websearch + +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WebSearchContentsParamsTest { + + @Test + fun create() { + WebSearchContentsParams.builder() + .addUrl("https://en.wikipedia.org/wiki/Artificial_intelligence") + .crawlTimeout(10L) + .addFormat(WebSearchContentsParams.Format.MARKDOWN) + .addFormat(WebSearchContentsParams.Format.METADATA) + .maxAge(null) + .build() + } + + @Test + fun body() { + val params = + WebSearchContentsParams.builder() + .addUrl("https://en.wikipedia.org/wiki/Artificial_intelligence") + .crawlTimeout(10L) + .addFormat(WebSearchContentsParams.Format.MARKDOWN) + .addFormat(WebSearchContentsParams.Format.METADATA) + .maxAge(null) + .build() + + val body = params._body() + + assertThat(body.urls()) + .containsExactly("https://en.wikipedia.org/wiki/Artificial_intelligence") + assertThat(body.crawlTimeout()).contains(10L) + assertThat(body.formats().getOrNull()) + .containsExactly( + WebSearchContentsParams.Format.MARKDOWN, + WebSearchContentsParams.Format.METADATA, + ) + assertThat(body.maxAge()).isEmpty + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + WebSearchContentsParams.builder() + .addUrl("https://en.wikipedia.org/wiki/Artificial_intelligence") + .build() + + val body = params._body() + + assertThat(body.urls()) + .containsExactly("https://en.wikipedia.org/wiki/Artificial_intelligence") + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/WebSearchContentsResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/WebSearchContentsResponseTest.kt new file mode 100644 index 000000000..fc717b2a6 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/WebSearchContentsResponseTest.kt @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.websearch + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WebSearchContentsResponseTest { + + @Test + fun create() { + val webSearchContentsResponse = + WebSearchContentsResponse.builder() + .data( + WebSearchContentsResponse.Data.builder() + .addResult( + WebSearchContentsResponse.Data.Result.builder() + .url("https://example.com") + .html("html") + .markdown("markdown") + .metadata( + WebSearchContentsResponse.Data.Result.Metadata.builder() + .faviconUrl("https://example.com") + .siteName("site_name") + .build() + ) + .title("title") + .build() + ) + .build() + ) + .build() + + assertThat(webSearchContentsResponse.data()) + .contains( + WebSearchContentsResponse.Data.builder() + .addResult( + WebSearchContentsResponse.Data.Result.builder() + .url("https://example.com") + .html("html") + .markdown("markdown") + .metadata( + WebSearchContentsResponse.Data.Result.Metadata.builder() + .faviconUrl("https://example.com") + .siteName("site_name") + .build() + ) + .title("title") + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val webSearchContentsResponse = + WebSearchContentsResponse.builder() + .data( + WebSearchContentsResponse.Data.builder() + .addResult( + WebSearchContentsResponse.Data.Result.builder() + .url("https://example.com") + .html("html") + .markdown("markdown") + .metadata( + WebSearchContentsResponse.Data.Result.Metadata.builder() + .faviconUrl("https://example.com") + .siteName("site_name") + .build() + ) + .title("title") + .build() + ) + .build() + ) + .build() + + val roundtrippedWebSearchContentsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(webSearchContentsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedWebSearchContentsResponse).isEqualTo(webSearchContentsResponse) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/WebSearchCreateParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/WebSearchCreateParamsTest.kt new file mode 100644 index 000000000..dbe411750 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/WebSearchCreateParamsTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.websearch + +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WebSearchCreateParamsTest { + + @Test + fun create() { + WebSearchCreateParams.builder() + .query("latest AI agent frameworks") + .count(10L) + .country("US") + .addExcludeDomain("pinterest.com") + .freshness("week") + .addIncludeDomain("arxiv.org") + .addIncludeDomain("github.com") + .livecrawl(false) + .safesearch(WebSearchCreateParams.Safesearch.MODERATE) + .build() + } + + @Test + fun body() { + val params = + WebSearchCreateParams.builder() + .query("latest AI agent frameworks") + .count(10L) + .country("US") + .addExcludeDomain("pinterest.com") + .freshness("week") + .addIncludeDomain("arxiv.org") + .addIncludeDomain("github.com") + .livecrawl(false) + .safesearch(WebSearchCreateParams.Safesearch.MODERATE) + .build() + + val body = params._body() + + assertThat(body.query()).isEqualTo("latest AI agent frameworks") + assertThat(body.count()).contains(10L) + assertThat(body.country()).contains("US") + assertThat(body.excludeDomains().getOrNull()).containsExactly("pinterest.com") + assertThat(body.freshness()).contains("week") + assertThat(body.includeDomains().getOrNull()).containsExactly("arxiv.org", "github.com") + assertThat(body.livecrawl()).contains(false) + assertThat(body.safesearch()).contains(WebSearchCreateParams.Safesearch.MODERATE) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = WebSearchCreateParams.builder().query("latest AI agent frameworks").build() + + val body = params._body() + + assertThat(body.query()).isEqualTo("latest AI agent frameworks") + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/WebSearchCreateResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/WebSearchCreateResponseTest.kt new file mode 100644 index 000000000..9dc4ced02 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/WebSearchCreateResponseTest.kt @@ -0,0 +1,120 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.websearch + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WebSearchCreateResponseTest { + + @Test + fun create() { + val webSearchCreateResponse = + WebSearchCreateResponse.builder() + .data( + WebSearchCreateResponse.Data.builder() + .results( + WebSearchCreateResponse.Data.Results.builder() + .addWeb( + WebSearchResult.builder() + .description("description") + .addSnippet("string") + .title("title") + .url("https://example.com") + .faviconUrl("https://example.com") + .thumbnailUrl("https://example.com") + .build() + ) + .addNews( + WebSearchResult.builder() + .description("description") + .addSnippet("string") + .title("title") + .url("https://example.com") + .faviconUrl("https://example.com") + .thumbnailUrl("https://example.com") + .build() + ) + .build() + ) + .build() + ) + .build() + + assertThat(webSearchCreateResponse.data()) + .contains( + WebSearchCreateResponse.Data.builder() + .results( + WebSearchCreateResponse.Data.Results.builder() + .addWeb( + WebSearchResult.builder() + .description("description") + .addSnippet("string") + .title("title") + .url("https://example.com") + .faviconUrl("https://example.com") + .thumbnailUrl("https://example.com") + .build() + ) + .addNews( + WebSearchResult.builder() + .description("description") + .addSnippet("string") + .title("title") + .url("https://example.com") + .faviconUrl("https://example.com") + .thumbnailUrl("https://example.com") + .build() + ) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val webSearchCreateResponse = + WebSearchCreateResponse.builder() + .data( + WebSearchCreateResponse.Data.builder() + .results( + WebSearchCreateResponse.Data.Results.builder() + .addWeb( + WebSearchResult.builder() + .description("description") + .addSnippet("string") + .title("title") + .url("https://example.com") + .faviconUrl("https://example.com") + .thumbnailUrl("https://example.com") + .build() + ) + .addNews( + WebSearchResult.builder() + .description("description") + .addSnippet("string") + .title("title") + .url("https://example.com") + .faviconUrl("https://example.com") + .thumbnailUrl("https://example.com") + .build() + ) + .build() + ) + .build() + ) + .build() + + val roundtrippedWebSearchCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(webSearchCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedWebSearchCreateResponse).isEqualTo(webSearchCreateResponse) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/WebSearchResultTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/WebSearchResultTest.kt new file mode 100644 index 000000000..f4e8c9eac --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/WebSearchResultTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.websearch + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WebSearchResultTest { + + @Test + fun create() { + val webSearchResult = + WebSearchResult.builder() + .description("description") + .addSnippet("string") + .title("title") + .url("https://example.com") + .faviconUrl("https://example.com") + .thumbnailUrl("https://example.com") + .build() + + assertThat(webSearchResult.description()).isEqualTo("description") + assertThat(webSearchResult.snippets()).containsExactly("string") + assertThat(webSearchResult.title()).isEqualTo("title") + assertThat(webSearchResult.url()).isEqualTo("https://example.com") + assertThat(webSearchResult.faviconUrl()).contains("https://example.com") + assertThat(webSearchResult.thumbnailUrl()).contains("https://example.com") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val webSearchResult = + WebSearchResult.builder() + .description("description") + .addSnippet("string") + .title("title") + .url("https://example.com") + .faviconUrl("https://example.com") + .thumbnailUrl("https://example.com") + .build() + + val roundtrippedWebSearchResult = + jsonMapper.readValue( + jsonMapper.writeValueAsString(webSearchResult), + jacksonTypeRef(), + ) + + assertThat(roundtrippedWebSearchResult).isEqualTo(webSearchResult) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/research/ResearchCitationTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/research/ResearchCitationTest.kt new file mode 100644 index 000000000..e834e6fab --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/research/ResearchCitationTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.websearch.research + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ResearchCitationTest { + + @Test + fun create() { + val researchCitation = + ResearchCitation.builder() + .title("title") + .url("https://example.com") + .snippet("snippet") + .build() + + assertThat(researchCitation.title()).isEqualTo("title") + assertThat(researchCitation.url()).isEqualTo("https://example.com") + assertThat(researchCitation.snippet()).contains("snippet") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val researchCitation = + ResearchCitation.builder() + .title("title") + .url("https://example.com") + .snippet("snippet") + .build() + + val roundtrippedResearchCitation = + jsonMapper.readValue( + jsonMapper.writeValueAsString(researchCitation), + jacksonTypeRef(), + ) + + assertThat(roundtrippedResearchCitation).isEqualTo(researchCitation) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/research/ResearchCreateParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/research/ResearchCreateParamsTest.kt new file mode 100644 index 000000000..c6c45f45b --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/research/ResearchCreateParamsTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.websearch.research + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ResearchCreateParamsTest { + + @Test + fun create() { + ResearchCreateParams.builder() + .query("Compare the performance of RAG vs fine-tuning for domain-specific QA") + .background(false) + .maxSources(20L) + .researchEffort(ResearchCreateParams.ResearchEffort.STANDARD) + .build() + } + + @Test + fun body() { + val params = + ResearchCreateParams.builder() + .query("Compare the performance of RAG vs fine-tuning for domain-specific QA") + .background(false) + .maxSources(20L) + .researchEffort(ResearchCreateParams.ResearchEffort.STANDARD) + .build() + + val body = params._body() + + assertThat(body.query()) + .isEqualTo("Compare the performance of RAG vs fine-tuning for domain-specific QA") + assertThat(body.background()).contains(false) + assertThat(body.maxSources()).contains(20L) + assertThat(body.researchEffort()).contains(ResearchCreateParams.ResearchEffort.STANDARD) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ResearchCreateParams.builder() + .query("Compare the performance of RAG vs fine-tuning for domain-specific QA") + .build() + + val body = params._body() + + assertThat(body.query()) + .isEqualTo("Compare the performance of RAG vs fine-tuning for domain-specific QA") + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/research/ResearchCreateResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/research/ResearchCreateResponseTest.kt new file mode 100644 index 000000000..b9c52527c --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/research/ResearchCreateResponseTest.kt @@ -0,0 +1,74 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.websearch.research + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ResearchCreateResponseTest { + + @Test + fun create() { + val researchCreateResponse = + ResearchCreateResponse.builder() + .data( + ResearchCreateResponse.Data.ResearchResponseSync.builder() + .answer("RAG and fine-tuning serve different purposes...") + .addCitation( + ResearchCitation.builder() + .title("title") + .url("https://example.com") + .snippet("snippet") + .build() + ) + .build() + ) + .build() + + assertThat(researchCreateResponse.data()) + .contains( + ResearchCreateResponse.Data.ofResearchResponseSync( + ResearchCreateResponse.Data.ResearchResponseSync.builder() + .answer("RAG and fine-tuning serve different purposes...") + .addCitation( + ResearchCitation.builder() + .title("title") + .url("https://example.com") + .snippet("snippet") + .build() + ) + .build() + ) + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val researchCreateResponse = + ResearchCreateResponse.builder() + .data( + ResearchCreateResponse.Data.ResearchResponseSync.builder() + .answer("RAG and fine-tuning serve different purposes...") + .addCitation( + ResearchCitation.builder() + .title("title") + .url("https://example.com") + .snippet("snippet") + .build() + ) + .build() + ) + .build() + + val roundtrippedResearchCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(researchCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedResearchCreateResponse).isEqualTo(researchCreateResponse) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/research/ResearchRetrieveParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/research/ResearchRetrieveParamsTest.kt new file mode 100644 index 000000000..5035715b8 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/research/ResearchRetrieveParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.websearch.research + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ResearchRetrieveParamsTest { + + @Test + fun create() { + ResearchRetrieveParams.builder().taskId("bf3026a5-dd57-44dd-b922-200041be3a4b").build() + } + + @Test + fun pathParams() { + val params = + ResearchRetrieveParams.builder().taskId("bf3026a5-dd57-44dd-b922-200041be3a4b").build() + + assertThat(params._pathParam(0)).isEqualTo("bf3026a5-dd57-44dd-b922-200041be3a4b") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/research/ResearchRetrieveResponseTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/research/ResearchRetrieveResponseTest.kt new file mode 100644 index 000000000..37728b637 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/models/websearch/research/ResearchRetrieveResponseTest.kt @@ -0,0 +1,81 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.models.websearch.research + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.telnyx.sdk.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ResearchRetrieveResponseTest { + + @Test + fun create() { + val researchRetrieveResponse = + ResearchRetrieveResponse.builder() + .data( + ResearchRetrieveResponse.Data.builder() + .status(ResearchRetrieveResponse.Data.Status.PENDING) + .taskId("task_id") + .answer("answer") + .addCitation( + ResearchCitation.builder() + .title("title") + .url("https://example.com") + .snippet("snippet") + .build() + ) + .error("error") + .build() + ) + .build() + + assertThat(researchRetrieveResponse.data()) + .contains( + ResearchRetrieveResponse.Data.builder() + .status(ResearchRetrieveResponse.Data.Status.PENDING) + .taskId("task_id") + .answer("answer") + .addCitation( + ResearchCitation.builder() + .title("title") + .url("https://example.com") + .snippet("snippet") + .build() + ) + .error("error") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val researchRetrieveResponse = + ResearchRetrieveResponse.builder() + .data( + ResearchRetrieveResponse.Data.builder() + .status(ResearchRetrieveResponse.Data.Status.PENDING) + .taskId("task_id") + .answer("answer") + .addCitation( + ResearchCitation.builder() + .title("title") + .url("https://example.com") + .snippet("snippet") + .build() + ) + .error("error") + .build() + ) + .build() + + val roundtrippedResearchRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(researchRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedResearchRetrieveResponse).isEqualTo(researchRetrieveResponse) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/ServiceParamsTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/ServiceParamsTest.kt index 88ecf4d35..be8dd7559 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/ServiceParamsTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/ServiceParamsTest.kt @@ -429,11 +429,11 @@ internal class ServiceParamsTest { CallDialParams.WebhookUrls.builder() .putAdditionalProperty( "call.hangup", - JsonValue.from("https://www.example.com/webhooks/hangup"), + JsonValue.from(listOf("https://www.example.com/webhooks/hangup")), ) .putAdditionalProperty( "call.bridge", - JsonValue.from("https://www.example.com/webhooks/bridge"), + JsonValue.from(listOf("https://www.example.com/webhooks/bridge")), ) .build() ) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/CallServiceAsyncTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/CallServiceAsyncTest.kt index 0febce1d9..95674e3ae 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/CallServiceAsyncTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/CallServiceAsyncTest.kt @@ -383,11 +383,11 @@ internal class CallServiceAsyncTest { CallDialParams.WebhookUrls.builder() .putAdditionalProperty( "call.hangup", - JsonValue.from("https://www.example.com/webhooks/hangup"), + JsonValue.from(listOf("https://www.example.com/webhooks/hangup")), ) .putAdditionalProperty( "call.bridge", - JsonValue.from("https://www.example.com/webhooks/bridge"), + JsonValue.from(listOf("https://www.example.com/webhooks/bridge")), ) .build() ) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/WebSearchServiceAsyncTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/WebSearchServiceAsyncTest.kt new file mode 100644 index 000000000..66b9f30dd --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/WebSearchServiceAsyncTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async + +import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClientAsync +import com.telnyx.sdk.models.websearch.WebSearchContentsParams +import com.telnyx.sdk.models.websearch.WebSearchCreateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class WebSearchServiceAsyncTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val webSearchServiceAsync = client.webSearch() + + val webSearchFuture = + webSearchServiceAsync.create( + WebSearchCreateParams.builder() + .query("latest AI agent frameworks") + .count(10L) + .country("US") + .addExcludeDomain("pinterest.com") + .freshness("week") + .addIncludeDomain("arxiv.org") + .addIncludeDomain("github.com") + .livecrawl(false) + .safesearch(WebSearchCreateParams.Safesearch.MODERATE) + .build() + ) + + val webSearch = webSearchFuture.get() + webSearch.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun contents() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val webSearchServiceAsync = client.webSearch() + + val responseFuture = + webSearchServiceAsync.contents( + WebSearchContentsParams.builder() + .addUrl("https://en.wikipedia.org/wiki/Artificial_intelligence") + .crawlTimeout(10L) + .addFormat(WebSearchContentsParams.Format.MARKDOWN) + .addFormat(WebSearchContentsParams.Format.METADATA) + .maxAge(null) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/calls/ActionServiceAsyncTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/calls/ActionServiceAsyncTest.kt index f236773c2..ef008f7da 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/calls/ActionServiceAsyncTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/calls/ActionServiceAsyncTest.kt @@ -387,11 +387,11 @@ internal class ActionServiceAsyncTest { ActionAnswerParams.WebhookUrls.builder() .putAdditionalProperty( "call.hangup", - JsonValue.from("https://www.example.com/webhooks/hangup"), + JsonValue.from(listOf("https://www.example.com/webhooks/hangup")), ) .putAdditionalProperty( "call.bridge", - JsonValue.from("https://www.example.com/webhooks/bridge"), + JsonValue.from(listOf("https://www.example.com/webhooks/bridge")), ) .build() ) @@ -1785,11 +1785,11 @@ internal class ActionServiceAsyncTest { ActionTransferParams.WebhookUrls.builder() .putAdditionalProperty( "call.answered", - JsonValue.from("https://www.example.com/webhooks/answered"), + JsonValue.from(listOf("https://www.example.com/webhooks/answered")), ) .putAdditionalProperty( "call.hangup", - JsonValue.from("https://www.example.com/webhooks/hangup"), + JsonValue.from(listOf("https://www.example.com/webhooks/hangup")), ) .build() ) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/phonenumbers/VoicemailServiceAsyncTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/phonenumbers/VoicemailServiceAsyncTest.kt index 697627233..5c182c2d3 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/phonenumbers/VoicemailServiceAsyncTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/phonenumbers/VoicemailServiceAsyncTest.kt @@ -21,7 +21,18 @@ internal class VoicemailServiceAsyncTest { voicemailServiceAsync.create( VoicemailCreateParams.builder() .phoneNumberId("123455678900") - .voicemailRequest(VoicemailRequest.builder().enabled(true).pin("1234").build()) + .voicemailRequest( + VoicemailRequest.builder() + .enabled(true) + .greeting( + VoicemailRequest.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailRequest.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() + ) .build() ) @@ -51,7 +62,18 @@ internal class VoicemailServiceAsyncTest { voicemailServiceAsync.update( VoicemailUpdateParams.builder() .phoneNumberId("123455678900") - .voicemailRequest(VoicemailRequest.builder().enabled(true).pin("1234").build()) + .voicemailRequest( + VoicemailRequest.builder() + .enabled(true) + .greeting( + VoicemailRequest.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailRequest.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() + ) .build() ) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/simcards/ActionServiceAsyncTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/simcards/ActionServiceAsyncTest.kt index 4775a15f2..2ac0df12b 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/simcards/ActionServiceAsyncTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/simcards/ActionServiceAsyncTest.kt @@ -6,6 +6,7 @@ import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClientAsync import com.telnyx.sdk.models.simcards.actions.ActionBulkDisableVoiceParams import com.telnyx.sdk.models.simcards.actions.ActionBulkEnableVoiceParams import com.telnyx.sdk.models.simcards.actions.ActionBulkSetPublicIpsParams +import com.telnyx.sdk.models.simcards.actions.ActionEnableVoiceParams import com.telnyx.sdk.models.simcards.actions.ActionSetPublicIpParams import com.telnyx.sdk.models.simcards.actions.ActionValidateRegistrationCodesParams import org.junit.jupiter.api.Disabled @@ -64,6 +65,7 @@ internal class ActionServiceAsyncTest { actionServiceAsync.bulkEnableVoice( ActionBulkEnableVoiceParams.builder() .simCardGroupId("6b14e151-8493-4fa1-8664-1cc4e6d14158") + .connectionId("123456789") .build() ) @@ -100,6 +102,18 @@ internal class ActionServiceAsyncTest { response.validate() } + @Disabled("Mock server tests are disabled") + @Test + fun disableVoice() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val actionServiceAsync = client.simCards().actions() + + val responseFuture = actionServiceAsync.disableVoice("6a09cdc3-8948-47f0-aa62-74ac943d6c58") + + val response = responseFuture.get() + response.validate() + } + @Disabled("Mock server tests are disabled") @Test fun enable() { @@ -112,6 +126,24 @@ internal class ActionServiceAsyncTest { response.validate() } + @Disabled("Mock server tests are disabled") + @Test + fun enableVoice() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val actionServiceAsync = client.simCards().actions() + + val responseFuture = + actionServiceAsync.enableVoice( + ActionEnableVoiceParams.builder() + .id("6a09cdc3-8948-47f0-aa62-74ac943d6c58") + .connectionId("123456789") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + @Disabled("Mock server tests are disabled") @Test fun removePublicIp() { diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/storage/SqldbServiceAsyncTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/storage/SqldbServiceAsyncTest.kt new file mode 100644 index 000000000..422ebeb06 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/storage/SqldbServiceAsyncTest.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async.storage + +import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClientAsync +import com.telnyx.sdk.models.storage.sqldbs.SqldbCreateParams +import com.telnyx.sdk.models.storage.sqldbs.SqldbDeleteParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class SqldbServiceAsyncTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val sqldbServiceAsync = client.storage().sqldbs() + + val sqlDatabaseResponseWrapperFuture = + sqldbServiceAsync.create(SqldbCreateParams.builder().name("my-database").build()) + + val sqlDatabaseResponseWrapper = sqlDatabaseResponseWrapperFuture.get() + sqlDatabaseResponseWrapper.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun retrieve() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val sqldbServiceAsync = client.storage().sqldbs() + + val sqlDatabaseResponseWrapperFuture = + sqldbServiceAsync.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val sqlDatabaseResponseWrapper = sqlDatabaseResponseWrapperFuture.get() + sqlDatabaseResponseWrapper.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val sqldbServiceAsync = client.storage().sqldbs() + + val pageFuture = sqldbServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun delete() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val sqldbServiceAsync = client.storage().sqldbs() + + val future = + sqldbServiceAsync.delete( + SqldbDeleteParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .force(true) + .build() + ) + + val response = future.get() + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/storage/sqldbs/ActionServiceAsyncTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/storage/sqldbs/ActionServiceAsyncTest.kt new file mode 100644 index 000000000..f25a052af --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/storage/sqldbs/ActionServiceAsyncTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async.storage.sqldbs + +import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClientAsync +import com.telnyx.sdk.models.storage.sqldbs.actions.ActionQueryParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class ActionServiceAsyncTest { + + @Disabled("Mock server tests are disabled") + @Test + fun query() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val actionServiceAsync = client.storage().sqldbs().actions() + + val responseFuture = + actionServiceAsync.query( + ActionQueryParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sql("SELECT * FROM users WHERE name = ?") + .addParam("alice") + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/websearch/ResearchServiceAsyncTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/websearch/ResearchServiceAsyncTest.kt new file mode 100644 index 000000000..5f81791ef --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/async/websearch/ResearchServiceAsyncTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.async.websearch + +import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClientAsync +import com.telnyx.sdk.models.websearch.research.ResearchCreateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class ResearchServiceAsyncTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val researchServiceAsync = client.webSearch().research() + + val researchFuture = + researchServiceAsync.create( + ResearchCreateParams.builder() + .query("Compare the performance of RAG vs fine-tuning for domain-specific QA") + .background(false) + .maxSources(20L) + .researchEffort(ResearchCreateParams.ResearchEffort.STANDARD) + .build() + ) + + val research = researchFuture.get() + research.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun retrieve() { + val client = TelnyxOkHttpClientAsync.builder().apiKey("My API Key").build() + val researchServiceAsync = client.webSearch().research() + + val researchFuture = researchServiceAsync.retrieve("bf3026a5-dd57-44dd-b922-200041be3a4b") + + val research = researchFuture.get() + research.validate() + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/CallServiceTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/CallServiceTest.kt index eb18fcec8..e55311112 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/CallServiceTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/CallServiceTest.kt @@ -383,11 +383,11 @@ internal class CallServiceTest { CallDialParams.WebhookUrls.builder() .putAdditionalProperty( "call.hangup", - JsonValue.from("https://www.example.com/webhooks/hangup"), + JsonValue.from(listOf("https://www.example.com/webhooks/hangup")), ) .putAdditionalProperty( "call.bridge", - JsonValue.from("https://www.example.com/webhooks/bridge"), + JsonValue.from(listOf("https://www.example.com/webhooks/bridge")), ) .build() ) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/WebSearchServiceTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/WebSearchServiceTest.kt new file mode 100644 index 000000000..fd0c316b9 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/WebSearchServiceTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking + +import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient +import com.telnyx.sdk.models.websearch.WebSearchContentsParams +import com.telnyx.sdk.models.websearch.WebSearchCreateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class WebSearchServiceTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val webSearchService = client.webSearch() + + val webSearch = + webSearchService.create( + WebSearchCreateParams.builder() + .query("latest AI agent frameworks") + .count(10L) + .country("US") + .addExcludeDomain("pinterest.com") + .freshness("week") + .addIncludeDomain("arxiv.org") + .addIncludeDomain("github.com") + .livecrawl(false) + .safesearch(WebSearchCreateParams.Safesearch.MODERATE) + .build() + ) + + webSearch.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun contents() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val webSearchService = client.webSearch() + + val response = + webSearchService.contents( + WebSearchContentsParams.builder() + .addUrl("https://en.wikipedia.org/wiki/Artificial_intelligence") + .crawlTimeout(10L) + .addFormat(WebSearchContentsParams.Format.MARKDOWN) + .addFormat(WebSearchContentsParams.Format.METADATA) + .maxAge(null) + .build() + ) + + response.validate() + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/calls/ActionServiceTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/calls/ActionServiceTest.kt index c2a06b240..3d70fc937 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/calls/ActionServiceTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/calls/ActionServiceTest.kt @@ -386,11 +386,11 @@ internal class ActionServiceTest { ActionAnswerParams.WebhookUrls.builder() .putAdditionalProperty( "call.hangup", - JsonValue.from("https://www.example.com/webhooks/hangup"), + JsonValue.from(listOf("https://www.example.com/webhooks/hangup")), ) .putAdditionalProperty( "call.bridge", - JsonValue.from("https://www.example.com/webhooks/bridge"), + JsonValue.from(listOf("https://www.example.com/webhooks/bridge")), ) .build() ) @@ -1746,11 +1746,11 @@ internal class ActionServiceTest { ActionTransferParams.WebhookUrls.builder() .putAdditionalProperty( "call.answered", - JsonValue.from("https://www.example.com/webhooks/answered"), + JsonValue.from(listOf("https://www.example.com/webhooks/answered")), ) .putAdditionalProperty( "call.hangup", - JsonValue.from("https://www.example.com/webhooks/hangup"), + JsonValue.from(listOf("https://www.example.com/webhooks/hangup")), ) .build() ) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/phonenumbers/VoicemailServiceTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/phonenumbers/VoicemailServiceTest.kt index 1b44d5207..4f53e7b41 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/phonenumbers/VoicemailServiceTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/phonenumbers/VoicemailServiceTest.kt @@ -21,7 +21,18 @@ internal class VoicemailServiceTest { voicemailService.create( VoicemailCreateParams.builder() .phoneNumberId("123455678900") - .voicemailRequest(VoicemailRequest.builder().enabled(true).pin("1234").build()) + .voicemailRequest( + VoicemailRequest.builder() + .enabled(true) + .greeting( + VoicemailRequest.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailRequest.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() + ) .build() ) @@ -49,7 +60,18 @@ internal class VoicemailServiceTest { voicemailService.update( VoicemailUpdateParams.builder() .phoneNumberId("123455678900") - .voicemailRequest(VoicemailRequest.builder().enabled(true).pin("1234").build()) + .voicemailRequest( + VoicemailRequest.builder() + .enabled(true) + .greeting( + VoicemailRequest.Greeting.builder() + .mediaName("my_voicemail_greeting") + .mode(VoicemailRequest.Greeting.Mode.CUSTOM_GREETING) + .build() + ) + .pin("1234") + .build() + ) .build() ) diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/simcards/ActionServiceTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/simcards/ActionServiceTest.kt index 9e5d27a7f..188685938 100644 --- a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/simcards/ActionServiceTest.kt +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/simcards/ActionServiceTest.kt @@ -6,6 +6,7 @@ import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient import com.telnyx.sdk.models.simcards.actions.ActionBulkDisableVoiceParams import com.telnyx.sdk.models.simcards.actions.ActionBulkEnableVoiceParams import com.telnyx.sdk.models.simcards.actions.ActionBulkSetPublicIpsParams +import com.telnyx.sdk.models.simcards.actions.ActionEnableVoiceParams import com.telnyx.sdk.models.simcards.actions.ActionSetPublicIpParams import com.telnyx.sdk.models.simcards.actions.ActionValidateRegistrationCodesParams import org.junit.jupiter.api.Disabled @@ -61,6 +62,7 @@ internal class ActionServiceTest { actionService.bulkEnableVoice( ActionBulkEnableVoiceParams.builder() .simCardGroupId("6b14e151-8493-4fa1-8664-1cc4e6d14158") + .connectionId("123456789") .build() ) @@ -94,6 +96,17 @@ internal class ActionServiceTest { response.validate() } + @Disabled("Mock server tests are disabled") + @Test + fun disableVoice() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val actionService = client.simCards().actions() + + val response = actionService.disableVoice("6a09cdc3-8948-47f0-aa62-74ac943d6c58") + + response.validate() + } + @Disabled("Mock server tests are disabled") @Test fun enable() { @@ -105,6 +118,23 @@ internal class ActionServiceTest { response.validate() } + @Disabled("Mock server tests are disabled") + @Test + fun enableVoice() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val actionService = client.simCards().actions() + + val response = + actionService.enableVoice( + ActionEnableVoiceParams.builder() + .id("6a09cdc3-8948-47f0-aa62-74ac943d6c58") + .connectionId("123456789") + .build() + ) + + response.validate() + } + @Disabled("Mock server tests are disabled") @Test fun removePublicIp() { diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/storage/SqldbServiceTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/storage/SqldbServiceTest.kt new file mode 100644 index 000000000..794480abd --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/storage/SqldbServiceTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking.storage + +import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient +import com.telnyx.sdk.models.storage.sqldbs.SqldbCreateParams +import com.telnyx.sdk.models.storage.sqldbs.SqldbDeleteParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class SqldbServiceTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val sqldbService = client.storage().sqldbs() + + val sqlDatabaseResponseWrapper = + sqldbService.create(SqldbCreateParams.builder().name("my-database").build()) + + sqlDatabaseResponseWrapper.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun retrieve() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val sqldbService = client.storage().sqldbs() + + val sqlDatabaseResponseWrapper = + sqldbService.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + sqlDatabaseResponseWrapper.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val sqldbService = client.storage().sqldbs() + + val page = sqldbService.list() + + page.response().validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun delete() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val sqldbService = client.storage().sqldbs() + + sqldbService.delete( + SqldbDeleteParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .force(true) + .build() + ) + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/storage/sqldbs/ActionServiceTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/storage/sqldbs/ActionServiceTest.kt new file mode 100644 index 000000000..150c0ae1e --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/storage/sqldbs/ActionServiceTest.kt @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking.storage.sqldbs + +import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient +import com.telnyx.sdk.models.storage.sqldbs.actions.ActionQueryParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class ActionServiceTest { + + @Disabled("Mock server tests are disabled") + @Test + fun query() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val actionService = client.storage().sqldbs().actions() + + val response = + actionService.query( + ActionQueryParams.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sql("SELECT * FROM users WHERE name = ?") + .addParam("alice") + .build() + ) + + response.validate() + } +} diff --git a/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/websearch/ResearchServiceTest.kt b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/websearch/ResearchServiceTest.kt new file mode 100644 index 000000000..cfe4c5589 --- /dev/null +++ b/telnyx-core/src/test/kotlin/com/telnyx/sdk/services/blocking/websearch/ResearchServiceTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.telnyx.sdk.services.blocking.websearch + +import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient +import com.telnyx.sdk.models.websearch.research.ResearchCreateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class ResearchServiceTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val researchService = client.webSearch().research() + + val research = + researchService.create( + ResearchCreateParams.builder() + .query("Compare the performance of RAG vs fine-tuning for domain-specific QA") + .background(false) + .maxSources(20L) + .researchEffort(ResearchCreateParams.ResearchEffort.STANDARD) + .build() + ) + + research.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun retrieve() { + val client = TelnyxOkHttpClient.builder().apiKey("My API Key").build() + val researchService = client.webSearch().research() + + val research = researchService.retrieve("bf3026a5-dd57-44dd-b922-200041be3a4b") + + research.validate() + } +} diff --git a/telnyx-proguard-test/src/test/kotlin/com/telnyx/sdk/proguard/ProGuardCompatibilityTest.kt b/telnyx-proguard-test/src/test/kotlin/com/telnyx/sdk/proguard/ProGuardCompatibilityTest.kt index a2c09e1db..034646d3e 100644 --- a/telnyx-proguard-test/src/test/kotlin/com/telnyx/sdk/proguard/ProGuardCompatibilityTest.kt +++ b/telnyx-proguard-test/src/test/kotlin/com/telnyx/sdk/proguard/ProGuardCompatibilityTest.kt @@ -235,6 +235,7 @@ internal class ProGuardCompatibilityTest { assertThat(client.emailUnsubscribeGroups()).isNotNull() assertThat(client.emailValidations()).isNotNull() assertThat(client.pricing()).isNotNull() + assertThat(client.webSearch()).isNotNull() } @Test