-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3dbf1f6
commit 5f34859
Showing
5 changed files
with
132 additions
and
85 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
39 changes: 37 additions & 2 deletions
39
js/packages/quary-extension/src/web/servicesDatabaseBigQuery.ts
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,6 +1,41 @@ | ||
import { BigQueryBase } from '@shared/databaseBigQuery' | ||
import { | ||
BigQueryBase, | ||
BigQueryOptions, | ||
BigQueryBaseWithLocation, | ||
} from '@shared/databaseBigQuery' | ||
import { SourcesLister } from '@shared/database' | ||
import { Err, ErrorCodes, Ok, Result } from '@shared/result' | ||
import * as vscode from 'vscode' | ||
|
||
const getAccessToken = async () => { | ||
const session = await vscode.authentication.getSession('quaryBigQuery', [], { | ||
createIfNone: true, | ||
}) | ||
if (!session) { | ||
return Err({ | ||
code: ErrorCodes.INTERNAL, | ||
message: 'Failed to get BigQuery session', | ||
}) | ||
} | ||
return Ok(session.accessToken) | ||
} | ||
|
||
export class BigQueryOAuth extends BigQueryBaseWithLocation { | ||
readonly projectId: string | ||
readonly datasetId: string | ||
|
||
constructor(options: BigQueryOptions) { | ||
super(options) | ||
this.projectId = options.projectId | ||
this.datasetId = options.datasetId | ||
} | ||
|
||
getAccessToken = async (): Promise<Result<string>> => getAccessToken() | ||
} | ||
|
||
export class BigQueryOauthHeadless | ||
extends BigQueryBase | ||
implements SourcesLister {} | ||
implements SourcesLister | ||
{ | ||
getAccessToken = () => getAccessToken() | ||
} |
51 changes: 49 additions & 2 deletions
51
js/packages/quary-extension/src/web/servicesDatabaseSnowflake.ts
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,4 +1,51 @@ | ||
import { SnowflakeBase } from '@shared/databaseSnowflake' | ||
import { | ||
SnowflakeOptions, | ||
SnowflakeBaseWithLocation, | ||
SnowflakeBase, | ||
} from '@shared/databaseSnowflake' | ||
import { SourcesLister } from '@shared/database' | ||
import { Err, ErrorCodes, Ok, Result } from '@shared/result' | ||
import * as vscode from 'vscode' | ||
|
||
export class SnowflakeHeadless extends SnowflakeBase implements SourcesLister {} | ||
const getAccessToken = async ( | ||
accountUrl: string, | ||
clientId: string, | ||
clientSecret: string, | ||
role: string, | ||
): Promise<Result<string>> => { | ||
const session = await vscode.authentication.getSession( | ||
'quarySnowflake', | ||
[accountUrl, clientId, clientSecret, role], | ||
{ | ||
createIfNone: true, | ||
}, | ||
) | ||
if (!session) { | ||
return Err({ | ||
code: ErrorCodes.INTERNAL, | ||
message: 'Unable to authenticate with Snowflake.', | ||
}) | ||
} | ||
return Ok(session.accessToken) | ||
} | ||
|
||
export class Snowflake extends SnowflakeBaseWithLocation { | ||
readonly database: string | ||
readonly schema: string | ||
readonly warehouse: string | ||
|
||
constructor(options: SnowflakeOptions) { | ||
super(options) | ||
this.database = options.database | ||
this.schema = options.schema | ||
this.warehouse = options.warehouse | ||
} | ||
|
||
getAccessToken = async (): Promise<Result<string>> => | ||
getAccessToken(this.accountUrl, this.clientId, this.clientSecret, this.role) | ||
} | ||
|
||
export class SnowflakeHeadless extends SnowflakeBase implements SourcesLister { | ||
getAccessToken = () => | ||
getAccessToken(this.accountUrl, this.clientId, this.clientSecret, this.role) | ||
} |