/******************************************************************************* * Copyright 2012-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"). You may not use * this file except in compliance with the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * ***************************************************************************** * * AWS Tools for Windows (TM) PowerShell (TM) * */ using System; using System.Collections.Generic; using System.Linq; using System.Management.Automation; using System.Text; using Amazon.PowerShell.Common; using Amazon.Runtime; using Amazon.TranscribeService; using Amazon.TranscribeService.Model; namespace Amazon.PowerShell.Cmdlets.TRS { /// /// Creates a new custom medical vocabulary. /// /// /// /// Before creating a new custom medical vocabulary, you must first upload a text file /// that contains your vocabulary table into an Amazon S3 bucket. Note that this differs /// from , where you can include a list of terms within your request using the Phrases /// flag; CreateMedicalVocabulary does not support the Phrases /// flag and only accepts vocabularies in table format. /// /// Each language has a character set that contains all allowed characters for that specific /// language. If you use unsupported characters, your custom vocabulary request fails. /// Refer to Character /// Sets for Custom Vocabularies to get the character set for your language. /// /// For more information, see Custom /// vocabularies. /// /// [Cmdlet("New", "TRSMedicalVocabulary", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)] [OutputType("Amazon.TranscribeService.Model.CreateMedicalVocabularyResponse")] [AWSCmdlet("Calls the Amazon Transcribe Service CreateMedicalVocabulary API operation.", Operation = new[] {"CreateMedicalVocabulary"}, SelectReturnType = typeof(Amazon.TranscribeService.Model.CreateMedicalVocabularyResponse))] [AWSCmdletOutput("Amazon.TranscribeService.Model.CreateMedicalVocabularyResponse", "This cmdlet returns an Amazon.TranscribeService.Model.CreateMedicalVocabularyResponse object containing multiple properties. The object can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack." )] public partial class NewTRSMedicalVocabularyCmdlet : AmazonTranscribeServiceClientCmdlet, IExecutor { #region Parameter LanguageCode /// /// /// The language code that represents the language of the entries in your custom vocabulary. /// US English (en-US) is the only language supported with Amazon Transcribe /// Medical. /// /// #if !MODULAR [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] #else [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)] [System.Management.Automation.AllowNull] #endif [Amazon.PowerShell.Common.AWSRequiredParameter] [AWSConstantClassSource("Amazon.TranscribeService.LanguageCode")] public Amazon.TranscribeService.LanguageCode LanguageCode { get; set; } #endregion #region Parameter Tag /// /// /// Adds one or more custom tags, each in the form of a key:value pair, to a new custom /// medical vocabulary at the time you create this new custom vocabulary.To learn more about using tags with Amazon Transcribe, refer to Tagging /// resources. /// /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] [Alias("Tags")] public Amazon.TranscribeService.Model.Tag[] Tag { get; set; } #endregion #region Parameter VocabularyFileUri /// /// /// The Amazon S3 location (URI) of the text file that contains your custom medical vocabulary. /// The URI must be in the same Amazon Web Services Region as the resource you're calling.Here's an example URI path: s3://DOC-EXAMPLE-BUCKET/my-vocab-file.txt /// /// #if !MODULAR [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] #else [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)] [System.Management.Automation.AllowEmptyString] [System.Management.Automation.AllowNull] #endif [Amazon.PowerShell.Common.AWSRequiredParameter] public System.String VocabularyFileUri { get; set; } #endregion #region Parameter VocabularyName /// /// /// A unique name, chosen by you, for your new custom medical vocabulary.This name is case sensitive, cannot contain spaces, and must be unique within an Amazon /// Web Services account. If you try to create a new custom medical vocabulary with the /// same name as an existing custom medical vocabulary, you get a ConflictException /// error. /// /// #if !MODULAR [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] #else [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)] [System.Management.Automation.AllowEmptyString] [System.Management.Automation.AllowNull] #endif [Amazon.PowerShell.Common.AWSRequiredParameter] public System.String VocabularyName { get; set; } #endregion #region Parameter Select /// /// Use the -Select parameter to control the cmdlet output. The default value is '*'. /// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.TranscribeService.Model.CreateMedicalVocabularyResponse). /// Specifying the name of a property of type Amazon.TranscribeService.Model.CreateMedicalVocabularyResponse will result in that property being returned. /// Specifying -Select '^ParameterName' will result in the cmdlet returning the selected cmdlet parameter value. /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public string Select { get; set; } = "*"; #endregion #region Parameter Force /// /// This parameter overrides confirmation prompts to force /// the cmdlet to continue its operation. This parameter should always /// be used with caution. /// [System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)] public SwitchParameter Force { get; set; } #endregion protected override void ProcessRecord() { this._AWSSignerType = "v4"; base.ProcessRecord(); var resourceIdentifiersText = FormatParameterValuesForConfirmationMsg(nameof(this.VocabularyName), MyInvocation.BoundParameters); if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "New-TRSMedicalVocabulary (CreateMedicalVocabulary)")) { return; } var context = new CmdletContext(); // allow for manipulation of parameters prior to loading into context PreExecutionContextLoad(context); if (ParameterWasBound(nameof(this.Select))) { context.Select = CreateSelectDelegate(Select) ?? throw new System.ArgumentException("Invalid value for -Select parameter.", nameof(this.Select)); } context.LanguageCode = this.LanguageCode; #if MODULAR if (this.LanguageCode == null && ParameterWasBound(nameof(this.LanguageCode))) { WriteWarning("You are passing $null as a value for parameter LanguageCode which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues."); } #endif if (this.Tag != null) { context.Tag = new List(this.Tag); } context.VocabularyFileUri = this.VocabularyFileUri; #if MODULAR if (this.VocabularyFileUri == null && ParameterWasBound(nameof(this.VocabularyFileUri))) { WriteWarning("You are passing $null as a value for parameter VocabularyFileUri which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues."); } #endif context.VocabularyName = this.VocabularyName; #if MODULAR if (this.VocabularyName == null && ParameterWasBound(nameof(this.VocabularyName))) { WriteWarning("You are passing $null as a value for parameter VocabularyName which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues."); } #endif // allow further manipulation of loaded context prior to processing PostExecutionContextLoad(context); var output = Execute(context) as CmdletOutput; ProcessOutput(output); } #region IExecutor Members public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.TranscribeService.Model.CreateMedicalVocabularyRequest(); if (cmdletContext.LanguageCode != null) { request.LanguageCode = cmdletContext.LanguageCode; } if (cmdletContext.Tag != null) { request.Tags = cmdletContext.Tag; } if (cmdletContext.VocabularyFileUri != null) { request.VocabularyFileUri = cmdletContext.VocabularyFileUri; } if (cmdletContext.VocabularyName != null) { request.VocabularyName = cmdletContext.VocabularyName; } CmdletOutput output; // issue call var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint); try { var response = CallAWSServiceOperation(client, request); object pipelineOutput = null; pipelineOutput = cmdletContext.Select(response, this); output = new CmdletOutput { PipelineOutput = pipelineOutput, ServiceResponse = response }; } catch (Exception e) { output = new CmdletOutput { ErrorResponse = e }; } return output; } public ExecutorContext CreateContext() { return new CmdletContext(); } #endregion #region AWS Service Operation Call private Amazon.TranscribeService.Model.CreateMedicalVocabularyResponse CallAWSServiceOperation(IAmazonTranscribeService client, Amazon.TranscribeService.Model.CreateMedicalVocabularyRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Transcribe Service", "CreateMedicalVocabulary"); try { #if DESKTOP return client.CreateMedicalVocabulary(request); #elif CORECLR return client.CreateMedicalVocabularyAsync(request).GetAwaiter().GetResult(); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } } #endregion internal partial class CmdletContext : ExecutorContext { public Amazon.TranscribeService.LanguageCode LanguageCode { get; set; } public List Tag { get; set; } public System.String VocabularyFileUri { get; set; } public System.String VocabularyName { get; set; } public System.Func Select { get; set; } = (response, cmdlet) => response; } } }