Skip to content

Commit

Permalink
feat: adds the Snowflake reader account user reactivation endpoint [U… (
Browse files Browse the repository at this point in the history
#860)

feat: adds the Snowflake reader account user reactivation endpoint [UA-9263]
  • Loading branch information
mpayne-coveo authored Sep 25, 2024
1 parent ffe3d5c commit ae11c6e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/resources/UsageAnalytics/Read/Snowflake/Snowflake.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ReadServiceResource from '../ReadServiceResource.js';
import {
GetCreditUsageParams,
ReactivateUserParams,
SnowflakeCreditUsageModel,
SnowflakeNetworkPolicyModel,
SnowflakeReaderAccountEndpointModel,
Expand All @@ -21,6 +22,8 @@ export default class Snowflake extends ReadServiceResource {

/**
* Create a new user within a Snowflake reader account.
*
* @param model The user to create.
*/
createUser(model: SnowflakeUserModel) {
return this.api.post<SnowflakeUserModel>(this.buildPathWithOrg(`${Snowflake.baseUrl}/users`), model);
Expand Down Expand Up @@ -53,6 +56,19 @@ export default class Snowflake extends ReadServiceResource {
return this.api.post<void>(this.buildPathWithOrg(`${Snowflake.baseUrl}/users/${snowflakeUser}/passwordreset`));
}

/**
* Reactivate and set a user's expiration in a Snowflake reader account.
*
* @param snowflakeUser The login name for the Snowflake user.
* @param params The number of days until the user's expiration date.
*/
reactivateUser(snowflakeUser: string, params: ReactivateUserParams) {
return this.api.put<void>(
this.buildPathWithOrg(`${Snowflake.baseUrl}/users/${snowflakeUser}/expiration`),
params,
);
}

/**
* Get the details of the active network policy for a Snowflake reader account.
*/
Expand All @@ -62,13 +78,17 @@ export default class Snowflake extends ReadServiceResource {

/**
* Set the details of the active network policy for a Snowflake reader account.
*
* @param model The network policy to create.
*/
updateNetworkPolicy(model: SnowflakeNetworkPolicyModel) {
return this.api.put<void>(this.buildPathWithOrg(`${Snowflake.baseUrl}/networkpolicy`), model);
}

/**
* Get the amount of compute credits used by a Snowflake reader account within a date range.
*
* @param params The time range to get the amount of compute credits.
*/
getCreditUsage(params: GetCreditUsageParams) {
return this.api.get<SnowflakeCreditUsageModel>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export interface SnowflakeUserModel {
daysToExpiry?: number;
}

export interface ReactivateUserParams {
daysToExpiry: number;
}

export interface SnowflakeNetworkPolicyModel {
allowedIpAddresses: string[];
blockedIpAddresses: string[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import API from '../../../../../APICore.js';
import Snowflake from '../Snowflake.js';
import {GetCreditUsageParams, SnowflakeNetworkPolicyModel, SnowflakeUserModel} from '../SnowflakeInterfaces.js';
import {
GetCreditUsageParams,
ReactivateUserParams,
SnowflakeNetworkPolicyModel,
SnowflakeUserModel,
} from '../SnowflakeInterfaces.js';

jest.mock('../../../../../APICore.js');

Expand Down Expand Up @@ -59,6 +64,19 @@ describe('Snowflake', () => {
});
});

describe('reactivateUser', () => {
it('makes a PUT call to the specific Snowflake url', () => {
const snowflakeUser = 'ross.blais';
const params: ReactivateUserParams = {
daysToExpiry: 66,
};
snowflake.reactivateUser(snowflakeUser, params);

expect(api.put).toHaveBeenCalledTimes(1);
expect(api.put).toHaveBeenCalledWith(`${Snowflake.baseUrl}/users/${snowflakeUser}/expiration`, params);
});
});

describe('resetPassword', () => {
it('makes a POST call to the specific Snowflake url', () => {
const snowflakeUser = 'ross.blais';
Expand Down

0 comments on commit ae11c6e

Please sign in to comment.