private async Task ImportBotAsync(JToken importJson, CancellationToken cancellationToken) { using (var stream = new MemoryStream()) { // Generate zip archive with imports JSON await WriteJsonZipAsync(stream, importJson, cancellationToken).ConfigureAwait(false); // Call StartImport action on Amazon Lex var startImportRequest = new StartImportRequest { MergeStrategy = MergeStrategy.OVERWRITE_LATEST, Payload = stream, ResourceType = ResourceType.BOT, }; Logger.LogTrace($"Importing bot '{this.LexBotName}'."); var startImportResponse = await this.LexClient.StartImportAsync(startImportRequest, cancellationToken).ConfigureAwait(false); // If the import is not complete, poll until import is complete if (startImportResponse.ImportStatus != ImportStatus.COMPLETE) { await this.PollBotImportStatusAsync(startImportResponse.ImportId, cancellationToken).ConfigureAwait(false); } } }
public async Task <StartImportResponse> StartImportAsync(StartImportRequest request, CancellationToken cancellationToken) { var streamCopy = new MemoryStream(); request.Payload.CopyTo(streamCopy); streamCopy.Position = 0; var requestCopy = new StartImportRequest { MergeStrategy = request.MergeStrategy, Payload = streamCopy, ResourceType = request.ResourceType, }; await this.ProcessRequestAsync(requestCopy).ConfigureAwait(false); return(this.Get <StartImportResponse>()); }
public Task <StartImportResponse> StartImportAsync(StartImportRequest request, CancellationToken cancellationToken) { return(RetryAsync(this.AmazonLexModelClient.StartImportAsync, request, cancellationToken)); }