Skip to content

Commit

Permalink
Pull request update/241225
Browse files Browse the repository at this point in the history
2d4578a OS-8087. Fix data source connection issues
82266e3 OS-8087. Add project_id to GcpBillingDataConfigInput scheme
ed1f380 OS-8086. Fix gcp tenant connection and update forms
807d7c1 OS-8085. Display pool and organization names in the roles section on the Accept/Decline Invites page
c84413c OS-8054. [UI] Add support for gcp_tenant
c6c6442 OS-8019. GCP optimization & gcp tenant cloud accounts
  • Loading branch information
stanfra authored Dec 25, 2024
2 parents 62f1d6c + 2d4578a commit ba54625
Show file tree
Hide file tree
Showing 31 changed files with 654 additions and 72 deletions.
2 changes: 1 addition & 1 deletion diworker/diworker/importers/gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def detect_period_start(self):
if last_exp_date:
self.period_start = last_exp_date.replace(
hour=0, minute=0, second=0, microsecond=0) - timedelta(
days=1)
days=3)
if not self.period_start:
super().detect_period_start()

Expand Down
2 changes: 2 additions & 0 deletions ngui/server/api/restapi/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class RestApiClient extends BaseClient {
...params.azureSubscriptionConfig,
...params.azureTenantConfig,
...params.gcpConfig,
...params.gcpTenantConfig,
...params.alibabaConfig,
...params.nebiusConfig,
...params.databricksConfig,
Expand Down Expand Up @@ -95,6 +96,7 @@ class RestApiClient extends BaseClient {
...params.azureSubscriptionConfig,
...params.azureTenantConfig,
...params.gcpConfig,
...params.gcpTenantConfig,
...params.alibabaConfig,
...params.nebiusConfig,
...params.databricksConfig,
Expand Down
117 changes: 99 additions & 18 deletions ngui/server/graphql/resolvers/restapi.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export type CreateDataSourceInput = {
azureTenantConfig?: InputMaybe<AzureTenantConfigInput>;
databricksConfig?: InputMaybe<DatabricksConfigInput>;
gcpConfig?: InputMaybe<GcpConfigInput>;
gcpTenantConfig?: InputMaybe<GcpTenantConfigInput>;
k8sConfig?: InputMaybe<K8sConfigInput>;
name?: InputMaybe<Scalars['String']['input']>;
nebiusConfig?: InputMaybe<NebiusConfigInput>;
Expand Down Expand Up @@ -190,18 +191,18 @@ export type DataSourceDiscoveryInfos = {
};

export type DataSourceInterface = {
account_id: Scalars['String']['output'];
account_id?: Maybe<Scalars['String']['output']>;
details?: Maybe<DataSourceDetails>;
id: Scalars['String']['output'];
last_getting_metric_attempt_at: Scalars['Int']['output'];
id?: Maybe<Scalars['String']['output']>;
last_getting_metric_attempt_at?: Maybe<Scalars['Int']['output']>;
last_getting_metric_attempt_error?: Maybe<Scalars['String']['output']>;
last_getting_metrics_at: Scalars['Int']['output'];
last_import_at: Scalars['Int']['output'];
last_import_attempt_at: Scalars['Int']['output'];
last_getting_metrics_at?: Maybe<Scalars['Int']['output']>;
last_import_at?: Maybe<Scalars['Int']['output']>;
last_import_attempt_at?: Maybe<Scalars['Int']['output']>;
last_import_attempt_error?: Maybe<Scalars['String']['output']>;
name: Scalars['String']['output'];
name?: Maybe<Scalars['String']['output']>;
parent_id?: Maybe<Scalars['String']['output']>;
type: DataSourceType;
type?: Maybe<DataSourceType>;
};

export type DataSourceRequestParams = {
Expand All @@ -216,6 +217,7 @@ export enum DataSourceType {
Databricks = 'databricks',
Environment = 'environment',
GcpCnr = 'gcp_cnr',
GcpTenant = 'gcp_tenant',
KubernetesCnr = 'kubernetes_cnr',
Nebius = 'nebius'
}
Expand Down Expand Up @@ -290,6 +292,7 @@ export type GcpBillingDataConfig = {

export type GcpBillingDataConfigInput = {
dataset_name: Scalars['String']['input'];
project_id?: InputMaybe<Scalars['String']['input']>;
table_name: Scalars['String']['input'];
};

Expand Down Expand Up @@ -320,6 +323,40 @@ export type GcpDataSource = DataSourceInterface & {
type: DataSourceType;
};

export type GcpTenantBillingDataConfig = {
__typename?: 'GcpTenantBillingDataConfig';
dataset_name?: Maybe<Scalars['String']['output']>;
project_id?: Maybe<Scalars['String']['output']>;
table_name?: Maybe<Scalars['String']['output']>;
};

export type GcpTenantConfig = {
__typename?: 'GcpTenantConfig';
billing_data?: Maybe<GcpTenantBillingDataConfig>;
};

export type GcpTenantConfigInput = {
billing_data: GcpBillingDataConfigInput;
credentials: Scalars['JSONObject']['input'];
};

export type GcpTenantDataSource = DataSourceInterface & {
__typename?: 'GcpTenantDataSource';
account_id?: Maybe<Scalars['String']['output']>;
config?: Maybe<GcpTenantConfig>;
details?: Maybe<DataSourceDetails>;
id: Scalars['String']['output'];
last_getting_metric_attempt_at: Scalars['Int']['output'];
last_getting_metric_attempt_error?: Maybe<Scalars['String']['output']>;
last_getting_metrics_at: Scalars['Int']['output'];
last_import_at: Scalars['Int']['output'];
last_import_attempt_at: Scalars['Int']['output'];
last_import_attempt_error?: Maybe<Scalars['String']['output']>;
name: Scalars['String']['output'];
parent_id?: Maybe<Scalars['String']['output']>;
type: DataSourceType;
};

export type Invitation = {
__typename?: 'Invitation';
id: Scalars['String']['output'];
Expand All @@ -334,6 +371,7 @@ export type InvitationAssignment = {
id: Scalars['String']['output'];
purpose: Scalars['String']['output'];
scope_id: Scalars['String']['output'];
scope_name: Scalars['String']['output'];
scope_type: Scalars['String']['output'];
};

Expand All @@ -350,6 +388,7 @@ export type K8sConfig = {
};

export type K8sConfigInput = {
cost_model?: InputMaybe<Scalars['JSONObject']['input']>;
password: Scalars['String']['input'];
user: Scalars['String']['input'];
};
Expand Down Expand Up @@ -577,6 +616,7 @@ export type UpdateDataSourceInput = {
azureTenantConfig?: InputMaybe<AzureTenantConfigInput>;
databricksConfig?: InputMaybe<DatabricksConfigInput>;
gcpConfig?: InputMaybe<GcpConfigInput>;
gcpTenantConfig?: InputMaybe<GcpTenantConfigInput>;
k8sConfig?: InputMaybe<K8sConfigInput>;
lastImportAt?: InputMaybe<Scalars['Int']['input']>;
lastImportModifiedAt?: InputMaybe<Scalars['Int']['input']>;
Expand Down Expand Up @@ -674,7 +714,7 @@ export type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArgs

/** Mapping of interface types */
export type ResolversInterfaceTypes<_RefType extends Record<string, unknown>> = {
DataSourceInterface: ( AlibabaDataSource ) | ( AwsDataSource ) | ( AzureSubscriptionDataSource ) | ( AzureTenantDataSource ) | ( DatabricksDataSource ) | ( EnvironmentDataSource ) | ( GcpDataSource ) | ( K8sDataSource ) | ( NebiusDataSource );
DataSourceInterface: ( AlibabaDataSource ) | ( AwsDataSource ) | ( AzureSubscriptionDataSource ) | ( AzureTenantDataSource ) | ( DatabricksDataSource ) | ( EnvironmentDataSource ) | ( GcpDataSource ) | ( GcpTenantDataSource ) | ( K8sDataSource ) | ( NebiusDataSource );
};

/** Mapping between all available schema types and the resolvers types */
Expand Down Expand Up @@ -711,6 +751,10 @@ export type ResolversTypes = {
GcpConfig: ResolverTypeWrapper<GcpConfig>;
GcpConfigInput: GcpConfigInput;
GcpDataSource: ResolverTypeWrapper<GcpDataSource>;
GcpTenantBillingDataConfig: ResolverTypeWrapper<GcpTenantBillingDataConfig>;
GcpTenantConfig: ResolverTypeWrapper<GcpTenantConfig>;
GcpTenantConfigInput: GcpTenantConfigInput;
GcpTenantDataSource: ResolverTypeWrapper<GcpTenantDataSource>;
ID: ResolverTypeWrapper<Scalars['ID']['output']>;
Int: ResolverTypeWrapper<Scalars['Int']['output']>;
Invitation: ResolverTypeWrapper<Invitation>;
Expand Down Expand Up @@ -769,6 +813,10 @@ export type ResolversParentTypes = {
GcpConfig: GcpConfig;
GcpConfigInput: GcpConfigInput;
GcpDataSource: GcpDataSource;
GcpTenantBillingDataConfig: GcpTenantBillingDataConfig;
GcpTenantConfig: GcpTenantConfig;
GcpTenantConfigInput: GcpTenantConfigInput;
GcpTenantDataSource: GcpTenantDataSource;
ID: Scalars['ID']['output'];
Int: Scalars['Int']['output'];
Invitation: Invitation;
Expand Down Expand Up @@ -917,19 +965,19 @@ export type DataSourceDiscoveryInfosResolvers<ContextType = any, ParentType exte
};

export type DataSourceInterfaceResolvers<ContextType = any, ParentType extends ResolversParentTypes['DataSourceInterface'] = ResolversParentTypes['DataSourceInterface']> = {
__resolveType: TypeResolveFn<'AlibabaDataSource' | 'AwsDataSource' | 'AzureSubscriptionDataSource' | 'AzureTenantDataSource' | 'DatabricksDataSource' | 'EnvironmentDataSource' | 'GcpDataSource' | 'K8sDataSource' | 'NebiusDataSource', ParentType, ContextType>;
account_id?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
__resolveType: TypeResolveFn<'AlibabaDataSource' | 'AwsDataSource' | 'AzureSubscriptionDataSource' | 'AzureTenantDataSource' | 'DatabricksDataSource' | 'EnvironmentDataSource' | 'GcpDataSource' | 'GcpTenantDataSource' | 'K8sDataSource' | 'NebiusDataSource', ParentType, ContextType>;
account_id?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
details?: Resolver<Maybe<ResolversTypes['DataSourceDetails']>, ParentType, ContextType>;
id?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
last_getting_metric_attempt_at?: Resolver<ResolversTypes['Int'], ParentType, ContextType>;
id?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
last_getting_metric_attempt_at?: Resolver<Maybe<ResolversTypes['Int']>, ParentType, ContextType>;
last_getting_metric_attempt_error?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
last_getting_metrics_at?: Resolver<ResolversTypes['Int'], ParentType, ContextType>;
last_import_at?: Resolver<ResolversTypes['Int'], ParentType, ContextType>;
last_import_attempt_at?: Resolver<ResolversTypes['Int'], ParentType, ContextType>;
last_getting_metrics_at?: Resolver<Maybe<ResolversTypes['Int']>, ParentType, ContextType>;
last_import_at?: Resolver<Maybe<ResolversTypes['Int']>, ParentType, ContextType>;
last_import_attempt_at?: Resolver<Maybe<ResolversTypes['Int']>, ParentType, ContextType>;
last_import_attempt_error?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
name?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
name?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
parent_id?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
type?: Resolver<ResolversTypes['DataSourceType'], ParentType, ContextType>;
type?: Resolver<Maybe<ResolversTypes['DataSourceType']>, ParentType, ContextType>;
};

export type DatabricksConfigResolvers<ContextType = any, ParentType extends ResolversParentTypes['DatabricksConfig'] = ResolversParentTypes['DatabricksConfig']> = {
Expand Down Expand Up @@ -1016,6 +1064,35 @@ export type GcpDataSourceResolvers<ContextType = any, ParentType extends Resolve
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};

export type GcpTenantBillingDataConfigResolvers<ContextType = any, ParentType extends ResolversParentTypes['GcpTenantBillingDataConfig'] = ResolversParentTypes['GcpTenantBillingDataConfig']> = {
dataset_name?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
project_id?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
table_name?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};

export type GcpTenantConfigResolvers<ContextType = any, ParentType extends ResolversParentTypes['GcpTenantConfig'] = ResolversParentTypes['GcpTenantConfig']> = {
billing_data?: Resolver<Maybe<ResolversTypes['GcpTenantBillingDataConfig']>, ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};

export type GcpTenantDataSourceResolvers<ContextType = any, ParentType extends ResolversParentTypes['GcpTenantDataSource'] = ResolversParentTypes['GcpTenantDataSource']> = {
account_id?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
config?: Resolver<Maybe<ResolversTypes['GcpTenantConfig']>, ParentType, ContextType>;
details?: Resolver<Maybe<ResolversTypes['DataSourceDetails']>, ParentType, ContextType>;
id?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
last_getting_metric_attempt_at?: Resolver<ResolversTypes['Int'], ParentType, ContextType>;
last_getting_metric_attempt_error?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
last_getting_metrics_at?: Resolver<ResolversTypes['Int'], ParentType, ContextType>;
last_import_at?: Resolver<ResolversTypes['Int'], ParentType, ContextType>;
last_import_attempt_at?: Resolver<ResolversTypes['Int'], ParentType, ContextType>;
last_import_attempt_error?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
name?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
parent_id?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
type?: Resolver<ResolversTypes['DataSourceType'], ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};

export type InvitationResolvers<ContextType = any, ParentType extends ResolversParentTypes['Invitation'] = ResolversParentTypes['Invitation']> = {
id?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
invite_assignments?: Resolver<Maybe<Array<ResolversTypes['InvitationAssignment']>>, ParentType, ContextType>;
Expand All @@ -1029,6 +1106,7 @@ export type InvitationAssignmentResolvers<ContextType = any, ParentType extends
id?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
purpose?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
scope_id?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
scope_name?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
scope_type?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
};
Expand Down Expand Up @@ -1156,6 +1234,9 @@ export type Resolvers<ContextType = any> = {
GcpBillingDataConfig?: GcpBillingDataConfigResolvers<ContextType>;
GcpConfig?: GcpConfigResolvers<ContextType>;
GcpDataSource?: GcpDataSourceResolvers<ContextType>;
GcpTenantBillingDataConfig?: GcpTenantBillingDataConfigResolvers<ContextType>;
GcpTenantConfig?: GcpTenantConfigResolvers<ContextType>;
GcpTenantDataSource?: GcpTenantDataSourceResolvers<ContextType>;
Invitation?: InvitationResolvers<ContextType>;
InvitationAssignment?: InvitationAssignmentResolvers<ContextType>;
JSONObject?: GraphQLScalarType;
Expand Down
3 changes: 3 additions & 0 deletions ngui/server/graphql/resolvers/restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const resolvers: Resolvers = {
case "gcp_cnr": {
return "GcpDataSource";
}
case "gcp_tenant": {
return "GcpTenantDataSource";
}
case "alibaba_cnr": {
return "AlibabaDataSource";
}
Expand Down
54 changes: 46 additions & 8 deletions ngui/server/graphql/schemas/restapi.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ enum DataSourceType {
azure_tenant
azure_cnr
gcp_cnr
gcp_tenant
alibaba_cnr
nebius
databricks
Expand Down Expand Up @@ -35,16 +36,16 @@ type DataSourceDetails {
}

interface DataSourceInterface {
id: String!
name: String!
type: DataSourceType!
id: String
name: String
type: DataSourceType
parent_id: String
account_id: String!
last_import_at: Int!
last_import_attempt_at: Int!
account_id: String
last_import_at: Int
last_import_attempt_at: Int
last_import_attempt_error: String
last_getting_metrics_at: Int!
last_getting_metric_attempt_at: Int!
last_getting_metrics_at: Int
last_getting_metric_attempt_at: Int
last_getting_metric_attempt_error: String
details: DataSourceDetails
}
Expand Down Expand Up @@ -151,6 +152,33 @@ type GcpDataSource implements DataSourceInterface {
config: GcpConfig
}

# GCP tenant data source
type GcpTenantBillingDataConfig {
dataset_name: String
table_name: String
project_id: String
}

type GcpTenantConfig {
billing_data: GcpTenantBillingDataConfig
}

type GcpTenantDataSource implements DataSourceInterface {
id: String!
name: String!
type: DataSourceType!
parent_id: String
account_id: String
last_import_at: Int!
last_import_attempt_at: Int!
last_import_attempt_error: String
last_getting_metrics_at: Int!
last_getting_metric_attempt_at: Int!
last_getting_metric_attempt_error: String
details: DataSourceDetails
config: GcpTenantConfig
}

# Alibaba data source
type AlibabaConfig {
access_key_id: String
Expand Down Expand Up @@ -302,13 +330,19 @@ input AzureTenantConfigInput {
input GcpBillingDataConfigInput {
dataset_name: String!
table_name: String!
project_id: String
}

input GcpConfigInput {
billing_data: GcpBillingDataConfigInput!
credentials: JSONObject!
}

input GcpTenantConfigInput {
billing_data: GcpBillingDataConfigInput!
credentials: JSONObject!
}

input AlibabaConfigInput {
access_key_id: String!
secret_access_key: String!
Expand All @@ -328,6 +362,7 @@ input NebiusConfigInput {
input K8sConfigInput {
password: String!
user: String!
cost_model: JSONObject
}

input DatabricksConfigInput {
Expand All @@ -344,6 +379,7 @@ input CreateDataSourceInput {
azureSubscriptionConfig: AzureSubscriptionConfigInput
azureTenantConfig: AzureTenantConfigInput
gcpConfig: GcpConfigInput
gcpTenantConfig: GcpTenantConfigInput
alibabaConfig: AlibabaConfigInput
nebiusConfig: NebiusConfigInput
databricksConfig: DatabricksConfigInput
Expand All @@ -359,6 +395,7 @@ input UpdateDataSourceInput {
azureSubscriptionConfig: AzureSubscriptionConfigInput
azureTenantConfig: AzureTenantConfigInput
gcpConfig: GcpConfigInput
gcpTenantConfig: GcpTenantConfigInput
alibabaConfig: AlibabaConfigInput
nebiusConfig: NebiusConfigInput
databricksConfig: DatabricksConfigInput
Expand Down Expand Up @@ -405,6 +442,7 @@ type Employee {
type InvitationAssignment {
id: String!
scope_id: String!
scope_name: String!
scope_type: String!
purpose: String!
}
Expand Down
Loading

0 comments on commit ba54625

Please sign in to comment.