Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose presign / presignURL methods in Models.swift to service client object #1198

Merged
merged 11 commits into from
Nov 6, 2023
43 changes: 43 additions & 0 deletions Sources/Services/AWSPolly/PollyClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
@_spi(FileBasedConfig) import AWSClientRuntime
import ClientRuntime
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
import Logging

public class PollyClient {
Expand Down Expand Up @@ -481,3 +484,43 @@ extension PollyClient: PollyClientProtocol {
}

}

extension PollyClient {
/// Presigns the URL for SynthesizeSpeech operation with the given input object SynthesizeSpeechInput.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc comment should include the same docs that are rendered onto the regular operation.

Copy link
Contributor Author

@sichanyoo sichanyoo Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what you mean by this - do you mean the links to AWS docs (the ones in Smithy model under documentation trait)? If so, they aren't available for these presign operations because these are added at SDK level.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline - will add docs as mentioned.

/// The presigned URL will be valid for the given expiration, in seconds.
///
/// Below is the documentation for SynthesizeSpeech operation:
/// Synthesizes UTF-8 input, plain text or SSML, to a stream of bytes. SSML input must be valid, well-formed SSML. Some alphabets might not be available with all the voices (for example, Cyrillic might not be read at all by English voices) unless phoneme mapping is used. For more information, see [How it Works](https://docs.aws.amazon.com/polly/latest/dg/how-text-to-speech-works.html).
///
/// - Parameter input: The input object for SynthesizeSpeech operation used to construct request.
/// - Parameter expiration: The duration (in seconds) the presigned request will be valid for.
///
/// - Returns: `Foundation.URL`: The presigned URL for SynthesizeSpeech operation.
public func presignedURLForSynthesizeSpeech(input: SynthesizeSpeechInput, expiration: Foundation.TimeInterval) async throws -> Foundation.URL {
let presignedURL = try await input.presignURL(config: config, expiration: expiration)
guard let presignedURL else {
jbelkins marked this conversation as resolved.
Show resolved Hide resolved
throw ClientError.unknownError("Could not generate presigned URL for the operation SynthesizeSpeech.")
}
return presignedURL
}
}

extension PollyClient {
/// Presigns the request for SynthesizeSpeech operation with the given input object SynthesizeSpeechInput.
/// The presigned request will be valid for the given expiration, in seconds.
///
/// Below is the documentation for SynthesizeSpeech operation:
/// Synthesizes UTF-8 input, plain text or SSML, to a stream of bytes. SSML input must be valid, well-formed SSML. Some alphabets might not be available with all the voices (for example, Cyrillic might not be read at all by English voices) unless phoneme mapping is used. For more information, see [How it Works](https://docs.aws.amazon.com/polly/latest/dg/how-text-to-speech-works.html).
///
/// - Parameter input: The input object for SynthesizeSpeech operation used to construct request.
/// - Parameter expiration: The duration (in seconds) the presigned request will be valid for.
///
/// - Returns: `URLRequest`: The presigned request for SynthesizeSpeech operation.
public func presignedRequestForSynthesizeSpeech(input: SynthesizeSpeechInput, expiration: Foundation.TimeInterval) async throws -> URLRequest {
let presignedRequest = try await input.presign(config: config, expiration: expiration)
guard let presignedRequest else {
throw ClientError.unknownError("Could not presign the request for the operation SynthesizeSpeech.")
}
return try await URLRequest(sdkRequest: presignedRequest)
}
}
Loading
Loading