Skip to content

Commit 8e959dd

Browse files
authored
fix: adds custom domain email support
Signed-off-by: nitish <[email protected]>
1 parent 21ff001 commit 8e959dd

File tree

35 files changed

+2144
-39
lines changed

35 files changed

+2144
-39
lines changed

.secrets.baseline

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2023-06-14T06:40:41Z",
6+
"generated_at": "2023-08-02T09:08:09Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -92,7 +92,7 @@
9292
"hashed_secret": "45ef428ffb0d89f2412db1cb133370f3900b0d58",
9393
"is_secret": false,
9494
"is_verified": false,
95-
"line_number": 31,
95+
"line_number": 36,
9696
"type": "Box Credentials",
9797
"verified_result": null
9898
}
@@ -102,13 +102,13 @@
102102
"hashed_secret": "776917ec7fd348ce384f3ea92c2e6a06eef86796",
103103
"is_secret": false,
104104
"is_verified": false,
105-
"line_number": 33,
105+
"line_number": 38,
106106
"type": "Box Credentials",
107107
"verified_result": null
108108
}
109109
]
110110
},
111-
"version": "0.13.1+ibm.47.dss",
111+
"version": "0.13.1+ibm.60.dss",
112112
"word_list": {
113113
"file": null,
114114
"hash": null

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ SDK Methods to consume
120120
- [Get Destination](#get-destination)
121121
- [Update Destination](#update-destination)
122122
- [Delete Destination](#delete-destination)
123+
- [Custom Domain_Name_verification](#custom-domain-name-verification)
123124
- [Push Destination APIs](#push-destination-apis)
124125
- [Create Destination tag subscription](#create-destination-tag-subscription)
125126
- [List Destination tag subscription](#list-destination-tag-subscription)
@@ -392,7 +393,25 @@ DeleteDestinationOptions deleteDestinationOptions = new DeleteDestinationOptions
392393

393394
Response<Void> response = eventNotificationsService.deleteDestination(deleteDestinationOptions).execute();
394395
```
396+
### Custom Domain Name Verification
395397

398+
After creation of the custom email destination with your domain name, make sure its validated for the right ownership.
399+
This can be done with SPF and DKIM verification.
400+
* Sender Policy Framework (SPF), which is used to authenticate the sender of an email. SPF specifies the mail servers that are allowed to send email for your domain.
401+
* DomainKeys Identified Mail (DKIM), which allows an organization to take responsibility for transmitting a message by signing it. DKIM allows
402+
the receiver to check the email that claimed to have come from a specific domain, is authorized by the owner of that domain.
403+
404+
```java
405+
UpdateVerifyDestinationOptions updateVerifyDestinationOptionsModel = new UpdateVerifyDestinationOptions.Builder()
406+
.instanceId(<instanceId>)
407+
.id(<destinationId>)
408+
.type(<verificationType>)
409+
.build();
410+
411+
Response<VerificationResponse> verificationResponse = service.updateVerifyDestination(updateVerifyDestinationOptionsModel).execute();
412+
VerificationResponse responseObj = verificationResponse.getResult();
413+
414+
```
396415
## Push Destination APIs
397416

398417
### Create Destination tag subscription

modules/event-notifications/src/main/java/com/ibm/cloud/eventnotifications/event_notifications/v1/EventNotifications.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
import com.ibm.cloud.eventnotifications.event_notifications.v1.model.UpdateDestinationOptions;
6565
import com.ibm.cloud.eventnotifications.event_notifications.v1.model.UpdateSourceOptions;
6666
import com.ibm.cloud.eventnotifications.event_notifications.v1.model.UpdateSubscriptionOptions;
67+
import com.ibm.cloud.eventnotifications.event_notifications.v1.model.UpdateVerifyDestinationOptions;
68+
import com.ibm.cloud.eventnotifications.event_notifications.v1.model.VerificationResponse;
6769
import com.ibm.cloud.sdk.core.http.RequestBuilder;
6870
import com.ibm.cloud.sdk.core.http.ResponseConverter;
6971
import com.ibm.cloud.sdk.core.http.ServiceCall;
@@ -697,6 +699,32 @@ public ServiceCall<Void> deleteDestination(DeleteDestinationOptions deleteDestin
697699
return createServiceCall(builder.build(), responseConverter);
698700
}
699701

702+
/**
703+
* Verify status of spf or dkim records of custom email.
704+
*
705+
* Verify status of spf or dkim records of custom email.
706+
*
707+
* @param updateVerifyDestinationOptions the {@link UpdateVerifyDestinationOptions} containing the options for the call
708+
* @return a {@link ServiceCall} with a result of type {@link VerificationResponse}
709+
*/
710+
public ServiceCall<VerificationResponse> updateVerifyDestination(UpdateVerifyDestinationOptions updateVerifyDestinationOptions) {
711+
com.ibm.cloud.sdk.core.util.Validator.notNull(updateVerifyDestinationOptions,
712+
"updateVerifyDestinationOptions cannot be null");
713+
Map<String, String> pathParamsMap = new HashMap<String, String>();
714+
pathParamsMap.put("instance_id", updateVerifyDestinationOptions.instanceId());
715+
pathParamsMap.put("id", updateVerifyDestinationOptions.id());
716+
RequestBuilder builder = RequestBuilder.patch(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/v1/instances/{instance_id}/destinations/{id}/verify", pathParamsMap));
717+
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("event_notifications", "v1", "updateVerifyDestination");
718+
for (Entry<String, String> header : sdkHeaders.entrySet()) {
719+
builder.header(header.getKey(), header.getValue());
720+
}
721+
builder.header("Accept", "application/json");
722+
builder.query("type", String.valueOf(updateVerifyDestinationOptions.type()));
723+
ResponseConverter<VerificationResponse> responseConverter =
724+
ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<VerificationResponse>() { }.getType());
725+
return createServiceCall(builder.build(), responseConverter);
726+
}
727+
700728
/**
701729
* Create a new tag subscription.
702730
*

modules/event-notifications/src/main/java/com/ibm/cloud/eventnotifications/event_notifications/v1/model/CreateDestinationOptions.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public interface Type {
5656
String IBMCOS = "ibmcos";
5757
/** push_huawei. */
5858
String PUSH_HUAWEI = "push_huawei";
59+
/** smtp_custom. */
60+
String SMTP_CUSTOM = "smtp_custom";
5961
}
6062

6163
protected String instanceId;
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
/*
2+
* (C) Copyright IBM Corp. 2023.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
package com.ibm.cloud.eventnotifications.event_notifications.v1.model;
14+
15+
import com.google.gson.annotations.SerializedName;
16+
import com.ibm.cloud.sdk.core.service.model.GenericModel;
17+
18+
/**
19+
* The DKIM attributes.
20+
*/
21+
public class DKIMAttributes extends GenericModel {
22+
23+
@SerializedName("public_key")
24+
protected String publicKey;
25+
protected String selector;
26+
protected String verification;
27+
28+
/**
29+
* Builder.
30+
*/
31+
public static class Builder {
32+
private String publicKey;
33+
private String selector;
34+
private String verification;
35+
36+
/**
37+
* Instantiates a new Builder from an existing DKIMAttributes instance.
38+
*
39+
* @param dkimAttributes the instance to initialize the Builder with
40+
*/
41+
private Builder(DKIMAttributes dkimAttributes) {
42+
this.publicKey = dkimAttributes.publicKey;
43+
this.selector = dkimAttributes.selector;
44+
this.verification = dkimAttributes.verification;
45+
}
46+
47+
/**
48+
* Instantiates a new builder.
49+
*/
50+
public Builder() {
51+
}
52+
53+
/**
54+
* Builds a DKIMAttributes.
55+
*
56+
* @return the new DKIMAttributes instance
57+
*/
58+
public DKIMAttributes build() {
59+
return new DKIMAttributes(this);
60+
}
61+
62+
/**
63+
* Set the publicKey.
64+
*
65+
* @param publicKey the publicKey
66+
* @return the DKIMAttributes builder
67+
*/
68+
public Builder publicKey(String publicKey) {
69+
this.publicKey = publicKey;
70+
return this;
71+
}
72+
73+
/**
74+
* Set the selector.
75+
*
76+
* @param selector the selector
77+
* @return the DKIMAttributes builder
78+
*/
79+
public Builder selector(String selector) {
80+
this.selector = selector;
81+
return this;
82+
}
83+
84+
/**
85+
* Set the verification.
86+
*
87+
* @param verification the verification
88+
* @return the DKIMAttributes builder
89+
*/
90+
public Builder verification(String verification) {
91+
this.verification = verification;
92+
return this;
93+
}
94+
}
95+
96+
protected DKIMAttributes() { }
97+
98+
protected DKIMAttributes(Builder builder) {
99+
publicKey = builder.publicKey;
100+
selector = builder.selector;
101+
verification = builder.verification;
102+
}
103+
104+
/**
105+
* New builder.
106+
*
107+
* @return a DKIMAttributes builder
108+
*/
109+
public Builder newBuilder() {
110+
return new Builder(this);
111+
}
112+
113+
/**
114+
* Gets the publicKey.
115+
*
116+
* dkim public key.
117+
*
118+
* @return the publicKey
119+
*/
120+
public String publicKey() {
121+
return publicKey;
122+
}
123+
124+
/**
125+
* Gets the selector.
126+
*
127+
* dkim selector.
128+
*
129+
* @return the selector
130+
*/
131+
public String selector() {
132+
return selector;
133+
}
134+
135+
/**
136+
* Gets the verification.
137+
*
138+
* dkim verification.
139+
*
140+
* @return the verification
141+
*/
142+
public String verification() {
143+
return verification;
144+
}
145+
}
146+

modules/event-notifications/src/main/java/com/ibm/cloud/eventnotifications/event_notifications/v1/model/Destination.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public interface Type {
5656
String IBMCOS = "ibmcos";
5757
/** push_huawei. */
5858
String PUSH_HUAWEI = "push_huawei";
59+
/** smtp_custom. */
60+
String SMTP_CUSTOM = "smtp_custom";
5961
}
6062

6163
protected String id;

modules/event-notifications/src/main/java/com/ibm/cloud/eventnotifications/event_notifications/v1/model/DestinationConfigOneOf.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* DestinationConfigOneOf.
2323
*
2424
* Classes which extend this class:
25+
* - DestinationConfigOneOfCustomDomainEmailDestinationConfig
2526
* - DestinationConfigOneOfWebhookDestinationConfig
2627
* - DestinationConfigOneOfFCMDestinationConfig
2728
* - DestinationConfigOneOfIOSDestinationConfig
@@ -48,6 +49,9 @@ public interface Verb {
4849
String POST = "post";
4950
}
5051

52+
protected String domain;
53+
protected DKIMAttributes dkim;
54+
protected SPFAttributes spf;
5155
protected String url;
5256
protected String verb;
5357
@SerializedName("custom_headers")
@@ -106,6 +110,39 @@ public interface Verb {
106110

107111
protected DestinationConfigOneOf() { }
108112

113+
/**
114+
* Gets the domain.
115+
*
116+
* Email Domain.
117+
*
118+
* @return the domain
119+
*/
120+
public String domain() {
121+
return domain;
122+
}
123+
124+
/**
125+
* Gets the dkim.
126+
*
127+
* The DKIM attributes.
128+
*
129+
* @return the dkim
130+
*/
131+
public DKIMAttributes dkim() {
132+
return dkim;
133+
}
134+
135+
/**
136+
* Gets the spf.
137+
*
138+
* The SPF attributes.
139+
*
140+
* @return the spf
141+
*/
142+
public SPFAttributes spf() {
143+
return spf;
144+
}
145+
109146
/**
110147
* Gets the url.
111148
*

0 commit comments

Comments
 (0)