Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

Commit

Permalink
fix: remove 2 enums from Plan schema, they don't match the real API (#64
Browse files Browse the repository at this point in the history
)

This PR removes 2 enums from Plan subschemas, because the enumed values
don't match the API.

Based on:

https://github.com/equinix/equinix-sdk-go/blob/main/spec/services/metalv1/patches/20230921-plan-drive-type.patch

fixes #63 

Most of the diff are tests, the relevant changes are two entries at the
bottom.
  • Loading branch information
ctreatma authored Dec 20, 2023
2 parents dab7e76 + 247f59b commit 29f133c
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 53 deletions.
10 changes: 0 additions & 10 deletions equinix_metal/equinix_metal/models/plan_specs_drives_inner.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,6 @@ def category_validate_enum(cls, value):
raise ValueError("must be one of enum values ('boot', 'cache', 'storage')")
return value

@validator('type')
def type_validate_enum(cls, value):
"""Validates the enum"""
if value is None:
return value

if value not in ('HDD', 'SSD', 'NVME'):
raise ValueError("must be one of enum values ('HDD', 'SSD', 'NVME')")
return value

class Config:
"""Pydantic configuration"""
allow_population_by_field_name = True
Expand Down
12 changes: 1 addition & 11 deletions equinix_metal/equinix_metal/models/plan_specs_nics_inner.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


from typing import Optional
from pydantic import BaseModel, StrictInt, StrictStr, validator
from pydantic import BaseModel, StrictInt, StrictStr

class PlanSpecsNicsInner(BaseModel):
"""
Expand All @@ -31,16 +31,6 @@ class PlanSpecsNicsInner(BaseModel):
type: Optional[StrictStr] = None
__properties = ["count", "href", "type"]

@validator('type')
def type_validate_enum(cls, value):
"""Validates the enum"""
if value is None:
return value

if value not in ('1Gbps', '10Gbps', '25Gbps'):
raise ValueError("must be one of enum values ('1Gbps', '10Gbps', '25Gbps')")
return value

class Config:
"""Pydantic configuration"""
allow_population_by_field_name = True
Expand Down
4 changes: 2 additions & 2 deletions equinix_metal/test/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class = 'm3.large.x86',
count = 56,
href = '',
size = '3.84TB',
type = 'HDD', )
type = '', )
],
features = equinix_metal.models.plan_specs_features.Plan_specs_features(
href = '',
Expand All @@ -228,7 +228,7 @@ class = 'm3.large.x86',
equinix_metal.models.plan_specs_nics_inner.Plan_specs_nics_inner(
count = 2,
href = '',
type = '1Gbps', )
type = '', )
], ),
type = 'standard', ),
project = None,
Expand Down
4 changes: 2 additions & 2 deletions equinix_metal/test/test_device_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class = 'm3.large.x86',
count = 56,
href = '',
size = '3.84TB',
type = 'HDD', )
type = '', )
],
features = equinix_metal.models.plan_specs_features.Plan_specs_features(
href = '',
Expand All @@ -223,7 +223,7 @@ class = 'm3.large.x86',
equinix_metal.models.plan_specs_nics_inner.Plan_specs_nics_inner(
count = 2,
href = '',
type = '1Gbps', )
type = '', )
], ),
type = 'standard', ),
project = null,
Expand Down
8 changes: 4 additions & 4 deletions equinix_metal/test/test_hardware_reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class = 'm3.large.x86',
count = 56,
href = '',
size = '3.84TB',
type = 'HDD', )
type = '', )
],
features = equinix_metal.models.plan_specs_features.Plan_specs_features(
href = '',
Expand All @@ -224,7 +224,7 @@ class = 'm3.large.x86',
equinix_metal.models.plan_specs_nics_inner.Plan_specs_nics_inner(
count = 2,
href = '',
type = '1Gbps', )
type = '', )
], ),
type = 'standard', ),
project = null,
Expand Down Expand Up @@ -363,7 +363,7 @@ class = 'm3.large.x86',
count = 56,
href = '',
size = '3.84TB',
type = 'HDD', )
type = '', )
],
features = equinix_metal.models.plan_specs_features.Plan_specs_features(
href = '',
Expand All @@ -378,7 +378,7 @@ class = 'm3.large.x86',
equinix_metal.models.plan_specs_nics_inner.Plan_specs_nics_inner(
count = 2,
href = '',
type = '1Gbps', )
type = '', )
], ),
type = 'standard', ),
project = equinix_metal.models.project.Project(
Expand Down
4 changes: 2 additions & 2 deletions equinix_metal/test/test_hardware_reservation_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class = 'm3.large.x86',
count = 56,
href = '',
size = '3.84TB',
type = 'HDD', )
type = '', )
],
features = equinix_metal.models.plan_specs_features.Plan_specs_features(
href = '',
Expand All @@ -226,7 +226,7 @@ class = 'm3.large.x86',
equinix_metal.models.plan_specs_nics_inner.Plan_specs_nics_inner(
count = 2,
href = '',
type = '1Gbps', )
type = '', )
], ),
type = 'standard', ),
project = null,
Expand Down
4 changes: 2 additions & 2 deletions equinix_metal/test/test_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class = 'm3.large.x86',
count = 56,
href = '',
size = '3.84TB',
type = 'HDD', )
type = '', )
],
features = equinix_metal.models.plan_specs_features.Plan_specs_features(
href = '',
Expand All @@ -110,7 +110,7 @@ class = 'm3.large.x86',
equinix_metal.models.plan_specs_nics_inner.Plan_specs_nics_inner(
count = 2,
href = '',
type = '1Gbps', )
type = '', )
], ),
type = 'standard', ),
unit = '',
Expand Down
4 changes: 2 additions & 2 deletions equinix_metal/test/test_invoice_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class = 'm3.large.x86',
count = 56,
href = '',
size = '3.84TB',
type = 'HDD', )
type = '', )
],
features = equinix_metal.models.plan_specs_features.Plan_specs_features(
href = '',
Expand All @@ -113,7 +113,7 @@ class = 'm3.large.x86',
equinix_metal.models.plan_specs_nics_inner.Plan_specs_nics_inner(
count = 2,
href = '',
type = '1Gbps', )
type = '', )
], ),
type = 'standard', ),
unit = '',
Expand Down
4 changes: 2 additions & 2 deletions equinix_metal/test/test_line_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class = 'm3.large.x86',
count = 56,
href = '',
size = '3.84TB',
type = 'HDD', )
type = '', )
],
features = equinix_metal.models.plan_specs_features.Plan_specs_features(
href = '',
Expand All @@ -99,7 +99,7 @@ class = 'm3.large.x86',
equinix_metal.models.plan_specs_nics_inner.Plan_specs_nics_inner(
count = 2,
href = '',
type = '1Gbps', )
type = '', )
], ),
type = 'standard', ),
unit = '',
Expand Down
4 changes: 2 additions & 2 deletions equinix_metal/test/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def make_instance(self, include_optional):
count = 56,
href = '',
size = '3.84TB',
type = 'HDD', )
type = '', )
],
features = equinix_metal.models.plan_specs_features.Plan_specs_features(
href = '',
Expand All @@ -96,7 +96,7 @@ def make_instance(self, include_optional):
equinix_metal.models.plan_specs_nics_inner.Plan_specs_nics_inner(
count = 2,
href = '',
type = '1Gbps', )
type = '', )
], ),
type = 'standard'
)
Expand Down
4 changes: 2 additions & 2 deletions equinix_metal/test/test_plan_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class = 'm3.large.x86',
count = 56,
href = '',
size = '3.84TB',
type = 'HDD', )
type = '', )
],
features = equinix_metal.models.plan_specs_features.Plan_specs_features(
href = '',
Expand All @@ -96,7 +96,7 @@ class = 'm3.large.x86',
equinix_metal.models.plan_specs_nics_inner.Plan_specs_nics_inner(
count = 2,
href = '',
type = '1Gbps', )
type = '', )
], ),
type = 'standard', )
]
Expand Down
4 changes: 2 additions & 2 deletions equinix_metal/test/test_plan_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def make_instance(self, include_optional):
count = 56,
href = '',
size = '3.84TB',
type = 'HDD', )
type = '', )
],
features = equinix_metal.models.plan_specs_features.Plan_specs_features(
href = '',
Expand All @@ -66,7 +66,7 @@ def make_instance(self, include_optional):
equinix_metal.models.plan_specs_nics_inner.Plan_specs_nics_inner(
count = 2,
href = '',
type = '1Gbps', )
type = '', )
]
)
else :
Expand Down
2 changes: 1 addition & 1 deletion equinix_metal/test/test_plan_specs_drives_inner.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def make_instance(self, include_optional):
count = 56,
href = '',
size = '3.84TB',
type = 'HDD'
type = ''
)
else :
return PlanSpecsDrivesInner(
Expand Down
2 changes: 1 addition & 1 deletion equinix_metal/test/test_plan_specs_nics_inner.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def make_instance(self, include_optional):
return PlanSpecsNicsInner(
count = 2,
href = '',
type = '1Gbps'
type = ''
)
else :
return PlanSpecsNicsInner(
Expand Down
8 changes: 0 additions & 8 deletions metal_openapi.fixed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3510,10 +3510,6 @@ components:
example: 3.84TB
type: string
type:
enum:
- HDD
- SSD
- NVME
type: string
type: object
Plan_specs_features:
Expand Down Expand Up @@ -3545,10 +3541,6 @@ components:
format: uri
type: string
type:
enum:
- 1Gbps
- 10Gbps
- 25Gbps
type: string
type: object
Port:
Expand Down
5 changes: 5 additions & 0 deletions scripts/patch_metal_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ def loadYaml(fn):

del fixedSpec['components']['schemas']['Address']['required']

# FIX 12. Remove enums from Plan schema - they don't match the real API
# https://github.com/equinix-labs/metal-python/pull/63

del fixedSpec['components']['schemas']['Plan_specs_drives_inner']['properties']['type']['enum']
del fixedSpec['components']['schemas']['Plan_specs_nics_inner']['properties']['type']['enum']

# Mark paginated operation with `x-equinix-metal-paginated-property`

Expand Down

0 comments on commit 29f133c

Please sign in to comment.