diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6b7b150 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License 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. diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..e15a47d --- /dev/null +++ b/Package.swift @@ -0,0 +1,16 @@ +// swift-tools-version:4.0 + +import PackageDescription + +let package = Package( + name: "SwiftAWSKinesis", + products: [ + .library(name: "SwiftAWSKinesis", targets: ["SwiftAWSKinesis"]), + ], + dependencies: [ + .package(url: "https://github.com/noppoMan/aws-sdk-swift-core.git", .upToNextMajor(from: "1.0.0")) + ], + targets: [ + .target(name: "SwiftAWSKinesis", dependencies: ["AWSSDKSwiftCore"]), + ] +) diff --git a/README.md b/README.md new file mode 100644 index 0000000..d39774d --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# kinesis + +An AWS kinesis type safe client for Swift (This is part of [aws-sdk-swift](https://github.com/noppoMan/aws-sdk-swift)) + +## Documentation + +Visit the aws-sdk-swift [documentation](http://htmlpreview.github.io/?https://github.com/noppoMan/aws-sdk-swift/gh-pages/index.html) for instructions and browsing api references. + +## Installation + +### Package.swift + +```swift +import PackageDescription + +let package = Package( + name: "MyAWSApp", + dependencies: [ + .package(url: "https://github.com/swift-aws/kinesis.git", .upToNextMajor(from: "1.0.0")) + ] +) +``` diff --git a/Sources/SwiftAWSKinesis/Kinesis_API.swift b/Sources/SwiftAWSKinesis/Kinesis_API.swift new file mode 100644 index 0000000..2ad9a82 --- /dev/null +++ b/Sources/SwiftAWSKinesis/Kinesis_API.swift @@ -0,0 +1,124 @@ +// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/noppoMan/aws-sdk-swift/blob/master/Sources/CodeGenerator/main.swift. DO NOT EDIT. + +import Foundation +import AWSSDKSwiftCore + +/** +Amazon Kinesis Streams Service API Reference Amazon Kinesis Streams is a managed service that scales elastically for real time processing of streaming big data. +*/ +public struct Kinesis { + + let client: AWSClient + + public init(accessKeyId: String? = nil, secretAccessKey: String? = nil, region: AWSSDKSwiftCore.Region? = nil, endpoint: String? = nil) { + self.client = AWSClient( + accessKeyId: accessKeyId, + secretAccessKey: secretAccessKey, + region: region, + amzTarget: "Kinesis_20131202", + service: "kinesis", + serviceProtocol: ServiceProtocol(type: .json, version: ServiceProtocol.Version(major: 1, minor: 1)), + apiVersion: "2013-12-02", + endpoint: endpoint, + middlewares: [], + possibleErrorTypes: [KinesisError.self] + ) + } + + /// Gets an Amazon Kinesis shard iterator. A shard iterator expires five minutes after it is returned to the requester. A shard iterator specifies the shard position from which to start reading data records sequentially. The position is specified using the sequence number of a data record in a shard. A sequence number is the identifier associated with every record ingested in the stream, and is assigned when a record is put into the stream. Each stream has one or more shards. You must specify the shard iterator type. For example, you can set the ShardIteratorType parameter to read exactly from the position denoted by a specific sequence number by using the AT_SEQUENCE_NUMBER shard iterator type, or right after the sequence number by using the AFTER_SEQUENCE_NUMBER shard iterator type, using sequence numbers returned by earlier calls to PutRecord, PutRecords, GetRecords, or DescribeStream. In the request, you can specify the shard iterator type AT_TIMESTAMP to read records from an arbitrary point in time, TRIM_HORIZON to cause ShardIterator to point to the last untrimmed record in the shard in the system (the oldest data record in the shard), or LATEST so that you always read the most recent data in the shard. When you read repeatedly from a stream, use a GetShardIterator request to get the first shard iterator for use in your first GetRecords request and for subsequent reads use the shard iterator returned by the GetRecords request in NextShardIterator. A new shard iterator is returned by every GetRecords request in NextShardIterator, which you use in the ShardIterator parameter of the next GetRecords request. If a GetShardIterator request is made too often, you receive a ProvisionedThroughputExceededException. For more information about throughput limits, see GetRecords, and Streams Limits in the Amazon Kinesis Streams Developer Guide. If the shard is closed, GetShardIterator returns a valid iterator for the last sequence number of the shard. Note that a shard can be closed as a result of using SplitShard or MergeShards. GetShardIterator has a limit of 5 transactions per second per account per open shard. + public func getShardIterator(_ input: GetShardIteratorInput) throws -> GetShardIteratorOutput { + return try client.send(operation: "GetShardIterator", path: "/", httpMethod: "POST", input: input) + } + + /// Describes the specified Amazon Kinesis stream. The information returned includes the stream name, Amazon Resource Name (ARN), creation time, enhanced metric configuration, and shard map. The shard map is an array of shard objects. For each shard object, there is the hash key and sequence number ranges that the shard spans, and the IDs of any earlier shards that played in a role in creating the shard. Every record ingested in the stream is identified by a sequence number, which is assigned when the record is put into the stream. You can limit the number of shards returned by each call. For more information, see Retrieving Shards from a Stream in the Amazon Kinesis Streams Developer Guide. There are no guarantees about the chronological order shards returned. To process shards in chronological order, use the ID of the parent shard to track the lineage to the oldest shard. This operation has a limit of 10 transactions per second per account. + public func describeStream(_ input: DescribeStreamInput) throws -> DescribeStreamOutput { + return try client.send(operation: "DescribeStream", path: "/", httpMethod: "POST", input: input) + } + + /// Decreases the Amazon Kinesis stream's retention period, which is the length of time data records are accessible after they are added to the stream. The minimum value of a stream's retention period is 24 hours. This operation may result in lost data. For example, if the stream's retention period is 48 hours and is decreased to 24 hours, any data already in the stream that is older than 24 hours is inaccessible. + public func decreaseStreamRetentionPeriod(_ input: DecreaseStreamRetentionPeriodInput) throws { + _ = try client.send(operation: "DecreaseStreamRetentionPeriod", path: "/", httpMethod: "POST", input: input) + } + + /// Increases the Amazon Kinesis stream's retention period, which is the length of time data records are accessible after they are added to the stream. The maximum value of a stream's retention period is 168 hours (7 days). Upon choosing a longer stream retention period, this operation will increase the time period records are accessible that have not yet expired. However, it will not make previous data that has expired (older than the stream's previous retention period) accessible after the operation has been called. For example, if a stream's retention period is set to 24 hours and is increased to 168 hours, any data that is older than 24 hours will remain inaccessible to consumer applications. + public func increaseStreamRetentionPeriod(_ input: IncreaseStreamRetentionPeriodInput) throws { + _ = try client.send(operation: "IncreaseStreamRetentionPeriod", path: "/", httpMethod: "POST", input: input) + } + + /// Merges two adjacent shards in an Amazon Kinesis stream and combines them into a single shard to reduce the stream's capacity to ingest and transport data. Two shards are considered adjacent if the union of the hash key ranges for the two shards form a contiguous set with no gaps. For example, if you have two shards, one with a hash key range of 276...381 and the other with a hash key range of 382...454, then you could merge these two shards into a single shard that would have a hash key range of 276...454. After the merge, the single child shard receives data for all hash key values covered by the two parent shards. MergeShards is called when there is a need to reduce the overall capacity of a stream because of excess capacity that is not being used. You must specify the shard to be merged and the adjacent shard for a stream. For more information about merging shards, see Merge Two Shards in the Amazon Kinesis Streams Developer Guide. If the stream is in the ACTIVE state, you can call MergeShards. If a stream is in the CREATING, UPDATING, or DELETING state, MergeShards returns a ResourceInUseException. If the specified stream does not exist, MergeShards returns a ResourceNotFoundException. You can use DescribeStream to check the state of the stream, which is returned in StreamStatus. MergeShards is an asynchronous operation. Upon receiving a MergeShards request, Amazon Kinesis immediately returns a response and sets the StreamStatus to UPDATING. After the operation is completed, Amazon Kinesis sets the StreamStatus to ACTIVE. Read and write operations continue to work while the stream is in the UPDATING state. You use DescribeStream to determine the shard IDs that are specified in the MergeShards request. If you try to operate on too many streams in parallel using CreateStream, DeleteStream, MergeShards or SplitShard, you will receive a LimitExceededException. MergeShards has limit of 5 transactions per second per account. + public func mergeShards(_ input: MergeShardsInput) throws { + _ = try client.send(operation: "MergeShards", path: "/", httpMethod: "POST", input: input) + } + + /// Writes a single data record into an Amazon Kinesis stream. Call PutRecord to send data into the stream for real-time ingestion and subsequent processing, one record at a time. Each shard can support writes up to 1,000 records per second, up to a maximum data write total of 1 MB per second. You must specify the name of the stream that captures, stores, and transports the data; a partition key; and the data blob itself. The data blob can be any type of data; for example, a segment from a log file, geographic/location data, website clickstream data, and so on. The partition key is used by Amazon Kinesis to distribute data across shards. Amazon Kinesis segregates the data records that belong to a stream into multiple shards, using the partition key associated with each data record to determine which shard a given data record belongs to. Partition keys are Unicode strings, with a maximum length limit of 256 characters for each key. An MD5 hash function is used to map partition keys to 128-bit integer values and to map associated data records to shards using the hash key ranges of the shards. You can override hashing the partition key to determine the shard by explicitly specifying a hash value using the ExplicitHashKey parameter. For more information, see Adding Data to a Stream in the Amazon Kinesis Streams Developer Guide. PutRecord returns the shard ID of where the data record was placed and the sequence number that was assigned to the data record. Sequence numbers increase over time and are specific to a shard within a stream, not across all shards within a stream. To guarantee strictly increasing ordering, write serially to a shard and use the SequenceNumberForOrdering parameter. For more information, see Adding Data to a Stream in the Amazon Kinesis Streams Developer Guide. If a PutRecord request cannot be processed because of insufficient provisioned throughput on the shard involved in the request, PutRecord throws ProvisionedThroughputExceededException. Data records are accessible for only 24 hours from the time that they are added to a stream. + public func putRecord(_ input: PutRecordInput) throws -> PutRecordOutput { + return try client.send(operation: "PutRecord", path: "/", httpMethod: "POST", input: input) + } + + /// Lists your Amazon Kinesis streams. The number of streams may be too large to return from a single call to ListStreams. You can limit the number of returned streams using the Limit parameter. If you do not specify a value for the Limit parameter, Amazon Kinesis uses the default limit, which is currently 10. You can detect if there are more streams available to list by using the HasMoreStreams flag from the returned output. If there are more streams available, you can request more streams by using the name of the last stream returned by the ListStreams request in the ExclusiveStartStreamName parameter in a subsequent request to ListStreams. The group of stream names returned by the subsequent request is then added to the list. You can continue this process until all the stream names have been collected in the list. ListStreams has a limit of 5 transactions per second per account. + public func listStreams(_ input: ListStreamsInput) throws -> ListStreamsOutput { + return try client.send(operation: "ListStreams", path: "/", httpMethod: "POST", input: input) + } + + /// Creates an Amazon Kinesis stream. A stream captures and transports data records that are continuously emitted from different data sources or producers. Scale-out within a stream is explicitly supported by means of shards, which are uniquely identified groups of data records in a stream. You specify and control the number of shards that a stream is composed of. Each shard can support reads up to 5 transactions per second, up to a maximum data read total of 2 MB per second. Each shard can support writes up to 1,000 records per second, up to a maximum data write total of 1 MB per second. You can add shards to a stream if the amount of data input increases and you can remove shards if the amount of data input decreases. The stream name identifies the stream. The name is scoped to the AWS account used by the application. It is also scoped by region. That is, two streams in two different accounts can have the same name, and two streams in the same account, but in two different regions, can have the same name. CreateStream is an asynchronous operation. Upon receiving a CreateStream request, Amazon Kinesis immediately returns and sets the stream status to CREATING. After the stream is created, Amazon Kinesis sets the stream status to ACTIVE. You should perform read and write operations only on an ACTIVE stream. You receive a LimitExceededException when making a CreateStream request if you try to do one of the following: Have more than five streams in the CREATING state at any point in time. Create more shards than are authorized for your account. For the default shard limit for an AWS account, see Streams Limits in the Amazon Kinesis Streams Developer Guide. If you need to increase this limit, contact AWS Support. You can use DescribeStream to check the stream status, which is returned in StreamStatus. CreateStream has a limit of 5 transactions per second per account. + public func createStream(_ input: CreateStreamInput) throws { + _ = try client.send(operation: "CreateStream", path: "/", httpMethod: "POST", input: input) + } + + /// Removes tags from the specified Amazon Kinesis stream. Removed tags are deleted and cannot be recovered after this operation successfully completes. If you specify a tag that does not exist, it is ignored. + public func removeTagsFromStream(_ input: RemoveTagsFromStreamInput) throws { + _ = try client.send(operation: "RemoveTagsFromStream", path: "/", httpMethod: "POST", input: input) + } + + /// Gets data records from an Amazon Kinesis stream's shard. Specify a shard iterator using the ShardIterator parameter. The shard iterator specifies the position in the shard from which you want to start reading data records sequentially. If there are no records available in the portion of the shard that the iterator points to, GetRecords returns an empty list. Note that it might take multiple calls to get to a portion of the shard that contains records. You can scale by provisioning multiple shards per stream while considering service limits (for more information, see Streams Limits in the Amazon Kinesis Streams Developer Guide). Your application should have one thread per shard, each reading continuously from its stream. To read from a stream continually, call GetRecords in a loop. Use GetShardIterator to get the shard iterator to specify in the first GetRecords call. GetRecords returns a new shard iterator in NextShardIterator. Specify the shard iterator returned in NextShardIterator in subsequent calls to GetRecords. Note that if the shard has been closed, the shard iterator can't return more data and GetRecords returns null in NextShardIterator. You can terminate the loop when the shard is closed, or when the shard iterator reaches the record with the sequence number or other attribute that marks it as the last record to process. Each data record can be up to 1 MB in size, and each shard can read up to 2 MB per second. You can ensure that your calls don't exceed the maximum supported size or throughput by using the Limit parameter to specify the maximum number of records that GetRecords can return. Consider your average record size when determining this limit. The size of the data returned by GetRecords varies depending on the utilization of the shard. The maximum size of data that GetRecords can return is 10 MB. If a call returns this amount of data, subsequent calls made within the next 5 seconds throw ProvisionedThroughputExceededException. If there is insufficient provisioned throughput on the shard, subsequent calls made within the next 1 second throw ProvisionedThroughputExceededException. Note that GetRecords won't return any data when it throws an exception. For this reason, we recommend that you wait one second between calls to GetRecords; however, it's possible that the application will get exceptions for longer than 1 second. To detect whether the application is falling behind in processing, you can use the MillisBehindLatest response attribute. You can also monitor the stream using CloudWatch metrics and other mechanisms (see Monitoring in the Amazon Kinesis Streams Developer Guide). Each Amazon Kinesis record includes a value, ApproximateArrivalTimestamp, that is set when a stream successfully receives and stores a record. This is commonly referred to as a server-side timestamp, whereas a client-side timestamp is set when a data producer creates or sends the record to a stream (a data producer is any data source putting data records into a stream, for example with PutRecords). The timestamp has millisecond precision. There are no guarantees about the timestamp accuracy, or that the timestamp is always increasing. For example, records in a shard or across a stream might have timestamps that are out of order. + public func getRecords(_ input: GetRecordsInput) throws -> GetRecordsOutput { + return try client.send(operation: "GetRecords", path: "/", httpMethod: "POST", input: input) + } + + /// Splits a shard into two new shards in the Amazon Kinesis stream to increase the stream's capacity to ingest and transport data. SplitShard is called when there is a need to increase the overall capacity of a stream because of an expected increase in the volume of data records being ingested. You can also use SplitShard when a shard appears to be approaching its maximum utilization; for example, the producers sending data into the specific shard are suddenly sending more than previously anticipated. You can also call SplitShard to increase stream capacity, so that more Amazon Kinesis applications can simultaneously read data from the stream for real-time processing. You must specify the shard to be split and the new hash key, which is the position in the shard where the shard gets split in two. In many cases, the new hash key might simply be the average of the beginning and ending hash key, but it can be any hash key value in the range being mapped into the shard. For more information about splitting shards, see Split a Shard in the Amazon Kinesis Streams Developer Guide. You can use DescribeStream to determine the shard ID and hash key values for the ShardToSplit and NewStartingHashKey parameters that are specified in the SplitShard request. SplitShard is an asynchronous operation. Upon receiving a SplitShard request, Amazon Kinesis immediately returns a response and sets the stream status to UPDATING. After the operation is completed, Amazon Kinesis sets the stream status to ACTIVE. Read and write operations continue to work while the stream is in the UPDATING state. You can use DescribeStream to check the status of the stream, which is returned in StreamStatus. If the stream is in the ACTIVE state, you can call SplitShard. If a stream is in CREATING or UPDATING or DELETING states, DescribeStream returns a ResourceInUseException. If the specified stream does not exist, DescribeStream returns a ResourceNotFoundException. If you try to create more shards than are authorized for your account, you receive a LimitExceededException. For the default shard limit for an AWS account, see Streams Limits in the Amazon Kinesis Streams Developer Guide. If you need to increase this limit, contact AWS Support. If you try to operate on too many streams simultaneously using CreateStream, DeleteStream, MergeShards, and/or SplitShard, you receive a LimitExceededException. SplitShard has limit of 5 transactions per second per account. + public func splitShard(_ input: SplitShardInput) throws { + _ = try client.send(operation: "SplitShard", path: "/", httpMethod: "POST", input: input) + } + + /// Lists the tags for the specified Amazon Kinesis stream. + public func listTagsForStream(_ input: ListTagsForStreamInput) throws -> ListTagsForStreamOutput { + return try client.send(operation: "ListTagsForStream", path: "/", httpMethod: "POST", input: input) + } + + /// Enables enhanced Amazon Kinesis stream monitoring for shard-level metrics. + public func enableEnhancedMonitoring(_ input: EnableEnhancedMonitoringInput) throws -> EnhancedMonitoringOutput { + return try client.send(operation: "EnableEnhancedMonitoring", path: "/", httpMethod: "POST", input: input) + } + + /// Adds or updates tags for the specified Amazon Kinesis stream. Each stream can have up to 10 tags. If tags have already been assigned to the stream, AddTagsToStream overwrites any existing tags that correspond to the specified tag keys. + public func addTagsToStream(_ input: AddTagsToStreamInput) throws { + _ = try client.send(operation: "AddTagsToStream", path: "/", httpMethod: "POST", input: input) + } + + /// Describes the shard limits and usage for the account. If you update your account limits, the old limits might be returned for a few minutes. This operation has a limit of 1 transaction per second per account. + public func describeLimits(_ input: DescribeLimitsInput) throws -> DescribeLimitsOutput { + return try client.send(operation: "DescribeLimits", path: "/", httpMethod: "POST", input: input) + } + + /// Writes multiple data records into an Amazon Kinesis stream in a single call (also referred to as a PutRecords request). Use this operation to send data into the stream for data ingestion and processing. Each PutRecords request can support up to 500 records. Each record in the request can be as large as 1 MB, up to a limit of 5 MB for the entire request, including partition keys. Each shard can support writes up to 1,000 records per second, up to a maximum data write total of 1 MB per second. You must specify the name of the stream that captures, stores, and transports the data; and an array of request Records, with each record in the array requiring a partition key and data blob. The record size limit applies to the total size of the partition key and data blob. The data blob can be any type of data; for example, a segment from a log file, geographic/location data, website clickstream data, and so on. The partition key is used by Amazon Kinesis as input to a hash function that maps the partition key and associated data to a specific shard. An MD5 hash function is used to map partition keys to 128-bit integer values and to map associated data records to shards. As a result of this hashing mechanism, all data records with the same partition key map to the same shard within the stream. For more information, see Adding Data to a Stream in the Amazon Kinesis Streams Developer Guide. Each record in the Records array may include an optional parameter, ExplicitHashKey, which overrides the partition key to shard mapping. This parameter allows a data producer to determine explicitly the shard where the record is stored. For more information, see Adding Multiple Records with PutRecords in the Amazon Kinesis Streams Developer Guide. The PutRecords response includes an array of response Records. Each record in the response array directly correlates with a record in the request array using natural ordering, from the top to the bottom of the request and response. The response Records array always includes the same number of records as the request array. The response Records array includes both successfully and unsuccessfully processed records. Amazon Kinesis attempts to process all records in each PutRecords request. A single record failure does not stop the processing of subsequent records. A successfully-processed record includes ShardId and SequenceNumber values. The ShardId parameter identifies the shard in the stream where the record is stored. The SequenceNumber parameter is an identifier assigned to the put record, unique to all records in the stream. An unsuccessfully-processed record includes ErrorCode and ErrorMessage values. ErrorCode reflects the type of error and can be one of the following values: ProvisionedThroughputExceededException or InternalFailure. ErrorMessage provides more detailed information about the ProvisionedThroughputExceededException exception including the account ID, stream name, and shard ID of the record that was throttled. For more information about partially successful responses, see Adding Multiple Records with PutRecords in the Amazon Kinesis Streams Developer Guide. By default, data records are accessible for only 24 hours from the time that they are added to an Amazon Kinesis stream. This retention period can be modified using the DecreaseStreamRetentionPeriod and IncreaseStreamRetentionPeriod operations. + public func putRecords(_ input: PutRecordsInput) throws -> PutRecordsOutput { + return try client.send(operation: "PutRecords", path: "/", httpMethod: "POST", input: input) + } + + /// Disables enhanced monitoring. + public func disableEnhancedMonitoring(_ input: DisableEnhancedMonitoringInput) throws -> EnhancedMonitoringOutput { + return try client.send(operation: "DisableEnhancedMonitoring", path: "/", httpMethod: "POST", input: input) + } + + /// Updates the shard count of the specified stream to the specified number of shards. Updating the shard count is an asynchronous operation. Upon receiving the request, Amazon Kinesis returns immediately and sets the status of the stream to UPDATING. After the update is complete, Amazon Kinesis sets the status of the stream back to ACTIVE. Depending on the size of the stream, the scaling action could take a few minutes to complete. You can continue to read and write data to your stream while its status is UPDATING. To update the shard count, Amazon Kinesis performs splits and merges and individual shards. This can cause short-lived shards to be created, in addition to the final shards. We recommend that you double or halve the shard count, as this results in the fewest number of splits or merges. This operation has a rate limit of twice per rolling 24 hour period. You cannot scale above double your current shard count, scale below half your current shard count, or exceed the shard limits for your account. For the default limits for an AWS account, see Streams Limits in the Amazon Kinesis Streams Developer Guide. If you need to increase a limit, contact AWS Support. + public func updateShardCount(_ input: UpdateShardCountInput) throws -> UpdateShardCountOutput { + return try client.send(operation: "UpdateShardCount", path: "/", httpMethod: "POST", input: input) + } + + /// Deletes an Amazon Kinesis stream and all its shards and data. You must shut down any applications that are operating on the stream before you delete the stream. If an application attempts to operate on a deleted stream, it will receive the exception ResourceNotFoundException. If the stream is in the ACTIVE state, you can delete it. After a DeleteStream request, the specified stream is in the DELETING state until Amazon Kinesis completes the deletion. Note: Amazon Kinesis might continue to accept data read and write operations, such as PutRecord, PutRecords, and GetRecords, on a stream in the DELETING state until the stream deletion is complete. When you delete a stream, any shards in that stream are also deleted, and any tags are dissociated from the stream. You can use the DescribeStream operation to check the state of the stream, which is returned in StreamStatus. DeleteStream has a limit of 5 transactions per second per account. + public func deleteStream(_ input: DeleteStreamInput) throws { + _ = try client.send(operation: "DeleteStream", path: "/", httpMethod: "POST", input: input) + } + + +} \ No newline at end of file diff --git a/Sources/SwiftAWSKinesis/Kinesis_Error.swift b/Sources/SwiftAWSKinesis/Kinesis_Error.swift new file mode 100644 index 0000000..424870f --- /dev/null +++ b/Sources/SwiftAWSKinesis/Kinesis_Error.swift @@ -0,0 +1,38 @@ +// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/noppoMan/aws-sdk-swift/blob/master/Sources/CodeGenerator/main.swift. DO NOT EDIT. + +import AWSSDKSwiftCore + +/// Error enum for Kinesis +public enum KinesisError: AWSErrorType { + case resourceNotFoundException(message: String?) + case invalidArgumentException(message: String?) + case provisionedThroughputExceededException(message: String?) + case limitExceededException(message: String?) + case resourceInUseException(message: String?) + case expiredIteratorException(message: String?) +} + +extension KinesisError { + public init?(errorCode: String, message: String?){ + var errorCode = errorCode + if let index = errorCode.index(of: "#") { + errorCode = String(errorCode[errorCode.index(index, offsetBy: 1)...]) + } + switch errorCode { + case "ResourceNotFoundException": + self = .resourceNotFoundException(message: message) + case "InvalidArgumentException": + self = .invalidArgumentException(message: message) + case "ProvisionedThroughputExceededException": + self = .provisionedThroughputExceededException(message: message) + case "LimitExceededException": + self = .limitExceededException(message: message) + case "ResourceInUseException": + self = .resourceInUseException(message: message) + case "ExpiredIteratorException": + self = .expiredIteratorException(message: message) + default: + return nil + } + } +} \ No newline at end of file diff --git a/Sources/SwiftAWSKinesis/Kinesis_Shapes.swift b/Sources/SwiftAWSKinesis/Kinesis_Shapes.swift new file mode 100644 index 0000000..dbbc72d --- /dev/null +++ b/Sources/SwiftAWSKinesis/Kinesis_Shapes.swift @@ -0,0 +1,943 @@ +// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/noppoMan/aws-sdk-swift/blob/master/Sources/CodeGenerator/main.swift. DO NOT EDIT. + +import Foundation +import AWSSDKSwiftCore + +extension Kinesis { + + public struct CreateStreamInput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "StreamName", required: true, type: .string), + AWSShapeMember(label: "ShardCount", required: true, type: .integer) + ] + /// A name to identify the stream. The stream name is scoped to the AWS account used by the application that creates the stream. It is also scoped by region. That is, two streams in two different AWS accounts can have the same name, and two streams in the same AWS account but in two different regions can have the same name. + public let streamName: String + /// The number of shards that the stream will use. The throughput of the stream is a function of the number of shards; more shards are required for greater provisioned throughput. DefaultShardLimit; + public let shardCount: Int32 + + public init(streamName: String, shardCount: Int32) { + self.streamName = streamName + self.shardCount = shardCount + } + + private enum CodingKeys: String, CodingKey { + case streamName = "StreamName" + case shardCount = "ShardCount" + } + } + + public struct AddTagsToStreamInput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "Tags", required: true, type: .map), + AWSShapeMember(label: "StreamName", required: true, type: .string) + ] + /// The set of key-value pairs to use to create the tags. + public let tags: [String: String] + /// The name of the stream. + public let streamName: String + + public init(tags: [String: String], streamName: String) { + self.tags = tags + self.streamName = streamName + } + + private enum CodingKeys: String, CodingKey { + case tags = "Tags" + case streamName = "StreamName" + } + } + + public struct DescribeLimitsInput: AWSShape { + + } + + public enum ShardIteratorType: String, CustomStringConvertible, Codable { + case atSequenceNumber = "AT_SEQUENCE_NUMBER" + case afterSequenceNumber = "AFTER_SEQUENCE_NUMBER" + case trimHorizon = "TRIM_HORIZON" + case latest = "LATEST" + case atTimestamp = "AT_TIMESTAMP" + public var description: String { return self.rawValue } + } + + public struct DescribeStreamInput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "StreamName", required: true, type: .string), + AWSShapeMember(label: "ExclusiveStartShardId", required: false, type: .string), + AWSShapeMember(label: "Limit", required: false, type: .integer) + ] + /// The name of the stream to describe. + public let streamName: String + /// The shard ID of the shard to start with. + public let exclusiveStartShardId: String? + /// The maximum number of shards to return in a single call. The default value is 100. If you specify a value greater than 100, at most 100 shards are returned. + public let limit: Int32? + + public init(streamName: String, exclusiveStartShardId: String? = nil, limit: Int32? = nil) { + self.streamName = streamName + self.exclusiveStartShardId = exclusiveStartShardId + self.limit = limit + } + + private enum CodingKeys: String, CodingKey { + case streamName = "StreamName" + case exclusiveStartShardId = "ExclusiveStartShardId" + case limit = "Limit" + } + } + + public struct UpdateShardCountOutput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "TargetShardCount", required: false, type: .integer), + AWSShapeMember(label: "CurrentShardCount", required: false, type: .integer), + AWSShapeMember(label: "StreamName", required: false, type: .string) + ] + /// The updated number of shards. + public let targetShardCount: Int32? + /// The current number of shards. + public let currentShardCount: Int32? + /// The name of the stream. + public let streamName: String? + + public init(targetShardCount: Int32? = nil, currentShardCount: Int32? = nil, streamName: String? = nil) { + self.targetShardCount = targetShardCount + self.currentShardCount = currentShardCount + self.streamName = streamName + } + + private enum CodingKeys: String, CodingKey { + case targetShardCount = "TargetShardCount" + case currentShardCount = "CurrentShardCount" + case streamName = "StreamName" + } + } + + public struct DecreaseStreamRetentionPeriodInput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "RetentionPeriodHours", required: true, type: .integer), + AWSShapeMember(label: "StreamName", required: true, type: .string) + ] + /// The new retention period of the stream, in hours. Must be less than the current retention period. + public let retentionPeriodHours: Int32 + /// The name of the stream to modify. + public let streamName: String + + public init(retentionPeriodHours: Int32, streamName: String) { + self.retentionPeriodHours = retentionPeriodHours + self.streamName = streamName + } + + private enum CodingKeys: String, CodingKey { + case retentionPeriodHours = "RetentionPeriodHours" + case streamName = "StreamName" + } + } + + public struct IncreaseStreamRetentionPeriodInput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "RetentionPeriodHours", required: true, type: .integer), + AWSShapeMember(label: "StreamName", required: true, type: .string) + ] + /// The new retention period of the stream, in hours. Must be more than the current retention period. + public let retentionPeriodHours: Int32 + /// The name of the stream to modify. + public let streamName: String + + public init(retentionPeriodHours: Int32, streamName: String) { + self.retentionPeriodHours = retentionPeriodHours + self.streamName = streamName + } + + private enum CodingKeys: String, CodingKey { + case retentionPeriodHours = "RetentionPeriodHours" + case streamName = "StreamName" + } + } + + public struct Shard: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "ShardId", required: true, type: .string), + AWSShapeMember(label: "SequenceNumberRange", required: true, type: .structure), + AWSShapeMember(label: "AdjacentParentShardId", required: false, type: .string), + AWSShapeMember(label: "HashKeyRange", required: true, type: .structure), + AWSShapeMember(label: "ParentShardId", required: false, type: .string) + ] + /// The unique identifier of the shard within the stream. + public let shardId: String + /// The range of possible sequence numbers for the shard. + public let sequenceNumberRange: SequenceNumberRange + /// The shard ID of the shard adjacent to the shard's parent. + public let adjacentParentShardId: String? + /// The range of possible hash key values for the shard, which is a set of ordered contiguous positive integers. + public let hashKeyRange: HashKeyRange + /// The shard ID of the shard's parent. + public let parentShardId: String? + + public init(shardId: String, sequenceNumberRange: SequenceNumberRange, adjacentParentShardId: String? = nil, hashKeyRange: HashKeyRange, parentShardId: String? = nil) { + self.shardId = shardId + self.sequenceNumberRange = sequenceNumberRange + self.adjacentParentShardId = adjacentParentShardId + self.hashKeyRange = hashKeyRange + self.parentShardId = parentShardId + } + + private enum CodingKeys: String, CodingKey { + case shardId = "ShardId" + case sequenceNumberRange = "SequenceNumberRange" + case adjacentParentShardId = "AdjacentParentShardId" + case hashKeyRange = "HashKeyRange" + case parentShardId = "ParentShardId" + } + } + + public struct PutRecordsOutput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "FailedRecordCount", required: false, type: .integer), + AWSShapeMember(label: "Records", required: true, type: .list) + ] + /// The number of unsuccessfully processed records in a PutRecords request. + public let failedRecordCount: Int32? + /// An array of successfully and unsuccessfully processed record results, correlated with the request by natural ordering. A record that is successfully added to a stream includes SequenceNumber and ShardId in the result. A record that fails to be added to a stream includes ErrorCode and ErrorMessage in the result. + public let records: [PutRecordsResultEntry] + + public init(failedRecordCount: Int32? = nil, records: [PutRecordsResultEntry]) { + self.failedRecordCount = failedRecordCount + self.records = records + } + + private enum CodingKeys: String, CodingKey { + case failedRecordCount = "FailedRecordCount" + case records = "Records" + } + } + + public struct DescribeStreamOutput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "StreamDescription", required: true, type: .structure) + ] + /// The current status of the stream, the stream ARN, an array of shard objects that comprise the stream, and whether there are more shards available. + public let streamDescription: StreamDescription + + public init(streamDescription: StreamDescription) { + self.streamDescription = streamDescription + } + + private enum CodingKeys: String, CodingKey { + case streamDescription = "StreamDescription" + } + } + + public struct EnhancedMonitoringOutput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "DesiredShardLevelMetrics", required: false, type: .list), + AWSShapeMember(label: "StreamName", required: false, type: .string), + AWSShapeMember(label: "CurrentShardLevelMetrics", required: false, type: .list) + ] + /// Represents the list of all the metrics that would be in the enhanced state after the operation. + public let desiredShardLevelMetrics: [MetricsName]? + /// The name of the Amazon Kinesis stream. + public let streamName: String? + /// Represents the current state of the metrics that are in the enhanced state before the operation. + public let currentShardLevelMetrics: [MetricsName]? + + public init(desiredShardLevelMetrics: [MetricsName]? = nil, streamName: String? = nil, currentShardLevelMetrics: [MetricsName]? = nil) { + self.desiredShardLevelMetrics = desiredShardLevelMetrics + self.streamName = streamName + self.currentShardLevelMetrics = currentShardLevelMetrics + } + + private enum CodingKeys: String, CodingKey { + case desiredShardLevelMetrics = "DesiredShardLevelMetrics" + case streamName = "StreamName" + case currentShardLevelMetrics = "CurrentShardLevelMetrics" + } + } + + public struct PutRecordOutput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "SequenceNumber", required: true, type: .string), + AWSShapeMember(label: "ShardId", required: true, type: .string) + ] + /// The sequence number identifier that was assigned to the put data record. The sequence number for the record is unique across all records in the stream. A sequence number is the identifier associated with every record put into the stream. + public let sequenceNumber: String + /// The shard ID of the shard where the data record was placed. + public let shardId: String + + public init(sequenceNumber: String, shardId: String) { + self.sequenceNumber = sequenceNumber + self.shardId = shardId + } + + private enum CodingKeys: String, CodingKey { + case sequenceNumber = "SequenceNumber" + case shardId = "ShardId" + } + } + + public struct Record: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "ApproximateArrivalTimestamp", required: false, type: .timestamp), + AWSShapeMember(label: "SequenceNumber", required: true, type: .string), + AWSShapeMember(label: "PartitionKey", required: true, type: .string), + AWSShapeMember(label: "Data", required: true, type: .blob) + ] + /// The approximate time that the record was inserted into the stream. + public let approximateArrivalTimestamp: TimeStamp? + /// The unique identifier of the record in the stream. + public let sequenceNumber: String + /// Identifies which shard in the stream the data record is assigned to. + public let partitionKey: String + /// The data blob. The data in the blob is both opaque and immutable to the Amazon Kinesis service, which does not inspect, interpret, or change the data in the blob in any way. When the data blob (the payload before base64-encoding) is added to the partition key size, the total size must not exceed the maximum record size (1 MB). + public let data: Data + + public init(approximateArrivalTimestamp: TimeStamp? = nil, sequenceNumber: String, partitionKey: String, data: Data) { + self.approximateArrivalTimestamp = approximateArrivalTimestamp + self.sequenceNumber = sequenceNumber + self.partitionKey = partitionKey + self.data = data + } + + private enum CodingKeys: String, CodingKey { + case approximateArrivalTimestamp = "ApproximateArrivalTimestamp" + case sequenceNumber = "SequenceNumber" + case partitionKey = "PartitionKey" + case data = "Data" + } + } + + public enum MetricsName: String, CustomStringConvertible, Codable { + case incomingbytes = "IncomingBytes" + case incomingrecords = "IncomingRecords" + case outgoingbytes = "OutgoingBytes" + case outgoingrecords = "OutgoingRecords" + case writeprovisionedthroughputexceeded = "WriteProvisionedThroughputExceeded" + case readprovisionedthroughputexceeded = "ReadProvisionedThroughputExceeded" + case iteratoragemilliseconds = "IteratorAgeMilliseconds" + case all = "ALL" + public var description: String { return self.rawValue } + } + + public struct DisableEnhancedMonitoringInput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "ShardLevelMetrics", required: true, type: .list), + AWSShapeMember(label: "StreamName", required: true, type: .string) + ] + /// List of shard-level metrics to disable. The following are the valid shard-level metrics. The value "ALL" disables every metric. IncomingBytes IncomingRecords OutgoingBytes OutgoingRecords WriteProvisionedThroughputExceeded ReadProvisionedThroughputExceeded IteratorAgeMilliseconds ALL For more information, see Monitoring the Amazon Kinesis Streams Service with Amazon CloudWatch in the Amazon Kinesis Streams Developer Guide. + public let shardLevelMetrics: [MetricsName] + /// The name of the Amazon Kinesis stream for which to disable enhanced monitoring. + public let streamName: String + + public init(shardLevelMetrics: [MetricsName], streamName: String) { + self.shardLevelMetrics = shardLevelMetrics + self.streamName = streamName + } + + private enum CodingKeys: String, CodingKey { + case shardLevelMetrics = "ShardLevelMetrics" + case streamName = "StreamName" + } + } + + public struct HashKeyRange: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "StartingHashKey", required: true, type: .string), + AWSShapeMember(label: "EndingHashKey", required: true, type: .string) + ] + /// The starting hash key of the hash key range. + public let startingHashKey: String + /// The ending hash key of the hash key range. + public let endingHashKey: String + + public init(startingHashKey: String, endingHashKey: String) { + self.startingHashKey = startingHashKey + self.endingHashKey = endingHashKey + } + + private enum CodingKeys: String, CodingKey { + case startingHashKey = "StartingHashKey" + case endingHashKey = "EndingHashKey" + } + } + + public struct SequenceNumberRange: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "EndingSequenceNumber", required: false, type: .string), + AWSShapeMember(label: "StartingSequenceNumber", required: true, type: .string) + ] + /// The ending sequence number for the range. Shards that are in the OPEN state have an ending sequence number of null. + public let endingSequenceNumber: String? + /// The starting sequence number for the range. + public let startingSequenceNumber: String + + public init(endingSequenceNumber: String? = nil, startingSequenceNumber: String) { + self.endingSequenceNumber = endingSequenceNumber + self.startingSequenceNumber = startingSequenceNumber + } + + private enum CodingKeys: String, CodingKey { + case endingSequenceNumber = "EndingSequenceNumber" + case startingSequenceNumber = "StartingSequenceNumber" + } + } + + public struct DescribeLimitsOutput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "ShardLimit", required: true, type: .integer), + AWSShapeMember(label: "OpenShardCount", required: true, type: .integer) + ] + /// The maximum number of shards. + public let shardLimit: Int32 + /// The number of open shards. + public let openShardCount: Int32 + + public init(shardLimit: Int32, openShardCount: Int32) { + self.shardLimit = shardLimit + self.openShardCount = openShardCount + } + + private enum CodingKeys: String, CodingKey { + case shardLimit = "ShardLimit" + case openShardCount = "OpenShardCount" + } + } + + public struct PutRecordsInput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "Records", required: true, type: .list), + AWSShapeMember(label: "StreamName", required: true, type: .string) + ] + /// The records associated with the request. + public let records: [PutRecordsRequestEntry] + /// The stream name associated with the request. + public let streamName: String + + public init(records: [PutRecordsRequestEntry], streamName: String) { + self.records = records + self.streamName = streamName + } + + private enum CodingKeys: String, CodingKey { + case records = "Records" + case streamName = "StreamName" + } + } + + public struct GetShardIteratorInput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "StartingSequenceNumber", required: false, type: .string), + AWSShapeMember(label: "Timestamp", required: false, type: .timestamp), + AWSShapeMember(label: "ShardIteratorType", required: true, type: .enum), + AWSShapeMember(label: "StreamName", required: true, type: .string), + AWSShapeMember(label: "ShardId", required: true, type: .string) + ] + /// The sequence number of the data record in the shard from which to start reading. Used with shard iterator type AT_SEQUENCE_NUMBER and AFTER_SEQUENCE_NUMBER. + public let startingSequenceNumber: String? + /// The timestamp of the data record from which to start reading. Used with shard iterator type AT_TIMESTAMP. A timestamp is the Unix epoch date with precision in milliseconds. For example, 2016-04-04T19:58:46.480-00:00 or 1459799926.480. If a record with this exact timestamp does not exist, the iterator returned is for the next (later) record. If the timestamp is older than the current trim horizon, the iterator returned is for the oldest untrimmed data record (TRIM_HORIZON). + public let timestamp: TimeStamp? + /// Determines how the shard iterator is used to start reading data records from the shard. The following are the valid Amazon Kinesis shard iterator types: AT_SEQUENCE_NUMBER - Start reading from the position denoted by a specific sequence number, provided in the value StartingSequenceNumber. AFTER_SEQUENCE_NUMBER - Start reading right after the position denoted by a specific sequence number, provided in the value StartingSequenceNumber. AT_TIMESTAMP - Start reading from the position denoted by a specific timestamp, provided in the value Timestamp. TRIM_HORIZON - Start reading at the last untrimmed record in the shard in the system, which is the oldest data record in the shard. LATEST - Start reading just after the most recent record in the shard, so that you always read the most recent data in the shard. + public let shardIteratorType: ShardIteratorType + /// The name of the Amazon Kinesis stream. + public let streamName: String + /// The shard ID of the Amazon Kinesis shard to get the iterator for. + public let shardId: String + + public init(startingSequenceNumber: String? = nil, timestamp: TimeStamp? = nil, shardIteratorType: ShardIteratorType, streamName: String, shardId: String) { + self.startingSequenceNumber = startingSequenceNumber + self.timestamp = timestamp + self.shardIteratorType = shardIteratorType + self.streamName = streamName + self.shardId = shardId + } + + private enum CodingKeys: String, CodingKey { + case startingSequenceNumber = "StartingSequenceNumber" + case timestamp = "Timestamp" + case shardIteratorType = "ShardIteratorType" + case streamName = "StreamName" + case shardId = "ShardId" + } + } + + public struct ListTagsForStreamOutput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "HasMoreTags", required: true, type: .boolean), + AWSShapeMember(label: "Tags", required: true, type: .list) + ] + /// If set to true, more tags are available. To request additional tags, set ExclusiveStartTagKey to the key of the last tag returned. + public let hasMoreTags: Bool + /// A list of tags associated with StreamName, starting with the first tag after ExclusiveStartTagKey and up to the specified Limit. + public let tags: [Tag] + + public init(hasMoreTags: Bool, tags: [Tag]) { + self.hasMoreTags = hasMoreTags + self.tags = tags + } + + private enum CodingKeys: String, CodingKey { + case hasMoreTags = "HasMoreTags" + case tags = "Tags" + } + } + + public struct PutRecordsRequestEntry: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "Data", required: true, type: .blob), + AWSShapeMember(label: "ExplicitHashKey", required: false, type: .string), + AWSShapeMember(label: "PartitionKey", required: true, type: .string) + ] + /// The data blob to put into the record, which is base64-encoded when the blob is serialized. When the data blob (the payload before base64-encoding) is added to the partition key size, the total size must not exceed the maximum record size (1 MB). + public let data: Data + /// The hash value used to determine explicitly the shard that the data record is assigned to by overriding the partition key hash. + public let explicitHashKey: String? + /// Determines which shard in the stream the data record is assigned to. Partition keys are Unicode strings with a maximum length limit of 256 characters for each key. Amazon Kinesis uses the partition key as input to a hash function that maps the partition key and associated data to a specific shard. Specifically, an MD5 hash function is used to map partition keys to 128-bit integer values and to map associated data records to shards. As a result of this hashing mechanism, all data records with the same partition key map to the same shard within the stream. + public let partitionKey: String + + public init(data: Data, explicitHashKey: String? = nil, partitionKey: String) { + self.data = data + self.explicitHashKey = explicitHashKey + self.partitionKey = partitionKey + } + + private enum CodingKeys: String, CodingKey { + case data = "Data" + case explicitHashKey = "ExplicitHashKey" + case partitionKey = "PartitionKey" + } + } + + public struct GetRecordsInput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "Limit", required: false, type: .integer), + AWSShapeMember(label: "ShardIterator", required: true, type: .string) + ] + /// The maximum number of records to return. Specify a value of up to 10,000. If you specify a value that is greater than 10,000, GetRecords throws InvalidArgumentException. + public let limit: Int32? + /// The position in the shard from which you want to start sequentially reading data records. A shard iterator specifies this position using the sequence number of a data record in the shard. + public let shardIterator: String + + public init(limit: Int32? = nil, shardIterator: String) { + self.limit = limit + self.shardIterator = shardIterator + } + + private enum CodingKeys: String, CodingKey { + case limit = "Limit" + case shardIterator = "ShardIterator" + } + } + + public struct UpdateShardCountInput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "TargetShardCount", required: true, type: .integer), + AWSShapeMember(label: "StreamName", required: true, type: .string), + AWSShapeMember(label: "ScalingType", required: true, type: .enum) + ] + /// The new number of shards. + public let targetShardCount: Int32 + /// The name of the stream. + public let streamName: String + /// The scaling type. Uniform scaling creates shards of equal size. + public let scalingType: ScalingType + + public init(targetShardCount: Int32, streamName: String, scalingType: ScalingType) { + self.targetShardCount = targetShardCount + self.streamName = streamName + self.scalingType = scalingType + } + + private enum CodingKeys: String, CodingKey { + case targetShardCount = "TargetShardCount" + case streamName = "StreamName" + case scalingType = "ScalingType" + } + } + + public struct Tag: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "Value", required: false, type: .string), + AWSShapeMember(label: "Key", required: true, type: .string) + ] + /// An optional string, typically used to describe or define the tag. Maximum length: 256 characters. Valid characters: Unicode letters, digits, white space, _ . / = + - % @ + public let value: String? + /// A unique identifier for the tag. Maximum length: 128 characters. Valid characters: Unicode letters, digits, white space, _ . / = + - % @ + public let key: String + + public init(value: String? = nil, key: String) { + self.value = value + self.key = key + } + + private enum CodingKeys: String, CodingKey { + case value = "Value" + case key = "Key" + } + } + + public struct DeleteStreamInput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "StreamName", required: true, type: .string) + ] + /// The name of the stream to delete. + public let streamName: String + + public init(streamName: String) { + self.streamName = streamName + } + + private enum CodingKeys: String, CodingKey { + case streamName = "StreamName" + } + } + + public struct GetShardIteratorOutput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "ShardIterator", required: false, type: .string) + ] + /// The position in the shard from which to start reading data records sequentially. A shard iterator specifies this position using the sequence number of a data record in a shard. + public let shardIterator: String? + + public init(shardIterator: String? = nil) { + self.shardIterator = shardIterator + } + + private enum CodingKeys: String, CodingKey { + case shardIterator = "ShardIterator" + } + } + + public struct PutRecordInput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "PartitionKey", required: true, type: .string), + AWSShapeMember(label: "ExplicitHashKey", required: false, type: .string), + AWSShapeMember(label: "StreamName", required: true, type: .string), + AWSShapeMember(label: "SequenceNumberForOrdering", required: false, type: .string), + AWSShapeMember(label: "Data", required: true, type: .blob) + ] + /// Determines which shard in the stream the data record is assigned to. Partition keys are Unicode strings with a maximum length limit of 256 characters for each key. Amazon Kinesis uses the partition key as input to a hash function that maps the partition key and associated data to a specific shard. Specifically, an MD5 hash function is used to map partition keys to 128-bit integer values and to map associated data records to shards. As a result of this hashing mechanism, all data records with the same partition key map to the same shard within the stream. + public let partitionKey: String + /// The hash value used to explicitly determine the shard the data record is assigned to by overriding the partition key hash. + public let explicitHashKey: String? + /// The name of the stream to put the data record into. + public let streamName: String + /// Guarantees strictly increasing sequence numbers, for puts from the same client and to the same partition key. Usage: set the SequenceNumberForOrdering of record n to the sequence number of record n-1 (as returned in the result when putting record n-1). If this parameter is not set, records will be coarsely ordered based on arrival time. + public let sequenceNumberForOrdering: String? + /// The data blob to put into the record, which is base64-encoded when the blob is serialized. When the data blob (the payload before base64-encoding) is added to the partition key size, the total size must not exceed the maximum record size (1 MB). + public let data: Data + + public init(partitionKey: String, explicitHashKey: String? = nil, streamName: String, sequenceNumberForOrdering: String? = nil, data: Data) { + self.partitionKey = partitionKey + self.explicitHashKey = explicitHashKey + self.streamName = streamName + self.sequenceNumberForOrdering = sequenceNumberForOrdering + self.data = data + } + + private enum CodingKeys: String, CodingKey { + case partitionKey = "PartitionKey" + case explicitHashKey = "ExplicitHashKey" + case streamName = "StreamName" + case sequenceNumberForOrdering = "SequenceNumberForOrdering" + case data = "Data" + } + } + + public struct PutRecordsResultEntry: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "SequenceNumber", required: false, type: .string), + AWSShapeMember(label: "ErrorMessage", required: false, type: .string), + AWSShapeMember(label: "ErrorCode", required: false, type: .string), + AWSShapeMember(label: "ShardId", required: false, type: .string) + ] + /// The sequence number for an individual record result. + public let sequenceNumber: String? + /// The error message for an individual record result. An ErrorCode value of ProvisionedThroughputExceededException has an error message that includes the account ID, stream name, and shard ID. An ErrorCode value of InternalFailure has the error message "Internal Service Failure". + public let errorMessage: String? + /// The error code for an individual record result. ErrorCodes can be either ProvisionedThroughputExceededException or InternalFailure. + public let errorCode: String? + /// The shard ID for an individual record result. + public let shardId: String? + + public init(sequenceNumber: String? = nil, errorMessage: String? = nil, errorCode: String? = nil, shardId: String? = nil) { + self.sequenceNumber = sequenceNumber + self.errorMessage = errorMessage + self.errorCode = errorCode + self.shardId = shardId + } + + private enum CodingKeys: String, CodingKey { + case sequenceNumber = "SequenceNumber" + case errorMessage = "ErrorMessage" + case errorCode = "ErrorCode" + case shardId = "ShardId" + } + } + + public struct ListTagsForStreamInput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "ExclusiveStartTagKey", required: false, type: .string), + AWSShapeMember(label: "StreamName", required: true, type: .string), + AWSShapeMember(label: "Limit", required: false, type: .integer) + ] + /// The key to use as the starting point for the list of tags. If this parameter is set, ListTagsForStream gets all tags that occur after ExclusiveStartTagKey. + public let exclusiveStartTagKey: String? + /// The name of the stream. + public let streamName: String + /// The number of tags to return. If this number is less than the total number of tags associated with the stream, HasMoreTags is set to true. To list additional tags, set ExclusiveStartTagKey to the last key in the response. + public let limit: Int32? + + public init(exclusiveStartTagKey: String? = nil, streamName: String, limit: Int32? = nil) { + self.exclusiveStartTagKey = exclusiveStartTagKey + self.streamName = streamName + self.limit = limit + } + + private enum CodingKeys: String, CodingKey { + case exclusiveStartTagKey = "ExclusiveStartTagKey" + case streamName = "StreamName" + case limit = "Limit" + } + } + + public struct ListStreamsOutput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "StreamNames", required: true, type: .list), + AWSShapeMember(label: "HasMoreStreams", required: true, type: .boolean) + ] + /// The names of the streams that are associated with the AWS account making the ListStreams request. + public let streamNames: [String] + /// If set to true, there are more streams available to list. + public let hasMoreStreams: Bool + + public init(streamNames: [String], hasMoreStreams: Bool) { + self.streamNames = streamNames + self.hasMoreStreams = hasMoreStreams + } + + private enum CodingKeys: String, CodingKey { + case streamNames = "StreamNames" + case hasMoreStreams = "HasMoreStreams" + } + } + + public struct EnableEnhancedMonitoringInput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "ShardLevelMetrics", required: true, type: .list), + AWSShapeMember(label: "StreamName", required: true, type: .string) + ] + /// List of shard-level metrics to enable. The following are the valid shard-level metrics. The value "ALL" enables every metric. IncomingBytes IncomingRecords OutgoingBytes OutgoingRecords WriteProvisionedThroughputExceeded ReadProvisionedThroughputExceeded IteratorAgeMilliseconds ALL For more information, see Monitoring the Amazon Kinesis Streams Service with Amazon CloudWatch in the Amazon Kinesis Streams Developer Guide. + public let shardLevelMetrics: [MetricsName] + /// The name of the stream for which to enable enhanced monitoring. + public let streamName: String + + public init(shardLevelMetrics: [MetricsName], streamName: String) { + self.shardLevelMetrics = shardLevelMetrics + self.streamName = streamName + } + + private enum CodingKeys: String, CodingKey { + case shardLevelMetrics = "ShardLevelMetrics" + case streamName = "StreamName" + } + } + + public enum ScalingType: String, CustomStringConvertible, Codable { + case uniformScaling = "UNIFORM_SCALING" + public var description: String { return self.rawValue } + } + + public struct MergeShardsInput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "AdjacentShardToMerge", required: true, type: .string), + AWSShapeMember(label: "ShardToMerge", required: true, type: .string), + AWSShapeMember(label: "StreamName", required: true, type: .string) + ] + /// The shard ID of the adjacent shard for the merge. + public let adjacentShardToMerge: String + /// The shard ID of the shard to combine with the adjacent shard for the merge. + public let shardToMerge: String + /// The name of the stream for the merge. + public let streamName: String + + public init(adjacentShardToMerge: String, shardToMerge: String, streamName: String) { + self.adjacentShardToMerge = adjacentShardToMerge + self.shardToMerge = shardToMerge + self.streamName = streamName + } + + private enum CodingKeys: String, CodingKey { + case adjacentShardToMerge = "AdjacentShardToMerge" + case shardToMerge = "ShardToMerge" + case streamName = "StreamName" + } + } + + public struct RemoveTagsFromStreamInput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "StreamName", required: true, type: .string), + AWSShapeMember(label: "TagKeys", required: true, type: .list) + ] + /// The name of the stream. + public let streamName: String + /// A list of tag keys. Each corresponding tag is removed from the stream. + public let tagKeys: [String] + + public init(streamName: String, tagKeys: [String]) { + self.streamName = streamName + self.tagKeys = tagKeys + } + + private enum CodingKeys: String, CodingKey { + case streamName = "StreamName" + case tagKeys = "TagKeys" + } + } + + public struct ListStreamsInput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "ExclusiveStartStreamName", required: false, type: .string), + AWSShapeMember(label: "Limit", required: false, type: .integer) + ] + /// The name of the stream to start the list with. + public let exclusiveStartStreamName: String? + /// The maximum number of streams to list. + public let limit: Int32? + + public init(exclusiveStartStreamName: String? = nil, limit: Int32? = nil) { + self.exclusiveStartStreamName = exclusiveStartStreamName + self.limit = limit + } + + private enum CodingKeys: String, CodingKey { + case exclusiveStartStreamName = "ExclusiveStartStreamName" + case limit = "Limit" + } + } + + public struct GetRecordsOutput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "NextShardIterator", required: false, type: .string), + AWSShapeMember(label: "MillisBehindLatest", required: false, type: .long), + AWSShapeMember(label: "Records", required: true, type: .list) + ] + /// The next position in the shard from which to start sequentially reading data records. If set to null, the shard has been closed and the requested iterator will not return any more data. + public let nextShardIterator: String? + /// The number of milliseconds the GetRecords response is from the tip of the stream, indicating how far behind current time the consumer is. A value of zero indicates record processing is caught up, and there are no new records to process at this moment. + public let millisBehindLatest: Int64? + /// The data records retrieved from the shard. + public let records: [Record] + + public init(nextShardIterator: String? = nil, millisBehindLatest: Int64? = nil, records: [Record]) { + self.nextShardIterator = nextShardIterator + self.millisBehindLatest = millisBehindLatest + self.records = records + } + + private enum CodingKeys: String, CodingKey { + case nextShardIterator = "NextShardIterator" + case millisBehindLatest = "MillisBehindLatest" + case records = "Records" + } + } + + public struct SplitShardInput: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "StreamName", required: true, type: .string), + AWSShapeMember(label: "ShardToSplit", required: true, type: .string), + AWSShapeMember(label: "NewStartingHashKey", required: true, type: .string) + ] + /// The name of the stream for the shard split. + public let streamName: String + /// The shard ID of the shard to split. + public let shardToSplit: String + /// A hash key value for the starting hash key of one of the child shards created by the split. The hash key range for a given shard constitutes a set of ordered contiguous positive integers. The value for NewStartingHashKey must be in the range of hash keys being mapped into the shard. The NewStartingHashKey hash key value and all higher hash key values in hash key range are distributed to one of the child shards. All the lower hash key values in the range are distributed to the other child shard. + public let newStartingHashKey: String + + public init(streamName: String, shardToSplit: String, newStartingHashKey: String) { + self.streamName = streamName + self.shardToSplit = shardToSplit + self.newStartingHashKey = newStartingHashKey + } + + private enum CodingKeys: String, CodingKey { + case streamName = "StreamName" + case shardToSplit = "ShardToSplit" + case newStartingHashKey = "NewStartingHashKey" + } + } + + public struct EnhancedMetrics: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "ShardLevelMetrics", required: false, type: .list) + ] + /// List of shard-level metrics. The following are the valid shard-level metrics. The value "ALL" enhances every metric. IncomingBytes IncomingRecords OutgoingBytes OutgoingRecords WriteProvisionedThroughputExceeded ReadProvisionedThroughputExceeded IteratorAgeMilliseconds ALL For more information, see Monitoring the Amazon Kinesis Streams Service with Amazon CloudWatch in the Amazon Kinesis Streams Developer Guide. + public let shardLevelMetrics: [MetricsName]? + + public init(shardLevelMetrics: [MetricsName]? = nil) { + self.shardLevelMetrics = shardLevelMetrics + } + + private enum CodingKeys: String, CodingKey { + case shardLevelMetrics = "ShardLevelMetrics" + } + } + + public struct StreamDescription: AWSShape { + public static var members: [AWSShapeMember] = [ + AWSShapeMember(label: "StreamARN", required: true, type: .string), + AWSShapeMember(label: "RetentionPeriodHours", required: true, type: .integer), + AWSShapeMember(label: "EnhancedMonitoring", required: true, type: .list), + AWSShapeMember(label: "HasMoreShards", required: true, type: .boolean), + AWSShapeMember(label: "Shards", required: true, type: .list), + AWSShapeMember(label: "StreamCreationTimestamp", required: true, type: .timestamp), + AWSShapeMember(label: "StreamName", required: true, type: .string), + AWSShapeMember(label: "StreamStatus", required: true, type: .enum) + ] + /// The Amazon Resource Name (ARN) for the stream being described. + public let streamARN: String + /// The current retention period, in hours. + public let retentionPeriodHours: Int32 + /// Represents the current enhanced monitoring settings of the stream. + public let enhancedMonitoring: [EnhancedMetrics] + /// If set to true, more shards in the stream are available to describe. + public let hasMoreShards: Bool + /// The shards that comprise the stream. + public let shards: [Shard] + /// The approximate time that the stream was created. + public let streamCreationTimestamp: TimeStamp + /// The name of the stream being described. + public let streamName: String + /// The current status of the stream being described. The stream status is one of the following states: CREATING - The stream is being created. Amazon Kinesis immediately returns and sets StreamStatus to CREATING. DELETING - The stream is being deleted. The specified stream is in the DELETING state until Amazon Kinesis completes the deletion. ACTIVE - The stream exists and is ready for read and write operations or deletion. You should perform read and write operations only on an ACTIVE stream. UPDATING - Shards in the stream are being merged or split. Read and write operations continue to work while the stream is in the UPDATING state. + public let streamStatus: StreamStatus + + public init(streamARN: String, retentionPeriodHours: Int32, enhancedMonitoring: [EnhancedMetrics], hasMoreShards: Bool, shards: [Shard], streamCreationTimestamp: TimeStamp, streamName: String, streamStatus: StreamStatus) { + self.streamARN = streamARN + self.retentionPeriodHours = retentionPeriodHours + self.enhancedMonitoring = enhancedMonitoring + self.hasMoreShards = hasMoreShards + self.shards = shards + self.streamCreationTimestamp = streamCreationTimestamp + self.streamName = streamName + self.streamStatus = streamStatus + } + + private enum CodingKeys: String, CodingKey { + case streamARN = "StreamARN" + case retentionPeriodHours = "RetentionPeriodHours" + case enhancedMonitoring = "EnhancedMonitoring" + case hasMoreShards = "HasMoreShards" + case shards = "Shards" + case streamCreationTimestamp = "StreamCreationTimestamp" + case streamName = "StreamName" + case streamStatus = "StreamStatus" + } + } + + public enum StreamStatus: String, CustomStringConvertible, Codable { + case creating = "CREATING" + case deleting = "DELETING" + case active = "ACTIVE" + case updating = "UPDATING" + public var description: String { return self.rawValue } + } + +} \ No newline at end of file