-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style: Configure Spotless formatter (#45)
- Loading branch information
Showing
30 changed files
with
5,409 additions
and
5,488 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
package io.qdrant.client; | ||
|
||
import java.util.concurrent.Executor; | ||
|
||
import io.grpc.CallCredentials; | ||
import io.grpc.Metadata; | ||
import io.grpc.Status; | ||
import java.util.concurrent.Executor; | ||
|
||
/** | ||
* API key authentication credentials | ||
*/ | ||
/** API key authentication credentials */ | ||
public class ApiKeyCredentials extends CallCredentials { | ||
private final String apiKey; | ||
private final String apiKey; | ||
|
||
/** | ||
* Instantiates a new instance of {@link ApiKeyCredentials} | ||
* @param apiKey The API key to use for authentication | ||
*/ | ||
public ApiKeyCredentials(String apiKey) { | ||
this.apiKey = apiKey; | ||
} | ||
/** | ||
* Instantiates a new instance of {@link ApiKeyCredentials} | ||
* | ||
* @param apiKey The API key to use for authentication | ||
*/ | ||
public ApiKeyCredentials(String apiKey) { | ||
this.apiKey = apiKey; | ||
} | ||
|
||
@Override | ||
public void applyRequestMetadata(RequestInfo requestInfo, Executor appExecutor, MetadataApplier applier) { | ||
appExecutor.execute(() -> { | ||
try { | ||
Metadata headers = new Metadata(); | ||
headers.put(Metadata.Key.of("api-key", Metadata.ASCII_STRING_MARSHALLER), apiKey); | ||
applier.apply(headers); | ||
} catch (Throwable e) { | ||
applier.fail(Status.UNAUTHENTICATED.withCause(e)); | ||
} | ||
@Override | ||
public void applyRequestMetadata( | ||
RequestInfo requestInfo, Executor appExecutor, MetadataApplier applier) { | ||
appExecutor.execute( | ||
() -> { | ||
try { | ||
Metadata headers = new Metadata(); | ||
headers.put(Metadata.Key.of("api-key", Metadata.ASCII_STRING_MARSHALLER), apiKey); | ||
applier.apply(headers); | ||
} catch (Throwable e) { | ||
applier.fail(Status.UNAUTHENTICATED.withCause(e)); | ||
} | ||
}); | ||
} | ||
} | ||
} |
Oops, something went wrong.