Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [M3-8833] - Update API types and mock data for VPU plans #11256

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/api-v4/.changeset/pr-11256-added-1731689702399.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/api-v4": Added
---

New VPU related fields and capabilities to API types ([#11256](https://github.com/linode/manager/pull/11256))
1 change: 1 addition & 0 deletions packages/api-v4/src/account/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export type AccountCapability =
| 'Machine Images'
| 'Managed Databases'
| 'Managed Databases Beta'
| 'NETINT Quadra T1U'
| 'NodeBalancers'
| 'Object Storage Access Key Regions'
| 'Object Storage Endpoint Types'
Expand Down
2 changes: 1 addition & 1 deletion packages/api-v4/src/linodes/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const resizeLinode = (linodeId: number, data: ResizeLinodePayload) =>
* automatically appended to the root user's authorized keys file.
*/
export const rebuildLinode = (linodeId: number, data: RebuildRequest) =>
Request<{}>(
Request<Linode>(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(updated this type since this request does return a Linode)
https://techdocs.akamai.com/linode-api/reference/post-rebuild-linode-instance

setURL(
`${API_ROOT}/linode/instances/${encodeURIComponent(linodeId)}/rebuild`
),
Expand Down
3 changes: 3 additions & 0 deletions packages/api-v4/src/linodes/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface LinodeSpecs {
vcpus: number;
transfer: number;
gpus: number;
accelerated_devices: number;
}

export interface Linode {
Expand Down Expand Up @@ -322,6 +323,7 @@ export interface LinodeType extends BaseType {
successor: string | null;
network_out: number;
gpus: number;
accelerated_devices: number;
price: PriceObject;
region_prices: RegionPriceObject[];
addons: {
Expand All @@ -330,6 +332,7 @@ export interface LinodeType extends BaseType {
}

export type LinodeTypeClass =
| 'accelerated'
| 'nanode'
| 'standard'
| 'dedicated'
Expand Down
1 change: 1 addition & 0 deletions packages/api-v4/src/regions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type Capabilities =
| 'Managed Databases'
| 'Metadata'
| 'NodeBalancers'
| 'NETINT Quadra T1U'
| 'Object Storage'
| 'Placement Group'
| 'Premium Plans'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Changed
---

Updated types based on new VPU fields and added mock data ([#11256](https://github.com/linode/manager/pull/11256))
4 changes: 4 additions & 0 deletions packages/manager/src/__data__/linodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const linode1: Linode = {
region: 'us-east',
site_type: 'core',
specs: {
accelerated_devices: 0,
disk: 20480,
gpus: 0,
memory: 1024,
Expand Down Expand Up @@ -81,6 +82,7 @@ export const linode2: Linode = {
region: 'us-east',
site_type: 'core',
specs: {
accelerated_devices: 0,
disk: 30720,
gpus: 0,
memory: 2048,
Expand Down Expand Up @@ -128,6 +130,7 @@ export const linode3: Linode = {
region: 'us-east',
site_type: 'core',
specs: {
accelerated_devices: 0,
disk: 30720,
gpus: 0,
memory: 2048,
Expand Down Expand Up @@ -175,6 +178,7 @@ export const linode4: Linode = {
region: 'eu-west',
site_type: 'core',
specs: {
accelerated_devices: 0,
disk: 30720,
gpus: 0,
memory: 2048,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const Default: Story = {
},
}}
linodeType={{
accelerated_devices: 0,
addons: {
backups: {
price: {
Expand Down
3 changes: 3 additions & 0 deletions packages/manager/src/factories/linodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const linodeAlertsFactory = Factory.Sync.makeFactory<LinodeAlerts>({
});

export const linodeSpecsFactory = Factory.Sync.makeFactory<LinodeSpecs>({
accelerated_devices: 1,
disk: 51200,
gpus: 0,
memory: 2048,
Expand Down Expand Up @@ -163,6 +164,7 @@ export const linodeTransferFactory = Factory.Sync.makeFactory<RegionalNetworkUti
);

export const linodeTypeFactory = Factory.Sync.makeFactory<LinodeType>({
accelerated_devices: 0,
addons: {
backups: {
price: {
Expand Down Expand Up @@ -218,6 +220,7 @@ export const dedicatedTypeFactory = linodeTypeFactory.extend({
});

export const proDedicatedTypeFactory = Factory.Sync.makeFactory<LinodeType>({
accelerated_devices: 0,
addons: {
backups: {
price: {
Expand Down
2 changes: 2 additions & 0 deletions packages/manager/src/factories/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
import type { ExtendedType } from 'src/utilities/extendType';

export const typeFactory = Factory.Sync.makeFactory<LinodeType>({
accelerated_devices: 0,
addons: {
backups: {
price: {
Expand Down Expand Up @@ -87,6 +88,7 @@ export const planSelectionTypeFactory = Factory.Sync.makeFactory<PlanWithAvailab
export const extendedTypeFactory = Factory.Sync.makeFactory<
ExtendedType & PlanSelectionAvailabilityTypes
>({
accelerated_devices: 0,
addons: {
backups: {
price: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const GPU_COMPUTE_INSTANCES_LINK =
'https://techdocs.akamai.com/cloud-computing/docs/gpu-compute-instances';

export const DEDICATED_512_GB_PLAN: ExtendedType = {
accelerated_devices: 0,
addons: {
backups: {
price: {
Expand Down Expand Up @@ -83,6 +84,7 @@ export const DEDICATED_512_GB_PLAN: ExtendedType = {
};

export const PREMIUM_512_GB_PLAN: ExtendedType = {
accelerated_devices: 0,
addons: {
backups: {
price: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const nanode = typeFactory.build({ class: 'nanode', id: 'g6-nanode-1' });
const premium = typeFactory.build({ class: 'premium', id: 'g6-premium-2' });
const highmem = typeFactory.build({ class: 'highmem', id: 'g6-highmem-1' });
const gpu = typeFactory.build({ class: 'gpu', id: 'g6-gpu-1' });
const accelerated = typeFactory.build({
class: 'accelerated',
id: 'accelerated-1',
});

describe('getPlanSelectionsByPlanType', () => {
it('should return an object with plans grouped by type', () => {
Expand Down Expand Up @@ -60,6 +64,7 @@ describe('getPlanSelectionsByPlanType', () => {
nanode,
dedicated,
prodedicated,
accelerated,
]);
const expectedOrder = planTypeOrder;

Expand Down
15 changes: 12 additions & 3 deletions packages/manager/src/features/components/PlansPanel/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { arrayToList } from 'src/utilities/arrayToList';
import { ExtendedType } from 'src/utilities/extendType';

import {
DEDICATED_512_GB_PLAN,
Expand All @@ -10,19 +9,20 @@ import {
PREMIUM_512_GB_PLAN,
SMALLER_PLAN_DISABLED_COPY,
} from './constants';
import {

import type {
DisabledTooltipReasons,
PlanSelectionType,
PlanWithAvailability,
} from './types';

import type {
Capabilities,
LinodeTypeClass,
Region,
RegionAvailability,
} from '@linode/api-v4';
import type { Flags } from 'src/featureFlags';
import type { ExtendedType } from 'src/utilities/extendType';

export type PlansTypes<T> = Record<LinodeTypeClass, T[]>;

Expand All @@ -42,6 +42,7 @@ export const planTypeOrder: (
'gpu',
'metal',
'premium',
'accelerated',
];

/**
Expand Down Expand Up @@ -165,6 +166,14 @@ export const getIsLimitedAvailability = ({
};

export const planTabInfoContent = {
// TODO: to be further handled in M3-8834
accelerated: {
dataId: 'data-qa-accelerated',
key: 'accelerated',
title: 'Accelerated',
typography:
'Accelerated instances leverage ASICs to accelerate specialized tasks such as video transcoding, media processing, and other compute heavy workloads.',
},
dedicated: {
dataId: 'data-qa-dedicated',
key: 'dedicated',
Expand Down
7 changes: 7 additions & 0 deletions packages/manager/src/mocks/serverHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,12 @@ const gpuTypesRX = linodeTypeFactory.buildList(7, {
gpus: 1,
transfer: 5000,
});
const acceleratedType = linodeTypeFactory.buildList(7, {
accelerated_devices: 1,
class: 'accelerated',
label: 'Netint Quadra T1U X',
transfer: 0,
});
const proxyAccountUser = accountUserFactory.build({
email: '[email protected]',
last_login: null,
Expand Down Expand Up @@ -595,6 +601,7 @@ export const handlers = [
...dedicatedTypes,
...gpuTypesAda,
...gpuTypesRX,
...acceleratedType,
proDedicatedType,
])
);
Expand Down