Skip to content

Commit

Permalink
Pull request update/241223
Browse files Browse the repository at this point in the history
627c2c8 OS-8080. Remove logs
55226ab Aapp initialization feature
  • Loading branch information
stanfra authored Dec 23, 2024
2 parents ce5e43e + 627c2c8 commit 62f1d6c
Show file tree
Hide file tree
Showing 199 changed files with 2,968 additions and 2,564 deletions.
1 change: 0 additions & 1 deletion auth/auth_server/handlers/v2/signin.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ async def post(self, **url_params):
data = self._request_body()
data.update(url_params)
data.update({'ip': self.get_ip_addr()})
data.update({'redirect_uri': self.request.headers.get('Origin')})
await self._validate_params(**data)
res = await run_task(self.controller.signin, **data)
self.set_status(201)
Expand Down
7 changes: 5 additions & 2 deletions ngui/server/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ KEEPER_ENDPOINT=
# Slacker endpoint. Used for endpoints that are migrated to Apollo.
SLACKER_ENDPOINT=

# Rest endpoint. Used for endpoints that are migrated to Apollo.
REST_ENDPOINT=
# Restapi endpoint. Used for endpoints that are migrated to Apollo.
RESTAPI_ENDPOINT=

# Auth endpoint. Used for endpoints that are migrated to Apollo.
AUTH_ENDPOINT=

# Helps distinguish environments with the same values for NODE_ENV/import.meta.env/etc., because they are built similarly/identically (e.g., with k8s).
# Can be any desired value, e.g., 'staging', 'production', etc.
Expand Down
77 changes: 77 additions & 0 deletions ngui/server/api/auth/client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import BaseClient from "../baseClient.js";
import {
MutationTokenArgs,
MutationUpdateUserArgs,
OrganizationAllowedActionsRequestParams,
} from "../../graphql/resolvers/auth.generated.js";

class AuthClient extends BaseClient {
override baseURL = `${process.env.AUTH_ENDPOINT || this.endpoint}/auth/v2/`;

async getOrganizationAllowedActions(
requestParams: OrganizationAllowedActionsRequestParams
) {
const path = `allowed_actions?organization=${requestParams.organization}`;
const actions = await this.get(path);

return actions.allowed_actions;
}

async createToken({ email, password, code }: MutationTokenArgs) {
const result = await this.post("tokens", {
body: { email, password, verification_code: code },
});

return {
token: result.token,
user_email: result.user_email,
user_id: result.user_id,
};
}

async createUser(email, password, name) {
const result = await this.post("users", {
body: { email, password, display_name: name },
});

return {
token: result.token,
user_email: result.email,
user_id: result.id,
};
}

async updateUser(
userId: MutationUpdateUserArgs["id"],
params: MutationUpdateUserArgs["params"]
) {
const result = await this.patch(`users/${userId}`, {
body: { display_name: params.name, password: params.password },
});

return {
token: result.token,
user_email: result.email,
user_id: result.id,
};
}

async signIn(provider, token, tenantId, redirectUri) {
const result = await this.post("signin", {
body: {
provider,
token,
tenant_id: tenantId,
redirect_uri: redirectUri,
},
});

return {
token: result.token,
user_email: result.user_email,
user_id: result.user_id,
};
}
}

export default AuthClient;
207 changes: 202 additions & 5 deletions ngui/server/api/restapi/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,44 @@ import BaseClient from "../baseClient.js";
import {
DataSourceRequestParams,
MutationUpdateEmployeeEmailsArgs,
UpdateDataSourceInput,
MutationUpdateEmployeeEmailArgs,
MutationCreateDataSourceArgs,
MutationUpdateDataSourceArgs,
MutationUpdateOrganizationArgs,
MutationCreateOrganizationArgs,
MutationDeleteOrganizationArgs,
MutationUpdateOptscaleModeArgs,
MutationUpdateOrganizationPerspectivesArgs,
QueryOrganizationPerspectivesArgs,
QueryOrganizationFeaturesArgs,
} from "../../graphql/resolvers/restapi.generated.js";

class RestClient extends BaseClient {
class RestApiClient extends BaseClient {
override baseURL = `${
process.env.REST_ENDPOINT || this.endpoint
process.env.RESTAPI_ENDPOINT || this.endpoint
}/restapi/v2/`;

async getOrganizations() {
const organizations = await this.get("organizations");

return organizations.organizations;
}

async getCurrentEmployee(organizationId: string) {
const path = `organizations/${organizationId}/employees?current_only=true`;
const currentEmployee = await this.get(path);

return currentEmployee.employees[0];
}

async getDataSources(organizationId: string) {
const path = `organizations/${organizationId}/cloud_accounts?details=true`;

const dataSources = await this.get(path);

return dataSources.cloud_accounts;
}

async getDataSource(
dataSourceId: string,
requestParams: DataSourceRequestParams
Expand All @@ -22,7 +51,37 @@ class RestClient extends BaseClient {
return dataSource;
}

async updateDataSource(dataSourceId, params: UpdateDataSourceInput) {
async createDataSource(
organizationId: MutationCreateDataSourceArgs["organizationId"],
params: MutationCreateDataSourceArgs["params"]
) {
const path = `organizations/${organizationId}/cloud_accounts`;

const dataSource = await this.post(path, {
body: {
name: params.name,
type: params.type,
config: {
...params.awsRootConfig,
...params.awsLinkedConfig,
...params.azureSubscriptionConfig,
...params.azureTenantConfig,
...params.gcpConfig,
...params.alibabaConfig,
...params.nebiusConfig,
...params.databricksConfig,
...params.k8sConfig,
},
},
});

return dataSource;
}

async updateDataSource(
dataSourceId: MutationUpdateDataSourceArgs["dataSourceId"],
params: MutationUpdateDataSourceArgs["params"]
) {
const path = `cloud_accounts/${dataSourceId}`;

const dataSource = await this.patch(path, {
Expand Down Expand Up @@ -90,6 +149,144 @@ class RestClient extends BaseClient {

return email;
}

async deleteDataSource(dataSourceId) {
const path = `cloud_accounts/${dataSourceId}`;

return await this.delete(path);
}

async getInvitations() {
const invitations = await this.get("invites");

return invitations.invites;
}

async updateInvitation(invitationId: string, action: string) {
const path = `invites/${invitationId}`;

return await this.patch(path, {
body: JSON.stringify({
action,
}),
});
}

async getOrganizationFeatures(
organizationId: QueryOrganizationFeaturesArgs["organizationId"]
) {
const path = `organizations/${organizationId}/options/features`;
const features = await this.get(path);

const parsedFeatures = JSON.parse(features.value);

return parsedFeatures;
}

async getOptscaleMode(organizationId: string) {
const path = `organizations/${organizationId}/options/optscale_mode`;
const mode = await this.get(path);

const parsedMode = JSON.parse(mode.value);

return parsedMode.value;
}

async updateOptscaleMode(
organizationId: MutationUpdateOptscaleModeArgs["organizationId"],
value: MutationUpdateOptscaleModeArgs["value"]
) {
const path = `organizations/${organizationId}/options/optscale_mode`;
const mode = await this.patch(path, {
body: {
value: JSON.stringify({
value,
}),
},
});

const parsedMode = JSON.parse(mode.value);

return parsedMode.value;
}

async getOrganizationThemeSettings(organizationId: string) {
const path = `organizations/${organizationId}/options/theme_settings`;
const settings = await this.get(path);

const parsedSettings = JSON.parse(settings.value);

return parsedSettings;
}

async updateOrganizationThemeSettings(organizationId, value) {
const themeSettings = await this.patch(
`organizations/${organizationId}/options/theme_settings`,
{
body: {
value: JSON.stringify(value),
},
}
);

const parsedThemeSettings = JSON.parse(themeSettings.value);

return parsedThemeSettings;
}

async getOrganizationPerspectives(
organizationId: QueryOrganizationPerspectivesArgs["organizationId"]
) {
const path = `organizations/${organizationId}/options/perspectives`;
const perspectives = await this.get(path);

const parsedPerspectives = JSON.parse(perspectives.value);

return parsedPerspectives;
}

async updateOrganizationPerspectives(
organizationId: MutationUpdateOrganizationPerspectivesArgs["organizationId"],
value: MutationUpdateOrganizationPerspectivesArgs["value"]
) {
const perspectives = await this.patch(
`organizations/${organizationId}/options/perspectives`,
{
body: {
value: JSON.stringify(value),
},
}
);

const parsedPerspectives = JSON.parse(perspectives.value);

return parsedPerspectives;
}

async createOrganization(
organizationName: MutationCreateOrganizationArgs["organizationName"]
) {
return await this.post("organizations", {
body: {
name: organizationName,
},
});
}

async updateOrganization(
organizationId: MutationUpdateOrganizationArgs["organizationId"],
params: MutationUpdateOrganizationArgs["params"]
) {
return await this.patch(`organizations/${organizationId}`, {
body: params,
});
}

async deleteOrganization(
organizationId: MutationDeleteOrganizationArgs["organizationId"]
) {
return await this.delete(`organizations/${organizationId}`);
}
}

export default RestClient;
export default RestApiClient;
2 changes: 1 addition & 1 deletion ngui/server/api/slacker/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SlackerClient extends BaseClient {

async connectSlackUser(secret) {
return this.post("connect_slack_user", {
body: JSON.stringify({ secret }),
body: { secret },
});
}
}
Expand Down
4 changes: 4 additions & 0 deletions ngui/server/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const config: CodegenConfig = {
},
},
},
"./graphql/resolvers/auth.generated.ts": {
schema: "./graphql/schemas/auth.graphql",
plugins: commonPlugins,
},
},
};

Expand Down
Loading

0 comments on commit 62f1d6c

Please sign in to comment.