Skip to content

Commit

Permalink
Add flag to allow extra properties (#54)
Browse files Browse the repository at this point in the history
* Add flag to allow extra properties
  • Loading branch information
sokoli1 authored Feb 7, 2024
1 parent 1f2b455 commit 151257f
Show file tree
Hide file tree
Showing 180 changed files with 1,621 additions and 101 deletions.
26 changes: 6 additions & 20 deletions .github/workflows/_common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,11 @@ jobs:
with:
package-name: ${{ inputs.package-name }}
test:
name: Test ${{ inputs.package-name }} py v ${{ matrix.python-version }}
runs-on: ubuntu-20.04
needs:
- lint
services:
mockserver:
image: mockserver/mockserver:5.15.0
ports:
- 1080:1080
strategy:
fail-fast: false
matrix:
python-version: [ '3.7', '3.12' ]
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/composite/test-sdk
with:
package-under-test: ./${{ inputs.package-name }}
test-dir: tests
test-file: ${{ inputs.test-file }}
test-report-dir: tests/test-reports
python-version: ${{ matrix.python-version }}
uses: ./.github/workflows/_test.yml
with:
test-dir: tests
test-file: ${{ inputs.test-file }}
test-report-dir: tests/test-reports
package-name: ${{ inputs.package-name }}
40 changes: 40 additions & 0 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: (abstract) - Test

on:
workflow_call:
inputs:
package-name:
required: true
type: string
test-file:
required: true
type: string
test-dir:
required: true
type: string
test-report-dir:
required: true
type: string

jobs:
test:
name: Test ${{ inputs.package-name }} py v ${{ matrix.python-version }}
runs-on: ubuntu-20.04
services:
mockserver:
image: mockserver/mockserver:5.15.0
ports:
- 1080:1080
strategy:
fail-fast: false
matrix:
python-version: [ '3.7', '3.12' ]
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/composite/test-sdk
with:
package-under-test: ./${{ inputs.package-name }}
test-dir: tests
test-file: ${{ inputs.test-file }}
test-report-dir: tests/test-reports
python-version: ${{ matrix.python-version }}
3 changes: 2 additions & 1 deletion .github/workflows/composite/generate-sdk/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ runs:
-c openapi-generator-config.yaml \
-o=${{ inputs.package-name }} \
--additional-properties packageName=${{ inputs.package-name }} \
--additional-properties packageVersion=$version
--additional-properties packageVersion=$version \
--additional-properties disallowAdditionalPropertiesIfNotPresent=false
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/validate-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ jobs:
package-name: pnap_payments_api
test-file: pnap_payments_api_test.py

run-generic-tests:
uses: ./.github/workflows/_test.yml
with:
test-dir: tests
test-file: misc_test.py
test-report-dir: tests/test-reports
package-name: pnap_audit_api

publish-test-results:
name: Publish Test Results
needs:
Expand All @@ -71,6 +79,7 @@ jobs:
- build-and-test-locationapi
- build-and-test-invoicingapi
- build-and-test-paymentsapi
- run-generic-tests
runs-on: ubuntu-20.04
if: always()
steps:
Expand Down
2 changes: 1 addition & 1 deletion pnap_audit_api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Knowledge base articles to help you can be found
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: 1.0
- Package version: 2.0.1-SNAPSHOT
- Package version: 2.0.1
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
For more information, please visit [https://phoenixnap.com/](https://phoenixnap.com/)

Expand Down
2 changes: 1 addition & 1 deletion pnap_audit_api/pnap_audit_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
""" # noqa: E501


__version__ = "2.0.1-SNAPSHOT"
__version__ = "2.0.1"

# import apis into sdk package
from pnap_audit_api.api.events_api import EventsApi
Expand Down
4 changes: 2 additions & 2 deletions pnap_audit_api/pnap_audit_api/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ def __init__(
self.default_headers[header_name] = header_value
self.cookie = cookie
# Set default User-Agent.
self.user_agent = f"PNAP-python-sdk-bmc/2.0.1-SNAPSHOT"
self.user_agent = f"PNAP-python-sdk-bmc/2.0.1"
self.client_side_validation = configuration.client_side_validation

# Set default X-Powered-By.
self.powered_by = f"PNAP-python-sdk-bmc/2.0.1-SNAPSHOT"
self.powered_by = f"PNAP-python-sdk-bmc/2.0.1"

def __enter__(self):
return self
Expand Down
2 changes: 1 addition & 1 deletion pnap_audit_api/pnap_audit_api/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def to_debug_report(self):
"OS: {env}\n"\
"Python Version: {pyversion}\n"\
"Version of the API: 1.0\n"\
"SDK Package Version: 2.0.1-SNAPSHOT".\
"SDK Package Version: 2.0.1".\
format(env=sys.platform, pyversion=sys.version)

def get_host_settings(self):
Expand Down
13 changes: 13 additions & 0 deletions pnap_audit_api/pnap_audit_api/models/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Error(BaseModel):
""" # noqa: E501
message: StrictStr = Field(description="The description detailing the cause of the error code.")
validation_errors: Optional[List[StrictStr]] = Field(default=None, description="Validation errors, if any.", alias="validationErrors")
additional_properties: Dict[str, Any] = {}
__properties: ClassVar[List[str]] = ["message", "validationErrors"]

model_config = {
Expand Down Expand Up @@ -67,15 +68,22 @@ def to_dict(self) -> Dict[str, Any]:
are ignored.
* OpenAPI `readOnly` fields are excluded.
* OpenAPI `readOnly` fields are excluded.
* Fields in `self.additional_properties` are added to the output dict.
"""
_dict = self.model_dump(
by_alias=True,
exclude={
"message",
"validation_errors",
"additional_properties",
},
exclude_none=True,
)
# puts key-value pairs in additional_properties in the top level
if self.additional_properties is not None:
for _key, _value in self.additional_properties.items():
_dict[_key] = _value

return _dict

@classmethod
Expand All @@ -91,6 +99,11 @@ def from_dict(cls, obj: Dict) -> Self:
"message": obj.get("message"),
"validationErrors": obj.get("validationErrors")
})
# store additional fields in additional_properties
for _key in obj.keys():
if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key)

return _obj


13 changes: 13 additions & 0 deletions pnap_audit_api/pnap_audit_api/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Event(BaseModel):
name: Optional[StrictStr] = Field(default=None, description="The name of the event.")
timestamp: datetime = Field(description="The UTC time the event initiated.")
user_info: UserInfo = Field(alias="userInfo")
additional_properties: Dict[str, Any] = {}
__properties: ClassVar[List[str]] = ["name", "timestamp", "userInfo"]

model_config = {
Expand Down Expand Up @@ -67,16 +68,23 @@ def to_dict(self) -> Dict[str, Any]:
* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
* Fields in `self.additional_properties` are added to the output dict.
"""
_dict = self.model_dump(
by_alias=True,
exclude={
"additional_properties",
},
exclude_none=True,
)
# override the default output from pydantic by calling `to_dict()` of user_info
if self.user_info:
_dict['userInfo'] = self.user_info.to_dict()
# puts key-value pairs in additional_properties in the top level
if self.additional_properties is not None:
for _key, _value in self.additional_properties.items():
_dict[_key] = _value

return _dict

@classmethod
Expand All @@ -93,6 +101,11 @@ def from_dict(cls, obj: Dict) -> Self:
"timestamp": obj.get("timestamp"),
"userInfo": UserInfo.from_dict(obj.get("userInfo")) if obj.get("userInfo") is not None else None
})
# store additional fields in additional_properties
for _key in obj.keys():
if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key)

return _obj


13 changes: 13 additions & 0 deletions pnap_audit_api/pnap_audit_api/models/user_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class UserInfo(BaseModel):
account_id: StrictStr = Field(description="The BMC account ID", alias="accountId")
client_id: Optional[StrictStr] = Field(default=None, description="The client ID of the application", alias="clientId")
username: StrictStr = Field(description="The logged in user or owner of the client application")
additional_properties: Dict[str, Any] = {}
__properties: ClassVar[List[str]] = ["accountId", "clientId", "username"]

model_config = {
Expand Down Expand Up @@ -66,13 +67,20 @@ def to_dict(self) -> Dict[str, Any]:
* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
* Fields in `self.additional_properties` are added to the output dict.
"""
_dict = self.model_dump(
by_alias=True,
exclude={
"additional_properties",
},
exclude_none=True,
)
# puts key-value pairs in additional_properties in the top level
if self.additional_properties is not None:
for _key, _value in self.additional_properties.items():
_dict[_key] = _value

return _dict

@classmethod
Expand All @@ -89,6 +97,11 @@ def from_dict(cls, obj: Dict) -> Self:
"clientId": obj.get("clientId"),
"username": obj.get("username")
})
# store additional fields in additional_properties
for _key in obj.keys():
if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key)

return _obj


2 changes: 1 addition & 1 deletion pnap_audit_api/pnap_audit_api/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "2.0.1-SNAPSHOT"
VERSION = "2.0.1"
2 changes: 1 addition & 1 deletion pnap_audit_api/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pnap_audit_api"
version = "2.0.1-SNAPSHOT"
version = "2.0.1"
description = "Audit Log API"
authors = ["PhoenixNAP Team <[email protected]>"]
license = "Apache 2.0"
Expand Down
2 changes: 1 addition & 1 deletion pnap_audit_api/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# prerequisite: setuptools
# http://pypi.python.org/pypi/setuptools
NAME = "pnap-audit-api"
VERSION = "2.0.1-SNAPSHOT"
VERSION = "2.0.1"
PYTHON_REQUIRES = ">=3.7"
REQUIRES = [
"urllib3 >= 1.25.3, < 2.1.0",
Expand Down
2 changes: 1 addition & 1 deletion pnap_bmc_api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Knowledge base articles to help you can be found
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: 0.1
- Package version: 2.0.1-SNAPSHOT
- Package version: 2.0.1
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
For more information, please visit [https://phoenixnap.com/](https://phoenixnap.com/)

Expand Down
2 changes: 1 addition & 1 deletion pnap_bmc_api/pnap_bmc_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
""" # noqa: E501


__version__ = "2.0.1-SNAPSHOT"
__version__ = "2.0.1"

# import apis into sdk package
from pnap_bmc_api.api.quotas_api import QuotasApi
Expand Down
4 changes: 2 additions & 2 deletions pnap_bmc_api/pnap_bmc_api/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ def __init__(
self.default_headers[header_name] = header_value
self.cookie = cookie
# Set default User-Agent.
self.user_agent = f"PNAP-python-sdk-bmc/2.0.1-SNAPSHOT"
self.user_agent = f"PNAP-python-sdk-bmc/2.0.1"
self.client_side_validation = configuration.client_side_validation

# Set default X-Powered-By.
self.powered_by = f"PNAP-python-sdk-bmc/2.0.1-SNAPSHOT"
self.powered_by = f"PNAP-python-sdk-bmc/2.0.1"

def __enter__(self):
return self
Expand Down
2 changes: 1 addition & 1 deletion pnap_bmc_api/pnap_bmc_api/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def to_debug_report(self):
"OS: {env}\n"\
"Python Version: {pyversion}\n"\
"Version of the API: 0.1\n"\
"SDK Package Version: 2.0.1-SNAPSHOT".\
"SDK Package Version: 2.0.1".\
format(env=sys.platform, pyversion=sys.version)

def get_host_settings(self):
Expand Down
13 changes: 13 additions & 0 deletions pnap_bmc_api/pnap_bmc_api/models/action_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ActionResult(BaseModel):
Result of a successful action.
""" # noqa: E501
result: StrictStr = Field(description="Message describing the action's result.")
additional_properties: Dict[str, Any] = {}
__properties: ClassVar[List[str]] = ["result"]

model_config = {
Expand Down Expand Up @@ -64,13 +65,20 @@ def to_dict(self) -> Dict[str, Any]:
* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
* Fields in `self.additional_properties` are added to the output dict.
"""
_dict = self.model_dump(
by_alias=True,
exclude={
"additional_properties",
},
exclude_none=True,
)
# puts key-value pairs in additional_properties in the top level
if self.additional_properties is not None:
for _key, _value in self.additional_properties.items():
_dict[_key] = _value

return _dict

@classmethod
Expand All @@ -85,6 +93,11 @@ def from_dict(cls, obj: Dict) -> Self:
_obj = cls.model_validate({
"result": obj.get("result")
})
# store additional fields in additional_properties
for _key in obj.keys():
if _key not in cls.__properties:
_obj.additional_properties[_key] = obj.get(_key)

return _obj


Loading

0 comments on commit 151257f

Please sign in to comment.