Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java: Stop sharing one ApiClient between all Svix instances #1608

Merged
merged 1 commit into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased
* Libs/Java: Stop sharing one `ApiClient` between all `Svix` instances. Fixes a bug where multiple
independently instantiated `Svix` instances would always use the same base path and auth token.

## Version 1.45.0
* CLI **(New)**: New Rust-based CLI with support for all recent Svix functionality.
* Libs/Rust **(Breaking)**: Add `api::MessageAttemptListAttemptedMessagesOptions` and use it for
Expand Down
5 changes: 3 additions & 2 deletions java/lib/src/main/java/com/svix/Application.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.svix;

import com.svix.exceptions.ApiException;
import com.svix.internal.ApiClient;
import com.svix.internal.api.ApplicationApi;
import com.svix.models.ApplicationIn;
import com.svix.models.ApplicationOut;
Expand All @@ -10,8 +11,8 @@
public final class Application {
private final ApplicationApi api;

Application() {
api = new ApplicationApi();
Application(ApiClient apiClient) {
api = new ApplicationApi(apiClient);
}

public ListResponseApplicationOut list(final ApplicationListOptions options) throws ApiException {
Expand Down
5 changes: 3 additions & 2 deletions java/lib/src/main/java/com/svix/Authentication.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.svix;

import com.svix.exceptions.ApiException;
import com.svix.internal.ApiClient;
import com.svix.internal.api.AuthenticationApi;
import com.svix.models.AppPortalAccessIn;
import com.svix.models.AppPortalAccessOut;
Expand All @@ -9,8 +10,8 @@
public final class Authentication {
private final AuthenticationApi api;

Authentication() {
api = new AuthenticationApi();
Authentication(ApiClient apiClient) {
api = new AuthenticationApi(apiClient);
}

public AppPortalAccessOut appPortalAccess(final String appId, final AppPortalAccessIn appPortalAccessIn) throws ApiException {
Expand Down
5 changes: 3 additions & 2 deletions java/lib/src/main/java/com/svix/BackgroundTask.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package com.svix;

import com.svix.exceptions.ApiException;
import com.svix.internal.ApiClient;
import com.svix.internal.api.BackgroundTasksApi;
import com.svix.models.BackgroundTaskOut;
import com.svix.models.ListResponseBackgroundTaskOut;

public final class BackgroundTask {
private final BackgroundTasksApi api;

BackgroundTask() {
api = new BackgroundTasksApi();
BackgroundTask(ApiClient apiClient) {
api = new BackgroundTasksApi(apiClient);
}

public ListResponseBackgroundTaskOut list(final BackgroundTaskListOptions options) throws ApiException {
Expand Down
5 changes: 3 additions & 2 deletions java/lib/src/main/java/com/svix/Endpoint.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.svix;

import com.svix.exceptions.ApiException;
import com.svix.internal.ApiClient;
import com.svix.internal.api.EndpointApi;
import com.svix.models.EndpointHeadersIn;
import com.svix.models.EndpointHeadersOut;
Expand All @@ -23,8 +24,8 @@
public final class Endpoint {
private final EndpointApi api;

public Endpoint() {
api = new EndpointApi();
public Endpoint(ApiClient apiClient) {
api = new EndpointApi(apiClient);
}

public ListResponseEndpointOut list(final String appId, final EndpointListOptions options) throws ApiException {
Expand Down
5 changes: 3 additions & 2 deletions java/lib/src/main/java/com/svix/EventType.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.svix;

import com.svix.exceptions.ApiException;
import com.svix.internal.ApiClient;
import com.svix.internal.api.EventTypeApi;
import com.svix.models.EventTypeImportOpenApiIn;
import com.svix.models.EventTypeImportOpenApiOut;
Expand All @@ -13,8 +14,8 @@
public final class EventType {
private final EventTypeApi api;

public EventType() {
api = new EventTypeApi();
public EventType(ApiClient apiClient) {
api = new EventTypeApi(apiClient);
}

public ListResponseEventTypeOut list(final EventTypeListOptions options) throws ApiException {
Expand Down
5 changes: 3 additions & 2 deletions java/lib/src/main/java/com/svix/Integration.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.svix;

import com.svix.exceptions.ApiException;
import com.svix.internal.ApiClient;
import com.svix.internal.api.IntegrationApi;
import com.svix.models.IntegrationIn;
import com.svix.models.IntegrationOut;
Expand All @@ -11,8 +12,8 @@
public final class Integration {
private final IntegrationApi api;

public Integration() {
api = new IntegrationApi();
public Integration(ApiClient apiClient) {
api = new IntegrationApi(apiClient);
}

public ListResponseIntegrationOut list(final String appId, final IntegrationListOptions options) throws ApiException {
Expand Down
5 changes: 3 additions & 2 deletions java/lib/src/main/java/com/svix/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Map;

import com.svix.exceptions.ApiException;
import com.svix.internal.ApiClient;
import com.svix.internal.api.MessageApi;
import com.svix.models.ListResponseMessageOut;
import com.svix.models.MessageIn;
Expand All @@ -15,8 +16,8 @@
public final class Message {
private final MessageApi api;

Message() {
api = new MessageApi();
Message(ApiClient apiClient) {
api = new MessageApi(apiClient);
}

private static MessageIn messageInEmptyPayload() {
Expand Down
5 changes: 3 additions & 2 deletions java/lib/src/main/java/com/svix/MessageAttempt.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.HashSet;

import com.svix.exceptions.ApiException;
import com.svix.internal.ApiClient;
import com.svix.internal.api.MessageAttemptApi;
import com.svix.models.ListResponseEndpointMessageOut;
import com.svix.models.ListResponseMessageAttemptEndpointOut;
Expand All @@ -13,8 +14,8 @@
public final class MessageAttempt {
private final MessageAttemptApi api;

MessageAttempt() {
api = new MessageAttemptApi();
MessageAttempt(ApiClient apiClient) {
api = new MessageAttemptApi(apiClient);
}

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.svix;

import com.svix.exceptions.ApiException;
import com.svix.internal.ApiClient;
import com.svix.internal.api.WebhookEndpointApi;
import com.svix.models.OperationalWebhookEndpointIn;
import com.svix.models.OperationalWebhookEndpointOut;
Expand All @@ -12,8 +13,8 @@
public final class OperationalWebhookEndpoint {
private final WebhookEndpointApi api;

public OperationalWebhookEndpoint() {
api = new WebhookEndpointApi();
public OperationalWebhookEndpoint(ApiClient apiClient) {
api = new WebhookEndpointApi(apiClient);
}

public ListResponseOperationalWebhookEndpointOut list(final OperationalWebhookEndpointListOptions options) throws ApiException {
Expand Down
5 changes: 3 additions & 2 deletions java/lib/src/main/java/com/svix/Statistics.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.svix;

import com.svix.exceptions.ApiException;
import com.svix.internal.ApiClient;
import com.svix.internal.api.StatisticsApi;
import com.svix.models.AggregateEventTypesOut;
import com.svix.models.AppUsageStatsIn;
Expand All @@ -9,8 +10,8 @@
public class Statistics {
private final StatisticsApi api;

Statistics() {
api = new StatisticsApi();
Statistics(ApiClient apiClient) {
api = new StatisticsApi(apiClient);
}

public AppUsageStatsOut aggregateAppStats(final AppUsageStatsIn appUsageStatsIn, final PostOptions options) throws ApiException {
Expand Down
21 changes: 9 additions & 12 deletions java/lib/src/main/java/com/svix/Svix.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,20 @@ public Svix(final String token, final SvixOptions options) {
}
}


apiClient.setUserAgent(String.format("svix-libs/%s/java", Svix.VERSION));

HttpBearerAuth httpBearer = (HttpBearerAuth) apiClient.getAuthentication("HTTPBearer");
httpBearer.setBearerToken(token);

Configuration.setDefaultApiClient(apiClient);

application = new Application();
authentication = new Authentication();
endpoint = new Endpoint();
eventType = new EventType();
integration = new Integration();
message = new Message();
messageAttempt = new MessageAttempt();
statistics = new Statistics();
operationalWebhookEndpoint = new OperationalWebhookEndpoint();
application = new Application(apiClient);
authentication = new Authentication(apiClient);
endpoint = new Endpoint(apiClient);
eventType = new EventType(apiClient);
integration = new Integration(apiClient);
message = new Message(apiClient);
messageAttempt = new MessageAttempt(apiClient);
statistics = new Statistics(apiClient);
operationalWebhookEndpoint = new OperationalWebhookEndpoint(apiClient);
}

public Application getApplication() {
Expand Down