Skip to content

Commit b9184c5

Browse files
authored
feat: Support for token based authentication and no auth rest calls (#587)
Support for token based authentication and no auth rest calls <!-- We appreciate the effort for this pull request but before that please make sure you read the contribution guidelines, then fill out the blanks below. Please format the PR title appropriately based on the type of change: <type>[!]: <description> Where <type> is one of: docs, chore, feat, fix, test, misc. Add a '!' after the type for breaking changes (e.g. feat!: new breaking feature). **All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.** Please enter each Issue number you are resolving in your PR after one of the following words [Fixes, Closes, Resolves]. This will auto-link these issues and close them when this PR is merged! e.g. Fixes #1 Closes #2 --> # Fixes # A short description of what this PR does. Updating mustache files to use bearer token/ no auth request and rest clients in appropriate cases ### Checklist - [x] I acknowledge that all my contributions will be made under the project's license - [ ] Run `make test-docker` - [ ] Verify affected language: - [ ] Generate [twilio-go](https://github.com/twilio/twilio-go) from our [OpenAPI specification](https://github.com/twilio/twilio-oai) using the [build_twilio_go.py](./examples/build_twilio_go.py) using `python examples/build_twilio_go.py path/to/twilio-oai/spec/yaml path/to/twilio-go` and inspect the diff - [ ] Run `make test` in `twilio-go` - [ ] Create a pull request in `twilio-go` - [ ] Provide a link below to the pull request - [ ] I have made a material change to the repo (functionality, testing, spelling, grammar) - [ ] I have read the [Contribution Guidelines](https://github.com/twilio/twilio-oai-generator/blob/main/CONTRIBUTING.md) and my PR follows them - [ ] I have titled the PR appropriately - [ ] I have updated my branch with the main branch - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added the necessary documentation about the functionality in the appropriate .md file - [ ] I have added inline documentation to the code I modified If you have questions, please create a GitHub Issue in this repository. <!-- We appreciate the effort for this pull request but before that please make sure you read the contribution guidelines, then fill out the blanks below. Please format the PR title appropriately based on the type of change: <type>[!]: <description> Where <type> is one of: docs, chore, feat, fix, test, misc. Add a '!' after the type for breaking changes (e.g. feat!: new breaking feature). **All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.** Please enter each Issue number you are resolving in your PR after one of the following words [Fixes, Closes, Resolves]. This will auto-link these issues and close them when this PR is merged! e.g. Fixes #1 Closes #2 --> # Fixes # A short description of what this PR does. ### Checklist - [x] I acknowledge that all my contributions will be made under the project's license - [ ] Run `make test-docker` - [ ] Verify affected language: - [ ] Generate [twilio-go](https://github.com/twilio/twilio-go) from our [OpenAPI specification](https://github.com/twilio/twilio-oai) using the [build_twilio_go.py](./examples/build_twilio_go.py) using `python examples/build_twilio_go.py path/to/twilio-oai/spec/yaml path/to/twilio-go` and inspect the diff - [ ] Run `make test` in `twilio-go` - [ ] Create a pull request in `twilio-go` - [ ] Provide a link below to the pull request - [ ] I have made a material change to the repo (functionality, testing, spelling, grammar) - [ ] I have read the [Contribution Guidelines](https://github.com/twilio/twilio-oai-generator/blob/main/CONTRIBUTING.md) and my PR follows them - [ ] I have titled the PR appropriately - [ ] I have updated my branch with the main branch - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added the necessary documentation about the functionality in the appropriate .md file - [ ] I have added inline documentation to the code I modified If you have questions, please create a GitHub Issue in this repository.
1 parent d10da1a commit b9184c5

36 files changed

+1678
-179
lines changed

examples/java/src/main/java/com/twilio/rest/api/v2010/AccountCreator.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package com.twilio.rest.api.v2010;
1616

1717
import com.fasterxml.jackson.databind.ObjectMapper;
18-
import com.twilio.base.Creator;
1918
import com.twilio.constant.EnumConstants;
2019
import com.twilio.converter.Promoter;
2120
import com.twilio.exception.ApiConnectionException;
@@ -24,9 +23,7 @@
2423
import com.twilio.exception.ApiException;
2524
import com.twilio.exception.RestException;
2625
import com.twilio.http.HttpMethod;
27-
import com.twilio.http.Request;
2826
import com.twilio.http.Response;
29-
import com.twilio.http.TwilioRestClient;
3027
import com.twilio.rest.Domains;
3128
import java.math.BigDecimal;
3229
import java.util.List;
@@ -52,6 +49,10 @@
5249

5350
import java.net.URI;
5451

52+
import com.twilio.base.Creator;
53+
import com.twilio.http.Request;
54+
import com.twilio.http.TwilioRestClient;
55+
5556
public class AccountCreator extends Creator<Account>{
5657
private Account.XTwilioWebhookEnabled xTwilioWebhookEnabled;
5758
private URI recordingStatusCallback;

examples/java/src/main/java/com/twilio/rest/api/v2010/AccountDeleter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package com.twilio.rest.api.v2010;
1616

1717
import com.fasterxml.jackson.databind.ObjectMapper;
18-
import com.twilio.base.Deleter;
1918
import com.twilio.converter.Promoter;
2019
import com.twilio.constant.EnumConstants;
2120
import com.twilio.exception.ApiConnectionException;
@@ -24,9 +23,7 @@
2423
import com.twilio.converter.Converter;
2524
import com.twilio.exception.RestException;
2625
import com.twilio.http.HttpMethod;
27-
import com.twilio.http.Request;
2826
import com.twilio.http.Response;
29-
import com.twilio.http.TwilioRestClient;
3027
import com.twilio.rest.Domains;
3128
import java.time.LocalDate;
3229
import java.io.IOException;
@@ -45,6 +42,10 @@
4542

4643
import lombok.ToString;
4744

45+
import com.twilio.base.Deleter;
46+
import com.twilio.http.Request;
47+
import com.twilio.http.TwilioRestClient;
48+
4849
public class AccountDeleter extends Deleter<Account> {
4950
private String pathSid;
5051

examples/java/src/main/java/com/twilio/rest/api/v2010/AccountFetcher.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package com.twilio.rest.api.v2010;
1616

1717
import com.fasterxml.jackson.databind.ObjectMapper;
18-
import com.twilio.base.Fetcher;
1918
import com.twilio.constant.EnumConstants;
2019
import com.twilio.converter.Promoter;
2120
import com.twilio.exception.ApiConnectionException;
@@ -24,9 +23,7 @@
2423
import com.twilio.exception.ApiException;
2524
import com.twilio.exception.RestException;
2625
import com.twilio.http.HttpMethod;
27-
import com.twilio.http.Request;
2826
import com.twilio.http.Response;
29-
import com.twilio.http.TwilioRestClient;
3027
import com.twilio.rest.Domains;
3128

3229
import java.io.IOException;
@@ -46,6 +43,10 @@
4643

4744
import lombok.ToString;
4845

46+
import com.twilio.base.Fetcher;
47+
import com.twilio.http.Request;
48+
import com.twilio.http.TwilioRestClient;
49+
4950
public class AccountFetcher extends Fetcher<Account> {
5051
private String pathSid;
5152

@@ -71,7 +72,7 @@ public Account fetch(final TwilioRestClient client) {
7172
Response response = client.request(request);
7273

7374
if (response == null) {
74-
throw new ApiConnectionException("Account fetch failed: Unable to connect to server");
75+
throw new ApiConnectionException("Account fetch failed: Unable to connect to server");
7576
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
7677
RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
7778
if (restException == null) {

examples/java/src/main/java/com/twilio/rest/api/v2010/AccountReader.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,16 @@
1515
package com.twilio.rest.api.v2010;
1616

1717
import com.fasterxml.jackson.databind.ObjectMapper;
18-
import com.twilio.base.Reader;
1918
import com.twilio.constant.EnumConstants;
20-
import com.twilio.base.ResourceSet;
2119
import com.twilio.converter.Promoter;
2220
import com.twilio.exception.ApiConnectionException;
2321
import com.twilio.converter.PrefixedCollapsibleMap;
2422
import com.twilio.converter.Converter;
2523
import com.twilio.exception.ApiException;
2624
import com.twilio.exception.RestException;
2725
import com.twilio.http.HttpMethod;
28-
import com.twilio.http.Request;
2926
import com.twilio.http.Response;
30-
import com.twilio.http.TwilioRestClient;
3127
import com.twilio.rest.Domains;
32-
import com.twilio.base.Page;
3328
import java.time.LocalDate;
3429
import java.time.ZonedDateTime;
3530
import java.io.IOException;
@@ -47,6 +42,12 @@
4742

4843
import lombok.ToString;
4944

45+
import com.twilio.base.Page;
46+
import com.twilio.base.Reader;
47+
import com.twilio.base.ResourceSet;
48+
import com.twilio.http.Request;
49+
import com.twilio.http.TwilioRestClient;
50+
5051
public class AccountReader extends Reader<Account> {
5152
private ZonedDateTime dateCreated;
5253
private LocalDate dateTest;

examples/java/src/main/java/com/twilio/rest/api/v2010/AccountUpdater.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package com.twilio.rest.api.v2010;
1616

1717
import com.fasterxml.jackson.databind.ObjectMapper;
18-
import com.twilio.base.Updater;
1918
import com.twilio.constant.EnumConstants;
2019
import com.twilio.converter.Promoter;
2120
import com.twilio.exception.ApiConnectionException;
@@ -24,9 +23,7 @@
2423
import com.twilio.exception.ApiException;
2524
import com.twilio.exception.RestException;
2625
import com.twilio.http.HttpMethod;
27-
import com.twilio.http.Request;
2826
import com.twilio.http.Response;
29-
import com.twilio.http.TwilioRestClient;
3027
import com.twilio.rest.Domains;
3128
import java.time.format.DateTimeFormatter;
3229
import com.twilio.converter.DateConverter;
@@ -46,6 +43,11 @@
4643

4744
import lombok.ToString;
4845

46+
import com.twilio.base.Updater;
47+
import com.twilio.http.Request;
48+
import com.twilio.http.TwilioRestClient;
49+
50+
4951
public class AccountUpdater extends Updater<Account>{
5052
private Account.Status status;
5153
private String pathSid;
@@ -96,6 +98,7 @@ public Account update(final TwilioRestClient client){
9698

9799
return Account.fromJson(response.getStream(), client.getObjectMapper());
98100
}
101+
99102
private void addPostParams(final Request request) {
100103
if (pauseBehavior != null) {
101104
request.addPostParam("PauseBehavior", pauseBehavior);

examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallCreator.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package com.twilio.rest.api.v2010.account;
1616

1717
import com.fasterxml.jackson.databind.ObjectMapper;
18-
import com.twilio.base.Creator;
1918
import com.twilio.constant.EnumConstants;
2019
import com.twilio.converter.Promoter;
2120
import com.twilio.exception.ApiConnectionException;
@@ -24,9 +23,7 @@
2423
import com.twilio.exception.ApiException;
2524
import com.twilio.exception.RestException;
2625
import com.twilio.http.HttpMethod;
27-
import com.twilio.http.Request;
2826
import com.twilio.http.Response;
29-
import com.twilio.http.TwilioRestClient;
3027
import com.twilio.rest.Domains;
3128
import java.math.BigDecimal;
3229
import java.util.List;
@@ -52,6 +49,10 @@
5249

5350
import java.net.URI;
5451

52+
import com.twilio.base.Creator;
53+
import com.twilio.http.Request;
54+
import com.twilio.http.TwilioRestClient;
55+
5556
public class CallCreator extends Creator<Call>{
5657
private String requiredStringProperty;
5758
private HttpMethod testMethod;

examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallDeleter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package com.twilio.rest.api.v2010.account;
1616

1717
import com.fasterxml.jackson.databind.ObjectMapper;
18-
import com.twilio.base.Deleter;
1918
import com.twilio.converter.Promoter;
2019
import com.twilio.constant.EnumConstants;
2120
import com.twilio.exception.ApiConnectionException;
@@ -24,9 +23,7 @@
2423
import com.twilio.converter.Converter;
2524
import com.twilio.exception.RestException;
2625
import com.twilio.http.HttpMethod;
27-
import com.twilio.http.Request;
2826
import com.twilio.http.Response;
29-
import com.twilio.http.TwilioRestClient;
3027
import com.twilio.rest.Domains;
3128
import java.time.LocalDate;
3229
import java.io.IOException;
@@ -45,6 +42,10 @@
4542

4643
import lombok.ToString;
4744

45+
import com.twilio.base.Deleter;
46+
import com.twilio.http.Request;
47+
import com.twilio.http.TwilioRestClient;
48+
4849
public class CallDeleter extends Deleter<Call> {
4950
private Integer pathTestInteger;
5051
private String pathAccountSid;

examples/java/src/main/java/com/twilio/rest/api/v2010/account/CallFetcher.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package com.twilio.rest.api.v2010.account;
1616

1717
import com.fasterxml.jackson.databind.ObjectMapper;
18-
import com.twilio.base.Fetcher;
1918
import com.twilio.constant.EnumConstants;
2019
import com.twilio.converter.Promoter;
2120
import com.twilio.exception.ApiConnectionException;
@@ -24,9 +23,7 @@
2423
import com.twilio.exception.ApiException;
2524
import com.twilio.exception.RestException;
2625
import com.twilio.http.HttpMethod;
27-
import com.twilio.http.Request;
2826
import com.twilio.http.Response;
29-
import com.twilio.http.TwilioRestClient;
3027
import com.twilio.rest.Domains;
3128

3229
import java.io.IOException;
@@ -46,6 +43,10 @@
4643

4744
import lombok.ToString;
4845

46+
import com.twilio.base.Fetcher;
47+
import com.twilio.http.Request;
48+
import com.twilio.http.TwilioRestClient;
49+
4950
public class CallFetcher extends Fetcher<Call> {
5051
private Integer pathTestInteger;
5152
private String pathAccountSid;
@@ -75,7 +76,7 @@ public Call fetch(final TwilioRestClient client) {
7576
Response response = client.request(request);
7677

7778
if (response == null) {
78-
throw new ApiConnectionException("Call fetch failed: Unable to connect to server");
79+
throw new ApiConnectionException("Call fetch failed: Unable to connect to server");
7980
} else if (!TwilioRestClient.SUCCESS.test(response.getStatusCode())) {
8081
RestException restException = RestException.fromJson(response.getStream(), client.getObjectMapper());
8182
if (restException == null) {

examples/java/src/main/java/com/twilio/rest/api/v2010/account/call/FeedbackCallSummaryUpdater.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package com.twilio.rest.api.v2010.account.call;
1616

1717
import com.fasterxml.jackson.databind.ObjectMapper;
18-
import com.twilio.base.Updater;
1918
import com.twilio.constant.EnumConstants;
2019
import com.twilio.converter.Promoter;
2120
import com.twilio.exception.ApiConnectionException;
@@ -24,9 +23,7 @@
2423
import com.twilio.exception.ApiException;
2524
import com.twilio.exception.RestException;
2625
import com.twilio.http.HttpMethod;
27-
import com.twilio.http.Request;
2826
import com.twilio.http.Response;
29-
import com.twilio.http.TwilioRestClient;
3027
import com.twilio.rest.Domains;
3128
import java.time.format.DateTimeFormatter;
3229
import com.twilio.converter.DateConverter;
@@ -46,6 +43,11 @@
4643

4744
import lombok.ToString;
4845

46+
import com.twilio.base.Updater;
47+
import com.twilio.http.Request;
48+
import com.twilio.http.TwilioRestClient;
49+
50+
4951
public class FeedbackCallSummaryUpdater extends Updater<FeedbackCallSummary>{
5052
private String pathSid;
5153
private LocalDate endDate;
@@ -108,6 +110,7 @@ public FeedbackCallSummary update(final TwilioRestClient client){
108110

109111
return FeedbackCallSummary.fromJson(response.getStream(), client.getObjectMapper());
110112
}
113+
111114
private void addPostParams(final Request request) {
112115
if (accountSid != null) {
113116
request.addPostParam("AccountSid", accountSid);

examples/java/src/main/java/com/twilio/rest/flexapi/v1/CallUpdater.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package com.twilio.rest.flexapi.v1;
1616

1717
import com.fasterxml.jackson.databind.ObjectMapper;
18-
import com.twilio.base.Updater;
1918
import com.twilio.constant.EnumConstants;
2019
import com.twilio.converter.Promoter;
2120
import com.twilio.exception.ApiConnectionException;
@@ -24,9 +23,7 @@
2423
import com.twilio.exception.ApiException;
2524
import com.twilio.exception.RestException;
2625
import com.twilio.http.HttpMethod;
27-
import com.twilio.http.Request;
2826
import com.twilio.http.Response;
29-
import com.twilio.http.TwilioRestClient;
3027
import com.twilio.rest.Domains;
3128
import java.time.format.DateTimeFormatter;
3229
import com.twilio.converter.DateConverter;
@@ -46,6 +43,11 @@
4643

4744
import lombok.ToString;
4845

46+
import com.twilio.base.Updater;
47+
import com.twilio.http.Request;
48+
import com.twilio.http.TwilioRestClient;
49+
50+
4951
public class CallUpdater extends Updater<Call>{
5052
private String pathSid;
5153

@@ -78,4 +80,5 @@ public Call update(final TwilioRestClient client){
7880

7981
return Call.fromJson(response.getStream(), client.getObjectMapper());
8082
}
83+
8184
}

0 commit comments

Comments
 (0)