Skip to content

Commit

Permalink
Merge pull request #356 from commercetools/gen-sdk-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jenschude committed Oct 24, 2022
2 parents 8ed0248 + 60ef0ff commit 1b37525
Show file tree
Hide file tree
Showing 13 changed files with 272 additions and 106 deletions.
@@ -0,0 +1,74 @@

package com.commercetools.api.models.subscription;

import java.util.Arrays;
import java.util.Optional;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import io.vrap.rmf.base.client.utils.Generated;

/**
* <p>Defines the method of authentication for AWS SQS and SNS Destinations. Subscriptions with <code>Credentials</code> authentication mode are authenticated using an <code>accessKey</code> and <code>accessSecret</code> pair. Subscriptions with <code>IAM</code> authentication mode are authenticated using Identity and Access Management (IAM). In this case, the user <code>arn:aws:iam::362576667341:user/subscriptions</code> requires permissions to send messages to the queue or publish to the topic. This is the recommended <code>authenticationMode</code>, as it doesn't require additional key management.</p>
*/
@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
public interface AwsAuthenticationMode {

AwsAuthenticationMode CREDENTIALS = AwsAuthenticationModeEnum.CREDENTIALS;

AwsAuthenticationMode IAM = AwsAuthenticationModeEnum.IAM;

enum AwsAuthenticationModeEnum implements AwsAuthenticationMode {
CREDENTIALS("Credentials"),

IAM("IAM");
private final String jsonName;

private AwsAuthenticationModeEnum(final String jsonName) {
this.jsonName = jsonName;
}

public String getJsonName() {
return jsonName;
}

public String toString() {
return jsonName;
}
}

@JsonValue
String getJsonName();

String name();

String toString();

@JsonCreator
public static AwsAuthenticationMode findEnum(String value) {
return findEnumViaJsonName(value).orElse(new AwsAuthenticationMode() {
@Override
public String getJsonName() {
return value;
}

@Override
public String name() {
return value.toUpperCase();
}

public String toString() {
return value;
}
});
}

public static Optional<AwsAuthenticationMode> findEnumViaJsonName(String jsonName) {
return Arrays.stream(values()).filter(t -> t.getJsonName().equals(jsonName)).findFirst();
}

public static AwsAuthenticationMode[] values() {
return AwsAuthenticationModeEnum.values();
}
}
Expand Up @@ -20,8 +20,6 @@
* <div class=code-example>
* <pre><code class='java'>
* SnsDestination snsDestination = SnsDestination.builder()
* .accessKey("{accessKey}")
* .accessSecret("{accessSecret}")
* .topicArn("{topicArn}")
* .build()
* </code></pre>
Expand All @@ -34,16 +32,16 @@ public interface SnsDestination extends Destination {
String SNS = "SNS";

/**
*
* <p>Only present if <code>authenticationMode</code> is set to <code>Credentials</code>.</p>
*/
@NotNull

@JsonProperty("accessKey")
public String getAccessKey();

/**
*
* <p>Only present if <code>authenticationMode</code> is set to <code>Credentials</code>.</p>
*/
@NotNull

@JsonProperty("accessSecret")
public String getAccessSecret();

Expand All @@ -54,12 +52,21 @@ public interface SnsDestination extends Destination {
@JsonProperty("topicArn")
public String getTopicArn();

/**
* <p>Defines the method of authentication for the SNS topic.</p>
*/

@JsonProperty("authenticationMode")
public AwsAuthenticationMode getAuthenticationMode();

public void setAccessKey(final String accessKey);

public void setAccessSecret(final String accessSecret);

public void setTopicArn(final String topicArn);

public void setAuthenticationMode(final AwsAuthenticationMode authenticationMode);

public static SnsDestination of() {
return new SnsDestinationImpl();
}
Expand All @@ -69,6 +76,7 @@ public static SnsDestination of(final SnsDestination template) {
instance.setAccessKey(template.getAccessKey());
instance.setAccessSecret(template.getAccessSecret());
instance.setTopicArn(template.getTopicArn());
instance.setAuthenticationMode(template.getAuthenticationMode());
return instance;
}

Expand Down
Expand Up @@ -3,6 +3,8 @@

import java.util.*;

import javax.annotation.Nullable;

import io.vrap.rmf.base.client.Builder;
import io.vrap.rmf.base.client.utils.Generated;

Expand All @@ -13,8 +15,6 @@
* <div class=code-example>
* <pre><code class='java'>
* SnsDestination snsDestination = SnsDestination.builder()
* .accessKey("{accessKey}")
* .accessSecret("{accessSecret}")
* .topicArn("{topicArn}")
* .build()
* </code></pre>
Expand All @@ -23,26 +23,31 @@
@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
public class SnsDestinationBuilder implements Builder<SnsDestination> {

@Nullable
private String accessKey;

@Nullable
private String accessSecret;

private String topicArn;

@Nullable
private com.commercetools.api.models.subscription.AwsAuthenticationMode authenticationMode;

/**
*
* <p>Only present if <code>authenticationMode</code> is set to <code>Credentials</code>.</p>
*/

public SnsDestinationBuilder accessKey(final String accessKey) {
public SnsDestinationBuilder accessKey(@Nullable final String accessKey) {
this.accessKey = accessKey;
return this;
}

/**
*
* <p>Only present if <code>authenticationMode</code> is set to <code>Credentials</code>.</p>
*/

public SnsDestinationBuilder accessSecret(final String accessSecret) {
public SnsDestinationBuilder accessSecret(@Nullable final String accessSecret) {
this.accessSecret = accessSecret;
return this;
}
Expand All @@ -56,10 +61,22 @@ public SnsDestinationBuilder topicArn(final String topicArn) {
return this;
}

/**
* <p>Defines the method of authentication for the SNS topic.</p>
*/

public SnsDestinationBuilder authenticationMode(
@Nullable final com.commercetools.api.models.subscription.AwsAuthenticationMode authenticationMode) {
this.authenticationMode = authenticationMode;
return this;
}

@Nullable
public String getAccessKey() {
return this.accessKey;
}

@Nullable
public String getAccessSecret() {
return this.accessSecret;
}
Expand All @@ -68,18 +85,21 @@ public String getTopicArn() {
return this.topicArn;
}

@Nullable
public com.commercetools.api.models.subscription.AwsAuthenticationMode getAuthenticationMode() {
return this.authenticationMode;
}

public SnsDestination build() {
Objects.requireNonNull(accessKey, SnsDestination.class + ": accessKey is missing");
Objects.requireNonNull(accessSecret, SnsDestination.class + ": accessSecret is missing");
Objects.requireNonNull(topicArn, SnsDestination.class + ": topicArn is missing");
return new SnsDestinationImpl(accessKey, accessSecret, topicArn);
return new SnsDestinationImpl(accessKey, accessSecret, topicArn, authenticationMode);
}

/**
* builds SnsDestination without checking for non null required values
*/
public SnsDestination buildUnchecked() {
return new SnsDestinationImpl(accessKey, accessSecret, topicArn);
return new SnsDestinationImpl(accessKey, accessSecret, topicArn, authenticationMode);
}

public static SnsDestinationBuilder of() {
Expand All @@ -91,6 +111,7 @@ public static SnsDestinationBuilder of(final SnsDestination template) {
builder.accessKey = template.getAccessKey();
builder.accessSecret = template.getAccessSecret();
builder.topicArn = template.getTopicArn();
builder.authenticationMode = template.getAuthenticationMode();
return builder;
}

Expand Down
Expand Up @@ -28,12 +28,16 @@ public class SnsDestinationImpl implements SnsDestination, ModelBase {

private String topicArn;

private com.commercetools.api.models.subscription.AwsAuthenticationMode authenticationMode;

@JsonCreator
SnsDestinationImpl(@JsonProperty("accessKey") final String accessKey,
@JsonProperty("accessSecret") final String accessSecret, @JsonProperty("topicArn") final String topicArn) {
@JsonProperty("accessSecret") final String accessSecret, @JsonProperty("topicArn") final String topicArn,
@JsonProperty("authenticationMode") final com.commercetools.api.models.subscription.AwsAuthenticationMode authenticationMode) {
this.accessKey = accessKey;
this.accessSecret = accessSecret;
this.topicArn = topicArn;
this.authenticationMode = authenticationMode;
this.type = SNS;
}

Expand All @@ -50,15 +54,15 @@ public String getType() {
}

/**
*
* <p>Only present if <code>authenticationMode</code> is set to <code>Credentials</code>.</p>
*/

public String getAccessKey() {
return this.accessKey;
}

/**
*
* <p>Only present if <code>authenticationMode</code> is set to <code>Credentials</code>.</p>
*/

public String getAccessSecret() {
Expand All @@ -73,6 +77,14 @@ public String getTopicArn() {
return this.topicArn;
}

/**
* <p>Defines the method of authentication for the SNS topic.</p>
*/

public com.commercetools.api.models.subscription.AwsAuthenticationMode getAuthenticationMode() {
return this.authenticationMode;
}

public void setAccessKey(final String accessKey) {
this.accessKey = accessKey;
}
Expand All @@ -85,6 +97,11 @@ public void setTopicArn(final String topicArn) {
this.topicArn = topicArn;
}

public void setAuthenticationMode(
final com.commercetools.api.models.subscription.AwsAuthenticationMode authenticationMode) {
this.authenticationMode = authenticationMode;
}

@Override
public boolean equals(Object o) {
if (this == o)
Expand All @@ -99,6 +116,7 @@ public boolean equals(Object o) {
.append(accessKey, that.accessKey)
.append(accessSecret, that.accessSecret)
.append(topicArn, that.topicArn)
.append(authenticationMode, that.authenticationMode)
.isEquals();
}

Expand All @@ -108,6 +126,7 @@ public int hashCode() {
.append(accessKey)
.append(accessSecret)
.append(topicArn)
.append(authenticationMode)
.toHashCode();
}

Expand Down
Expand Up @@ -20,8 +20,6 @@
* <div class=code-example>
* <pre><code class='java'>
* SqsDestination sqsDestination = SqsDestination.builder()
* .accessKey("{accessKey}")
* .accessSecret("{accessSecret}")
* .queueUrl("{queueUrl}")
* .region("{region}")
* .build()
Expand All @@ -35,16 +33,16 @@ public interface SqsDestination extends Destination {
String SQS = "SQS";

/**
*
* <p>Only present if <code>authenticationMode</code> is set to <code>Credentials</code>.</p>
*/
@NotNull

@JsonProperty("accessKey")
public String getAccessKey();

/**
*
* <p>Only present if <code>authenticationMode</code> is set to <code>Credentials</code>.</p>
*/
@NotNull

@JsonProperty("accessSecret")
public String getAccessSecret();

Expand All @@ -62,6 +60,13 @@ public interface SqsDestination extends Destination {
@JsonProperty("region")
public String getRegion();

/**
* <p>Defines the method of authentication for the SQS queue.</p>
*/

@JsonProperty("authenticationMode")
public AwsAuthenticationMode getAuthenticationMode();

public void setAccessKey(final String accessKey);

public void setAccessSecret(final String accessSecret);
Expand All @@ -70,6 +75,8 @@ public interface SqsDestination extends Destination {

public void setRegion(final String region);

public void setAuthenticationMode(final AwsAuthenticationMode authenticationMode);

public static SqsDestination of() {
return new SqsDestinationImpl();
}
Expand All @@ -80,6 +87,7 @@ public static SqsDestination of(final SqsDestination template) {
instance.setAccessSecret(template.getAccessSecret());
instance.setQueueUrl(template.getQueueUrl());
instance.setRegion(template.getRegion());
instance.setAuthenticationMode(template.getAuthenticationMode());
return instance;
}

Expand Down

0 comments on commit 1b37525

Please sign in to comment.