Skip to content

Commit 8f09dfd

Browse files
committed
Merge branch 'dotnettestfixes' of github.com:rlhagerm/aws-doc-sdk-examples into dotnettestfixes
2 parents a84d6b2 + 2e6eb0b commit 8f09dfd

File tree

25 files changed

+3753
-2665
lines changed

25 files changed

+3753
-2665
lines changed

.doc_gen/metadata/dynamodb_metadata.yaml

Lines changed: 2386 additions & 2386 deletions
Large diffs are not rendered by default.

.doc_gen/metadata/opensearch_metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ opensearch_DescribeDomain:
131131
excerpts:
132132
- description:
133133
snippet_tags:
134-
- opensearch.java2.update_domain.main
134+
- opensearch.java2.describe_domain.main
135135
services:
136136
opensearch: {DescribeDomain}
137137
opensearch_UpdateDomainConfig:

javav2/example_code/mediaconvert/src/main/java/com/example/mediaconvert/CreateJob.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -154,25 +154,11 @@ public static String createMediaJob(MediaConvertClient mc, String mcRoleARN, Str
154154

155155
try {
156156
// snippet-start:[mediaconvert.java.createjob.getendpointurl]
157-
DescribeEndpointsResponse res = mc
158-
.describeEndpoints(DescribeEndpointsRequest.builder().maxResults(20).build());
159-
160-
if (res.endpoints().size() <= 0) {
161-
System.out.println("Cannot find MediaConvert service endpoint URL!");
162-
System.exit(1);
163-
}
164-
String endpointURL = res.endpoints().get(0).url();
165-
System.out.println("MediaConvert service URL: " + endpointURL);
166157
System.out.println("MediaConvert role arn: " + mcRoleARN);
167158
System.out.println("MediaConvert input file: " + fileInput);
168159
System.out.println("MediaConvert output path: " + s3path);
169160
// snippet-end:[mediaconvert.java.createjob.getendpointurl]
170161

171-
MediaConvertClient emc = MediaConvertClient.builder()
172-
.region(Region.US_WEST_2)
173-
.endpointOverride(URI.create(endpointURL))
174-
.build();
175-
176162
// output group Preset HLS low profile
177163
Output hlsLow = createOutput("hls_low", "_low", "_$dt$", 750000, 7, 1920, 1080, 640);
178164
// output group Preset HLS media profile
@@ -369,7 +355,7 @@ public static String createMediaJob(MediaConvertClient mc, String mcRoleARN, Str
369355
.settings(jobSettings)
370356
.build();
371357

372-
CreateJobResponse createJobResponse = emc.createJob(createJobRequest);
358+
CreateJobResponse createJobResponse = mc.createJob(createJobRequest);
373359
return createJobResponse.job().id();
374360

375361
} catch (MediaConvertException e) {

javav2/example_code/mediaconvert/src/main/java/com/example/mediaconvert/GetJob.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,11 @@ public static void main(String[] args) {
4949

5050
public static void getSpecificJob(MediaConvertClient mc, String jobId) {
5151
try {
52-
DescribeEndpointsResponse res = mc.describeEndpoints(DescribeEndpointsRequest.builder()
53-
.maxResults(20)
54-
.build());
55-
56-
if (res.endpoints().size() <= 0) {
57-
System.out.println("Cannot find MediaConvert service endpoint URL!");
58-
System.exit(1);
59-
}
60-
String endpointURL = res.endpoints().get(0).url();
61-
MediaConvertClient emc = MediaConvertClient.builder()
62-
.region(Region.US_WEST_2)
63-
.endpointOverride(URI.create(endpointURL))
64-
.build();
65-
6652
GetJobRequest jobRequest = GetJobRequest.builder()
6753
.id(jobId)
6854
.build();
6955

70-
GetJobResponse response = emc.getJob(jobRequest);
56+
GetJobResponse response = mc.getJob(jobRequest);
7157
System.out.println("The ARN of the job is " + response.job().arn());
7258

7359
} catch (MediaConvertException e) {

javav2/example_code/mediaconvert/src/main/java/com/example/mediaconvert/ListJobs.java

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,14 @@ public static void main(String[] args) {
3838

3939
public static void listCompleteJobs(MediaConvertClient mc) {
4040
try {
41-
DescribeEndpointsResponse res = mc.describeEndpoints(DescribeEndpointsRequest.builder()
42-
.maxResults(20)
43-
.build());
44-
45-
if (res.endpoints().size() <= 0) {
46-
System.out.println("Cannot find MediaConvert service endpoint URL!");
47-
System.exit(1);
48-
}
49-
50-
String endpointURL = res.endpoints().get(0).url();
51-
MediaConvertClient emc = MediaConvertClient.builder()
52-
.region(Region.US_WEST_2)
53-
.endpointOverride(URI.create(endpointURL))
54-
.build();
55-
41+
// Create the ListJobsRequest
5642
ListJobsRequest jobsRequest = ListJobsRequest.builder()
5743
.maxResults(10)
5844
.status("COMPLETE")
5945
.build();
6046

61-
ListJobsResponse jobsResponse = emc.listJobs(jobsRequest);
47+
// Call the listJobs operation
48+
ListJobsResponse jobsResponse = mc.listJobs(jobsRequest);
6249
List<Job> jobs = jobsResponse.jobs();
6350
for (Job job : jobs) {
6451
System.out.println("The JOB ARN is : " + job.arn());

javav2/example_code/opensearch/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Code excerpts that show you how to call individual service functions.
4949
- [ChangeProgress](src/main/java/com/example/search/scenario/OpenSearchActions.java#L215)
5050
- [CreateDomain](src/main/java/com/example/search/scenario/OpenSearchActions.java#L69)
5151
- [DeleteDomain](src/main/java/com/example/search/scenario/OpenSearchActions.java#L114)
52-
- [DescribeDomain](src/main/java/com/example/search/scenario/OpenSearchActions.java#L189)
52+
- [DescribeDomain](src/main/java/com/example/search/scenario/OpenSearchActions.java#L136)
5353
- [ListDomainNames](src/main/java/com/example/search/scenario/OpenSearchActions.java#L167)
5454
- [ListTags](src/main/java/com/example/search/scenario/OpenSearchActions.java#L265)
5555
- [UpdateDomainConfig](src/main/java/com/example/search/scenario/OpenSearchActions.java#L189)
@@ -119,4 +119,4 @@ in the `javav2` folder.
119119

120120
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
121121

122-
SPDX-License-Identifier: Apache-2.0
122+
SPDX-License-Identifier: Apache-2.0

javav2/example_code/redshift/src/test/java/AmazonRedshiftTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ public class AmazonRedshiftTest {
4848
@BeforeAll
4949
public static void setUp() {
5050
redshiftClient = RedshiftClient.builder()
51-
.region(Region.US_EAST_1)
51+
.region(Region.US_EAST_2)
5252
.build();
5353

5454
redshiftDataClient = RedshiftDataClient.builder()
55-
.region(Region.US_EAST_1)
55+
.region(Region.US_EAST_2)
5656
.build();
5757

5858
Random rand = new Random();
@@ -195,6 +195,7 @@ public void testDeleteDatabase() {
195195
logger.info("Test 11 passed");
196196
}
197197

198+
198199
private static String getSecretValues() {
199200
SecretsManagerClient secretClient = SecretsManagerClient.builder()
200201
.region(Region.US_EAST_1)

javav2/example_code/sts/src/main/java/com/example/sts/AssumeRole.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
* {
3030
* "Effect": "Allow",
3131
* "Principal": {
32-
* "AWS": "<Specify the ARN of your IAM user you are using in this code
33-
* example>"
32+
* "AWS": "<Specify the ARN of your IAM user you are using in this code example>"
3433
* },
3534
* "Action": "sts:AssumeRole"
3635
* }
@@ -54,7 +53,7 @@ public static void main(String[] args) {
5453
<roleArn> <roleSessionName>\s
5554
5655
Where:
57-
roleArn - The Amazon Resource Name (ARN) of the role to assume (for example, rn:aws:iam::000008047983:role/s3role).\s
56+
roleArn - The Amazon Resource Name (ARN) of the role to assume (for example, arn:aws:iam::000008047983:role/s3role).\s
5857
roleSessionName - An identifier for the assumed role session (for example, mysession).\s
5958
""";
6059

php/README.md

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,75 @@ Cross-service examples are located in the [*cross-services folder*](cross_servic
2222
* We recommend that you grant your code least privilege. At most, grant only the minimum permissions required to perform the task. For more information, see [Grant least privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege).
2323
* This code is not tested in every AWS Region. For more information, see [AWS Regional Services](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services).
2424

25+
## Prerequisites
2526

26-
### Prerequisites
27+
To run these code examples, you need:
28+
29+
* [PHP](https://www.php.net/) version 8.1 or higher
30+
* [Composer](https://getcomposer.org) for dependency management
31+
* [PHPUnit](https://phpunit.de/) for unit testing
32+
* The [AWS SDK for PHP](https://aws.amazon.com/sdk-for-php/)
33+
* [AWS credentials](https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials.html) set up
34+
35+
For more information, see [Getting Started](https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/getting-started_index.html) in the AWS SDK for PHP Developer Guide.
36+
37+
## Set up the examples
38+
39+
Some examples require supporting files from the GitHub repository in addition to the AWS SDK for PHP. For these examples:
40+
41+
1. Clone, fork, or download the entire [aws-doc-sdk-examples repository](https://github.com/awsdocs/aws-doc-sdk-examples) from GitHub.
42+
43+
You need the entire repository, not just individual files, so supporting files can be accessed by the examples.
44+
45+
2. Install dependencies
46+
47+
From the directory that contains the composer.json file for the example, run:
48+
```bash
49+
composer install
50+
```
51+
52+
3. Run examples from within the repository structure and from the directory that contains the initiating code
53+
54+
Run examples from within the cloned directory structure to ensure access to supporting files.
55+
56+
## Run the examples
57+
58+
By default, these code examples run using the default AWS credential provider chain, which includes using the AWS shared credentials and config files with a `default` profile.
59+
For more information, about using AWS shared files and the `default` profile, see [Using shared config and credentials files to globally configure AWS SDKs and tools](https://docs.aws.amazon.com/sdkref/latest/guide/file-format.html) in the *AWS SDKs and Tools
60+
Reference Guide*.
61+
62+
Important: Running these code examples might result in charges to the AWS account associated with the AWS credentials being used.
63+
64+
Many examples include a `Runner.php` file to abstract the logic from running the code. From any example directory with a Runner.php file, run:
65+
66+
```bash
67+
php Runner.php
68+
```
69+
70+
---------
71+
72+
## Prerequisites
2773
To run or test these code examples, you need the following:
2874

2975
- [PHP](https://www.php.net/) version 8.1 or higher
3076
- [Composer](https://getcomposer.org), for dependency management
3177
- [PHPUnit](https://phpunit.de/), for unit testing
3278
- The [AWS SDK for PHP](https://aws.amazon.com/sdk-for-php/)
3379
- [AWS credentials](https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials.html) set up
80+
- For examples that use supporting files that are available only in the GitHub repository
81+
and not available for installation by Composer, you need to
82+
- clone, fork, or download a zip of the entire [aws-doc-sdk-examples repository](https://github.com/awsdocs/aws-doc-sdk-examples) from GitHub.
83+
You want the entire repository, not just indvidual files, so supporting files can be accessed by the examples.
84+
- Run the example from within the directory structure and from within the directory that contains the composer.json file.
85+
- Install the dependencies and configuration settings with Composer.
3486

3587
For more information, see [Getting Started](https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/getting-started_index.html) in the *AWS SDK for PHP Developer Guide*.
3688

3789
## Run the code
3890

39-
By default, these code examples run using the default AWS credential provider chain, which includes using an AWS shared credentials file and profiles.
40-
For more information, see [Using the AWS Credentials File and Credential Profiles](https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials_profiles.html) in the *AWS SDK for PHP Developer Guide*.
91+
By default, these code examples run using the default AWS credential provider chain, which includes using the AWS shared credentials and config files with a `default` profile.
92+
For more information, about using AWS shared files and the `default` profile, see [Using shared config and credentials files to globally configure AWS SDKs and tools](https://docs.aws.amazon.com/sdkref/latest/guide/file-format.html) in the *AWS SDKs and Tools
93+
Reference Guide*.
4194

4295
Running these code examples might result in charges to the AWS account that is associated with the AWS credentials being used.
4396

php/example_code/dynamodb/DynamoDBService.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ class DynamoDBService extends AWSServiceClass
1717
public function __construct(
1818
DynamoDbClient $client = null,
1919
string $region = 'us-west-2',
20-
string $version = 'latest',
21-
string $profile = 'default'
20+
string $version = 'latest'
2221
) {
2322
if (gettype($client) == DynamoDbClient::class) {
2423
$this->dynamoDbClient = $client;
@@ -27,7 +26,6 @@ public function __construct(
2726
$this->dynamoDbClient = new DynamoDbClient([
2827
'region' => $region,
2928
'version' => $version,
30-
'profile' => $profile,
3129
'http' => [
3230
'verify' => false,
3331
],

0 commit comments

Comments
 (0)