Skip to content

Commit

Permalink
Initial changes for documentation using mkdocs. Added Service Clients…
Browse files Browse the repository at this point in the history
… usage and S3TransferUtility usage.
  • Loading branch information
Rohan Dubal authored and scb01 committed Jul 2, 2018
1 parent 6ab2982 commit 5b7abfd
Show file tree
Hide file tree
Showing 17 changed files with 932 additions and 0 deletions.
113 changes: 113 additions & 0 deletions Scripts/APIReference.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#!/bin/sh
set -x

# remove everything generated by this script
function cleanup
{
rm -rf docs/reference
rm -rf Documentation
rm -rf docs_tmp
}


VERSION="2.6.22"
if [ -n $1 ] && [ "$1" == "clean" ];
then
cleanup
exit 0
else
cd "$SOURCE_ROOT"

if [ -d docs/reference ];
then
cleanup
fi

rm -rf docs_tmp
mkdir -p docs_tmp

cp -r AWSAPIGateway ./docs_tmp/AWSAPIGateway
cp -r AWSAutoScaling ./docs_tmp/AWSAutoScaling
cp -r AWSCore ./docs_tmp/AWSCore
cp -r AWSCognito ./docs_tmp/AWSCognito
cp -r AWSCognitoIdentityProvider ./docs_tmp/AWSCognitoIdentityProvider
cp -r AWSCloudWatch ./docs_tmp/AWSCloudWatch
cp -r AWSDynamoDB ./docs_tmp/AWSDynamoDB
cp -r AWSElasticLoadBalancing ./docs_tmp/AWSElasticLoadBalancing
cp -r AWSIoT ./docs_tmp/AWSIoT
cp -r AWSKinesis ./docs_tmp/AWSKinesis
cp -r AWSKMS ./docs_tmp/AWSKMS
cp -r AWSLambda ./docs_tmp/AWSLambda
cp -r AWSLex ./docs_tmp/AWSLex
cp -r AWSLogs ./docs_tmp/AWSLogs
cp -r AWSMachineLearning ./docs_tmp/AWSMachineLearning
cp -r AWSMobileAnalytics ./docs_tmp/AWSMobileAnalytics
cp -r AWSPinpoint ./docs_tmp/AWSPinpoint
cp -r AWSPolly ./docs_tmp/AWSPolly
cp -r AWSRekognition ./docs_tmp/AWSRekognition
cp -r AWSS3 ./docs_tmp/AWSS3
cp -r AWSSES ./docs_tmp/AWSSES
cp -r AWSSimpleDB ./docs_tmp/AWSSimpleDB
cp -r AWSSNS ./docs_tmp/AWSSNS
cp -r AWSSQS ./docs_tmp/AWSSQS
cp -r AWSTranscribe ./docs_tmp/AWSTranscribe
cp -r AWSTranslate ./docs_tmp/AWSTranslate
cp -r AWSComprehend ./docs_tmp/AWSComprehend
cp -r AWSCognitoAuth ./docs_tmp/AWSCognitoAuth
cp -r AWSAuthSDK/Sources/AWSAuthCore ./docs_tmp/AWSAuthSDK/
cp -r AWSAuthSDK/Sources/AWSAuthUI ./docs_tmp/AWSAuthSDK/
cp -r AWSAuthSDK/Sources/AWSFacebookSignIn ./docs_tmp/AWSAuthSDK/
cp -r AWSAuthSDK/Sources/AWSGoogleSignIn ./docs_tmp/AWSAuthSDK/
cp -r AWSAuthSDK/Sources/AWSUserPoolsSignIn ./docs_tmp/AWSAuthSDK/
cp -r AWSAuthSDK/Sources/AWSAuthUI ./docs_tmp/AWSAuthSDK/
cp -r AWSAuthSDK/Sources/AWSMobileClient ./docs_tmp/AWSAuthSDK/

rm -rf ./docs_tmp/AWSCore/Bolts
rm -rf ./docs_tmp/AWSCore/Fabric
rm -rf ./docs_tmp/AWSCore/FMDB
rm -rf ./docs_tmp/AWSCore/GZIP
rm -rf ./docs_tmp/AWSCore/Logging
rm -rf ./docs_tmp/AWSCore/Mantle
rm -rf ./docs_tmp/AWSCore/Reachability
rm -rf ./docs_tmp/AWSCore/TMCache
rm -rf ./docs_tmp/AWSCore/UICKeyChainStore
rm -rf ./docs_tmp/AWSCore/XMLDictionary
rm -rf ./docs_tmp/AWSCore/XMLWriter
rm -rf ./docs_tmp/AWSCognito/Internal
rm -rf ./docs_tmp/AWSCognito/Fabric
rm -rf ./docs_tmp/AWSCognitoIdentityProvider/Internal
rm -rf ./docs_tmp/AWSCognitoAuth/Internal
rm -rf ./docs_tmp/AWSMobileAnalytics/Internal
rm -rf ./docs_tmp/AWSIoT/Internal
rm -rf ./docs_tmp/AWSLex/Bluefront
rm -rf ./docs_tmp/AWSAuthSDK/UserPoolsUI

cd docs_tmp

# generate documenation
appledoc --verbose 1 \
--output ../docs/reference \
--exit-threshold 2 \
--no-repeat-first-par \
--explicit-crossref \
--company-id aws.amazon.com \
--project-name "AWS Mobile SDK for iOS v${VERSION}" \
--project-version "${VERSION}" \
--project-company "Amazon Web Services, Inc." \
--create-html \
--keep-intermediate-files \
--index-desc ../aws-sdk-for-ios.markdown \
./

# get command execution result
result=$?

if [ $result != 0 ];
then
echo "Building the AWS Mobile SDK for iOS documentation FAILED!"
cleanup;
exit 1;
fi

exit 0
fi
4 changes: 4 additions & 0 deletions Scripts/DocsCleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rm -rf docs/reference/docset/
rm docs/reference/docset-installed.txt
cp -r docs/reference/html/ docs/docs/reference
rm -rf docs/reference
1 change: 1 addition & 0 deletions docs/awstask.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
With native AWSTask support in the SDK for iOS, you can chain async requests instead of nesting them. It makes the logic cleaner, while keeping the code more readable. Read [Working with AWSTask](http://docs.aws.amazon.com/mobile/sdkforios/developerguide/awstask.html) to learn how to use AWSTask.
40 changes: 40 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# AWS Mobile SDK for iOS

[![Release](https://img.shields.io/github/release/aws/aws-sdk-ios.svg)]()
[![CocoaPods](https://img.shields.io/cocoapods/v/AWSiOSSDKv2.svg)]()
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Twitter Follow](https://img.shields.io/twitter/follow/AWSforMobile.svg?style=social&label=Follow)](https://twitter.com/AWSforMobile)

## Introduction

AWS Mobile SDK for iOS offers a set of SDKs which make working with AWS easy. You could leverage services like `S3`, `AppSync`, `IoT`, `CognitoUserPools`, `DynamoDB`, and many other in your application with very few steps. We also provide utility clients like `S3TransferUtility`, `Auth`, `DynamoDB`, etc. which further simplify interaction with the cloud!

## Quick Links

* [API Reference](http://aws.github.io/aws-sdk-ios/docs/reference)
* [Source Code on Github](https://github.com/aws/aws-sdk-ios)

## Setting Up

???+info "Setup Requirements"
To use the AWS SDK for iOS, you will need the following installed on your development machine:

* Xcode 8 or later
* iOS Simulators / iPhones with iOS 9 or later

To get started with AWS Mobile SDK for iOS, follow __**[this link](setup/setup-dependencies.md)**__ to setup the dependencies and integrate them in your application.

???- tip "SDK Samples"
The [samples](https://github.com/awslabs/aws-sdk-ios-samples) included with the SDK for iOS are standalone projects that are already set up for you. You can also integrate the SDK for iOS with your own existing project.

## Talk to Us

Visit our [GitHub Page](https://github.com/aws/aws-sdk-ios) to leave feedback and to connect with other users of the SDK.

## Author

Amazon Web Services

## License

See the **LICENSE** file for more info.
65 changes: 65 additions & 0 deletions docs/logging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
As of version 2.5.4 of this SDK, logging utilizes [CocoaLumberjack](https://github.com/CocoaLumberjack/CocoaLumberjack), a flexible, fast, open source logging framework. It supports many capabilities including the ability to set logging level per output target, for instance, concise messages logged to the console and verbose messages to a log file.

CocoaLumberjack logging levels are additive such that when the level is set to verbose, all messages from the levels below verbose are logged. It is also possible to set custom logging to meet your needs. For more information, see [CocoaLumberjack](https://github.com/CocoaLumberjack/CocoaLumberjack/blob/master/Documentation/CustomLogLevels.md)

## Changing Log Levels

```swift tab="Swift"
AWSDDLog.sharedInstance.logLevel = .verbose
```

```objective-c tab="Objective-C"
[AWSDDLog sharedInstance].logLevel = AWSDDLogLevelVerbose;
```

The following logging level options are available:

```swift tab="Swift"
.off
.error
.warning
.info
.debug
.verbose
```

```objective-c tab="Objective-C"
AWSDDLogLevelOff
AWSDDLogLevelError
AWSDDLogLevelWarning
AWSDDLogLevelInfo
AWSDDLogLevelDebug
AWSDDLogLevelVerbose
```

We recommend setting the log level to `Off` before publishing to the Apple App Store.

## Targeting Log Output

CocoaLumberjack can direct logs to file or used as a framework that integrates with the Xcode console.

To initialize logging to files, use the following code:

```swift tab="Swift"
let fileLogger: AWSDDFileLogger = AWSDDFileLogger() // File Logger
fileLogger.rollingFrequency = TimeInterval(60*60*24) // 24 hours
fileLogger.logFileManager.maximumNumberOfLogFiles = 7
AWSDDLog.add(fileLogger)
```

```objective-c tab="Objective-C"
AWSDDFileLogger *fileLogger = [[AWSDDFileLogger alloc] init]; // File Logger
fileLogger.rollingFrequency = 60 * 60 * 24; // 24 hour rolling
fileLogger.logFileManager.maximumNumberOfLogFiles = 7;
[AWSDDLog addLogger:fileLogger];
```
To initialize logging to your Xcode console, use the following code:
```swift tab="Swift"
AWSDDLog.add(AWSDDTTYLogger.sharedInstance) // TTY = Xcode console
```

```objective-c tab="Objective-C"
[AWSDDLog addLogger:[AWSDDTTYLogger sharedInstance]]; // TTY = Xcode console
```
Binary file added docs/readme-images/cocoapods-setup-01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/readme-images/cocoapods-setup-02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/readme-images/cocoapods-setup-03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
119 changes: 119 additions & 0 deletions docs/s3/s3-downloads.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
You can use `AWSS3TransferUtility` to download your data from `Amazon S3`. It internally uses `NSURLSession` to facilitate that the downloads continue even when the app goes into background.

## Download raw data

You can pass in a `Data` object to the `uploadUsingMultiPart` API to upload data which will be store in `S3`.

```swift linenums="2"

// Fetch the transfer utility client
let transferUtility = AWSS3TransferUtility.default()

// Initialize the completion handler which will be called when the upload completes
var completionHandler: AWSS3TransferUtilityDownloadCompletionHandlerBlock?

completionHandler = { (task, location, data, error) -> Void in
DispatchQueue.main.async(execute: {
if let error = error {
// Handle error here. Indicates download failed.
} else {
// `data` object contains the downloaded data
}
})
}

// The download task contains information about your download and can be used for activities like pause, resume, cancel.
let downloadTask = transferUtility.downloadData(
fromBucket: "YourBucket",
key: "YourFileName",
expression: nil,
completionHandler: completionHandler)
```

## Download to File

```swift linenums="2"

// Fetch the transfer utility client
let transferUtility = AWSS3TransferUtility.default()

// Initialize the completion handler which will be called when the upload completes
var completionHandler: AWSS3TransferUtilityDownloadCompletionHandlerBlock?

completionHandler = { (task, location, data, error) -> Void in
DispatchQueue.main.async(execute: {
if let error = error {
// Handle error here. Indicates download failed.
} else {
// `location` object contains the location of downloaded data
}
})
}

// Determine the file location where you want the download to happen
let downloadLocation: URL = URL(....)

// The download task contains information about your download and can be used for activities like pause, resume, cancel.
let downloadTask = transferUtility.download(to: downloadLocation
fromBucket: "YourBucket",
key: "YourFileName",
expression: nil,
completionHandler: completionHandler)
```

## Progress Tracking

To enable progress tracking, we will use the `expression` parameter in the `download` API call as highlighted below. We will update the example above to include progress tracking.

```swift hl_lines="4 5 6 7 8 9 10 32" linenums="2"

// Fetch the transfer utility client
let transferUtility = AWSS3TransferUtility.default()

// Create progress tracking expression
let expression = AWSS3TransferUtilityDownloadExpression()
expression.progressBlock = {(task, progress) in
DispatchQueue.main.async(execute: {
// Do something e.g. Update a progress bar.
})
}

// Initialize the completion handler which will be called when the upload completes
var completionHandler: AWSS3TransferUtilityDownloadCompletionHandlerBlock?

completionHandler = { (task, location, data, error) -> Void in
DispatchQueue.main.async(execute: {
if let error = error {
// Handle error here. Indicates download failed.
} else {
// `location` object contains the location of downloaded data
}
})
}

// Determine the file location where you want the download to happen
let downloadLocation: URL = URL(....)

// The download task contains information about your download and can be used for activities like pause, resume, cancel.
let downloadTask = transferUtility.download(to: downloadLocation
fromBucket: "YourBucket",
key: "YourFileName",
expression: expression,
completionHandler: completionHandler)
```

## Pause / Resume / Cancel

We use the `downloadTask` object which we get back from the `download` call to perform the pause, resume and cancel operations.

### Pause

downloadTask.suspend()

### Resume

downloadTask.resume()

### Cancel

downloadTask.cancel()
Loading

0 comments on commit 5b7abfd

Please sign in to comment.