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

fix!: Updates expiration paramater in presign functions to TimeInterval type. #805

Merged
merged 5 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import software.amazon.smithy.model.shapes.OperationShape
import software.amazon.smithy.model.shapes.ServiceShape
import software.amazon.smithy.swift.codegen.ClientRuntimeTypes.Http.SdkHttpRequest
import software.amazon.smithy.swift.codegen.ClientRuntimeTypes.Middleware.NoopHandler
import software.amazon.smithy.swift.codegen.FoundationTypes
import software.amazon.smithy.swift.codegen.SwiftDelegator
import software.amazon.smithy.swift.codegen.SwiftTypes
import software.amazon.smithy.swift.codegen.SwiftWriter
import software.amazon.smithy.swift.codegen.core.CodegenContext
import software.amazon.smithy.swift.codegen.core.toProtocolGenerationContext
Expand Down Expand Up @@ -68,11 +68,12 @@ class PresignerGenerator : SwiftIntegration {

writer.addImport(AWSClientConfiguration)
writer.addImport(SdkHttpRequest)
writer.addIndividualTypeImport("typealias", "Foundation", "TimeInterval")

val httpBindingResolver = protocolGenerator.getProtocolHttpBindingResolver(protocolGeneratorContext, protocolGenerator.defaultContentType)

writer.openBlock("extension $inputType {", "}") {
writer.openBlock("public func presign(config: \$N, expiration: \$N) async throws -> \$T {", "}", serviceConfig.typeProtocol, SwiftTypes.Int64, SdkHttpRequest) {
writer.openBlock("public func presign(config: \$N, expiration: \$N) async throws -> \$T {", "}", serviceConfig.typeProtocol, FoundationTypes.TimeInterval, SdkHttpRequest) {
writer.write("let serviceName = \"${ctx.settings.sdkId}\"")
writer.write("let input = self")
val operationStackName = "operation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import software.amazon.smithy.model.knowledge.OperationIndex
import software.amazon.smithy.model.shapes.OperationShape
import software.amazon.smithy.model.shapes.ServiceShape
import software.amazon.smithy.swift.codegen.ClientRuntimeTypes
import software.amazon.smithy.swift.codegen.FoundationTypes
import software.amazon.smithy.swift.codegen.MiddlewareGenerator
import software.amazon.smithy.swift.codegen.SwiftDelegator
import software.amazon.smithy.swift.codegen.SwiftDependency
import software.amazon.smithy.swift.codegen.SwiftSettings
import software.amazon.smithy.swift.codegen.SwiftTypes
import software.amazon.smithy.swift.codegen.SwiftWriter
import software.amazon.smithy.swift.codegen.core.CodegenContext
import software.amazon.smithy.swift.codegen.core.toProtocolGenerationContext
Expand Down Expand Up @@ -88,14 +88,15 @@ class PresignableUrlIntegration(private val presignedOperations: Map<String, Set

writer.addImport(AWSClientRuntimeTypes.Core.AWSClientConfiguration)
writer.addImport(ClientRuntimeTypes.Http.SdkHttpRequest)
writer.addIndividualTypeImport("typealias", "Foundation", "TimeInterval")

val httpBindingResolver = protocolGenerator.getProtocolHttpBindingResolver(protocolGeneratorContext, protocolGenerator.defaultContentType)

writer.openBlock("extension $inputType {", "}") {
writer.openBlock(
"public func presignURL(config: \$N, expiration: \$N) async throws -> \$T {", "}",
serviceConfig.typeProtocol,
SwiftTypes.Int64,
FoundationTypes.TimeInterval,
ClientRuntimeTypes.Core.URL
) {
writer.write("let serviceName = \"${ctx.settings.sdkId}\"")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ class PresignerGeneratorTests {
"""
import AWSClientRuntime
import ClientRuntime
import typealias Foundation.TimeInterval

extension GetFooInput {
public func presign(config: ExampleClientConfigurationProtocol, expiration: Swift.Int64) async throws -> ClientRuntime.SdkHttpRequest? {
public func presign(config: ExampleClientConfigurationProtocol, expiration: Foundation.TimeInterval) async throws -> ClientRuntime.SdkHttpRequest? {
let serviceName = "example"
let input = self
let encoder = ClientRuntime.JSONEncoder()
Expand Down Expand Up @@ -73,9 +74,10 @@ class PresignerGeneratorTests {
"""
import AWSClientRuntime
import ClientRuntime
import typealias Foundation.TimeInterval

extension PostFooInput {
public func presign(config: ExampleClientConfigurationProtocol, expiration: Swift.Int64) async throws -> ClientRuntime.SdkHttpRequest? {
public func presign(config: ExampleClientConfigurationProtocol, expiration: Foundation.TimeInterval) async throws -> ClientRuntime.SdkHttpRequest? {
let serviceName = "example"
let input = self
let encoder = ClientRuntime.JSONEncoder()
Expand Down Expand Up @@ -131,9 +133,10 @@ class PresignerGeneratorTests {
"""
import AWSClientRuntime
import ClientRuntime
import typealias Foundation.TimeInterval

extension PutFooInput {
public func presign(config: ExampleClientConfigurationProtocol, expiration: Swift.Int64) async throws -> ClientRuntime.SdkHttpRequest? {
public func presign(config: ExampleClientConfigurationProtocol, expiration: Foundation.TimeInterval) async throws -> ClientRuntime.SdkHttpRequest? {
let serviceName = "example"
let input = self
let encoder = ClientRuntime.JSONEncoder()
Expand Down Expand Up @@ -191,9 +194,10 @@ class PresignerGeneratorTests {

import AWSClientRuntime
import ClientRuntime
import typealias Foundation.TimeInterval

extension PutObjectInput {
public func presign(config: S3ClientConfigurationProtocol, expiration: Swift.Int64) async throws -> ClientRuntime.SdkHttpRequest? {
public func presign(config: S3ClientConfigurationProtocol, expiration: Foundation.TimeInterval) async throws -> ClientRuntime.SdkHttpRequest? {
let serviceName = "S3"
let input = self
let encoder = ClientRuntime.JSONEncoder()
Expand Down