Skip to content

Commit

Permalink
Update CloudWatch client to send payload in POST body instead of URL (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
knovichikhin authored Jan 25, 2024
1 parent f887209 commit a73e420
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Sources/CloudWatchClient/AWSCloudWatchClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public enum CloudWatchClientError: Swift.Error {

public func isRetriable() -> Bool? {
switch self {
case .limitExceededException, .limitExceededFault:
case .limitExceededException, .limitExceededFault, .throttling:
return true
default:
return nil
Expand Down Expand Up @@ -86,7 +86,7 @@ public struct AWSCloudWatchClient<InvocationReportingType: HTTPClientCoreInvocat
endpointPort: Int = 443,
requiresTLS: Bool? = nil,
service: String = "monitoring",
contentType: String = "application/octet-stream",
contentType: String = "application/x-www-form-urlencoded; charset=utf-8",
apiVersion: String = "2010-08-01",
connectionTimeoutSeconds: Int64 = 10,
retryConfiguration: HTTPClientRetryConfiguration = .default,
Expand All @@ -95,7 +95,7 @@ public struct AWSCloudWatchClient<InvocationReportingType: HTTPClientCoreInvocat
reportingConfiguration: SmokeAWSClientReportingConfiguration<CloudWatchModelOperations>
= SmokeAWSClientReportingConfiguration<CloudWatchModelOperations>() ) {
let useTLS = requiresTLS ?? AWSHTTPClientDelegate.requiresTLS(forEndpointPort: endpointPort)
let clientDelegate = XMLAWSHttpClientDelegate<CloudWatchError>(requiresTLS: useTLS,
let clientDelegate = FormEncodedXMLAWSHttpClientDelegate<CloudWatchError>(requiresTLS: useTLS,
outputListDecodingStrategy: .collapseListUsingItemTag("member"),
inputQueryListEncodingStrategy: .expandListWithIndexAndItemTag(itemTag: "member"))

Expand Down
4 changes: 2 additions & 2 deletions Sources/CloudWatchClient/AWSCloudWatchClientGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public struct AWSCloudWatchClientGenerator {
endpointPort: Int = 443,
requiresTLS: Bool? = nil,
service: String = "monitoring",
contentType: String = "application/octet-stream",
contentType: String = "application/x-www-form-urlencoded; charset=utf-8",
apiVersion: String = "2010-08-01",
connectionTimeoutSeconds: Int64 = 10,
retryConfiguration: HTTPClientRetryConfiguration = .default,
Expand All @@ -69,7 +69,7 @@ public struct AWSCloudWatchClientGenerator {
reportingConfiguration: SmokeAWSClientReportingConfiguration<CloudWatchModelOperations>
= SmokeAWSClientReportingConfiguration<CloudWatchModelOperations>() ) {
let useTLS = requiresTLS ?? AWSHTTPClientDelegate.requiresTLS(forEndpointPort: endpointPort)
let clientDelegate = XMLAWSHttpClientDelegate<CloudWatchError>(requiresTLS: useTLS,
let clientDelegate = FormEncodedXMLAWSHttpClientDelegate<CloudWatchError>(requiresTLS: useTLS,
outputListDecodingStrategy: .collapseListUsingItemTag("member"),
inputQueryListEncodingStrategy: .expandListWithIndexAndItemTag(itemTag: "member"))

Expand Down
15 changes: 15 additions & 0 deletions Sources/CloudWatchModel/CloudWatchModelErrors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,19 @@ private let limitExceededFaultIdentity = "LimitExceeded"
private let missingRequiredParameterIdentity = "MissingParameter"
private let resourceNotFoundIdentity = "ResourceNotFound"
private let resourceNotFoundExceptionIdentity = "ResourceNotFoundException"
private let throttlingIdentity = "ThrottlingException"
private let __accessDeniedIdentity = "AccessDenied"

public struct CloudWatchErrorPayload: Codable {
public let type: String
public let message: String

enum CodingKeys: String, CodingKey {
case type = "Code"
case message = "Message"
}
}

public enum CloudWatchError: Swift.Error, Decodable {
case concurrentModification(ConcurrentModificationException)
case dashboardInvalidInput(DashboardInvalidInputError)
Expand All @@ -62,6 +73,7 @@ public enum CloudWatchError: Swift.Error, Decodable {
case missingRequiredParameter(MissingRequiredParameterException)
case resourceNotFound(ResourceNotFound)
case resourceNotFoundException(ResourceNotFoundException)
case throttling(CloudWatchErrorPayload)
case accessDenied(message: String?)
case validationError(reason: String)
case unrecognizedError(String, String?)
Expand Down Expand Up @@ -120,6 +132,9 @@ public enum CloudWatchError: Swift.Error, Decodable {
case resourceNotFoundExceptionIdentity:
let errorPayload = try ResourceNotFoundException(from: decoder)
self = CloudWatchError.resourceNotFoundException(errorPayload)
case throttlingIdentity:
let errorPayload = try CloudWatchErrorPayload(from: decoder)
self = CloudWatchError.throttling(errorPayload)
case __accessDeniedIdentity:
self = .accessDenied(message: errorMessage)
default:
Expand Down

0 comments on commit a73e420

Please sign in to comment.