Skip to content

Update package#1

Merged
patienceigiraneza merged 1 commit intomainfrom
features
Jun 3, 2025
Merged

Update package#1
patienceigiraneza merged 1 commit intomainfrom
features

Conversation

@patienceigiraneza
Copy link
Contributor

@patienceigiraneza patienceigiraneza commented Jun 3, 2025

PR Type

enhancement, tests, documentation


Description

  • Rename package from openapi_client to workplace_console_client

    • Update all import paths and configuration references
    • Update package name/version in setup.py and pyproject.toml
    • Update test coverage and CI/CD configs for new package name
  • Add DNS Info API request/response models and tests

    • Implement DnsInfoCreateRequest and DnsInfoCreate200Response models
    • Add corresponding unit tests for new models
    • Update DnsInfoApi to use new models and return types
  • Enhance and refactor API client and exception handling

    • Add detailed exception classes in exceptions.py
    • Improve API response handling and type annotations
    • Refactor model serialization/deserialization logic
  • Update and expand documentation

    • Revise README and API docs for new package name and usage
    • Add documentation for new DNS Info models and endpoints

Changes walkthrough 📝

Relevant files
Configuration changes
7 files
python.yml
Update workflow for new package name and test coverage     
+2/-2     
.gitlab-ci.yml
Update CI test coverage for new package name                         
+1/-1     
FILES
Regenerate file list for new package structure and models
+32/-26 
.travis.yml
Update test script for new package name                                   
+1/-1     
pyproject.toml
Update project name and include for new package                   
+4/-4     
setup.py
Update package name, version, and data for new package     
+3/-3     
tox.ini
Update test coverage for new package name                               
+1/-1     
Documentation
20 files
README.md
Update documentation for new package name and usage           
+19/-16 
ChangeQuotaApi.md
Update API doc for new package name                                           
+7/-7     
CreateAliasApi.md
Update API doc for new package name                                           
+7/-7     
DeleteAliasApi.md
Update API doc for new package name                                           
+7/-7     
DeleteEmailApi.md
Update API doc for new package name                                           
+7/-7     
DnsInfoApi.md
Document DNS Info API with new models and usage                   
+22/-14 
DnsInfoCreate200Response.md
Add documentation for DNS Info response model                       
+30/-0   
DnsInfoCreateRequest.md
Add documentation for DNS Info request model                         
+31/-0   
DomainAliasApi.md
Update API doc for new package name                                           
+7/-7     
DomainApi.md
Update API doc for new package name                                           
+7/-7     
DomainInfoApi.md
Update API doc for new package name                                           
+7/-7     
GetTokenApi.md
Update API doc for new package name and imports                   
+9/-9     
ImportApi.md
Update API doc for new package name                                           
+7/-7     
RefreshTokenApi.md
Update API doc for new package name and imports                   
+9/-9     
ResetPasswordApi.md
Update API doc for new package name                                           
+7/-7     
SubscriptionInfoApi.md
Update API doc for new package name                                           
+7/-7     
SubscriptionsApi.md
Update API doc for new package name and imports                   
+25/-25 
TokenObtainPair.md
Update model doc for new package name                                       
+1/-1     
TokenRefresh.md
Update model doc for new package name                                       
+1/-1     
UpgradeApi.md
Update API doc for new package name                                           
+7/-7     
Enhancement
30 files
__init__.py
Remove old package init file                                                         
+0/-50   
__init__.py
Remove old API package init file                                                 
+0/-19   
__init__.py
Remove old models package init file                                           
+0/-19   
__init__.py
Add new package init with API/model imports                           
+52/-0   
__init__.py
Add new API package init file                                                       
+19/-0   
change_quota_api.py
Refactor imports to new package structure                               
+3/-3     
create_alias_api.py
Refactor imports to new package structure                               
+3/-3     
delete_alias_api.py
Refactor imports to new package structure                               
+3/-3     
delete_email_api.py
Refactor imports to new package structure                               
+3/-3     
dns_info_api.py
Add DNS Info API with request/response models and serialization
+48/-11 
domain_alias_api.py
Refactor imports to new package structure                               
+3/-3     
domain_api.py
Refactor imports to new package structure                               
+3/-3     
domain_info_api.py
Refactor imports to new package structure                               
+3/-3     
get_token_api.py
Refactor imports to new package structure                               
+4/-4     
import_api.py
Refactor imports to new package structure                               
+3/-3     
refresh_token_api.py
Refactor imports to new package structure                               
+4/-4     
reset_password_api.py
Refactor imports to new package structure                               
+3/-3     
subscription_info_api.py
Refactor imports to new package structure                               
+3/-3     
subscriptions_api.py
Refactor imports to new package structure                               
+3/-3     
upgrade_api.py
Refactor imports to new package structure                               
+3/-3     
api_client.py
Refactor client for new package and model imports               
+6/-6     
api_response.py
Add generic API response object class                                       
[link]   
configuration.py
Refactor configuration for new package and logging             
+2/-2     
exceptions.py
Add detailed exception classes for API errors                       
[link]   
__init__.py
Add new models package init with DNS Info models                 
+21/-0   
dns_info_create200_response.py
Add DNS Info response model with serialization                     
+90/-0   
dns_info_create_request.py
Add DNS Info request model with serialization                       
+92/-0   
token_obtain_pair.py
Add/refactor token obtain pair model for new package         
[link]   
token_refresh.py
Add/refactor token refresh model for new package                 
[link]   
rest.py
Refactor REST client for new package and exceptions           
+1/-1     
Tests
19 files
test_change_quota_api.py
Update imports for new package structure                                 
+1/-1     
test_create_alias_api.py
Update imports for new package structure                                 
+1/-1     
test_delete_alias_api.py
Update imports for new package structure                                 
+1/-1     
test_delete_email_api.py
Update imports for new package structure                                 
+1/-1     
test_dns_info_api.py
Update imports for new package structure                                 
+1/-1     
test_dns_info_create200_response.py
Add unit test for DNS Info response model                               
+53/-0   
test_dns_info_create_request.py
Add unit test for DNS Info request model                                 
+57/-0   
test_domain_alias_api.py
Update imports for new package structure                                 
+1/-1     
test_domain_api.py
Update imports for new package structure                                 
+1/-1     
test_domain_info_api.py
Update imports for new package structure                                 
+1/-1     
test_get_token_api.py
Update imports for new package structure                                 
+1/-1     
test_import_api.py
Update imports for new package structure                                 
+1/-1     
test_refresh_token_api.py
Update imports for new package structure                                 
+1/-1     
test_reset_password_api.py
Update imports for new package structure                                 
+1/-1     
test_subscription_info_api.py
Update imports for new package structure                                 
+1/-1     
test_subscriptions_api.py
Update imports for new package structure                                 
+1/-1     
test_token_obtain_pair.py
Update imports for new package structure                                 
+1/-1     
test_token_refresh.py
Update imports for new package structure                                 
+1/-1     
test_upgrade_api.py
Update imports for new package structure                                 
+1/-1     
Additional files
2 files
.DS_Store [link]   
py.typed [link]   

Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @patienceigiraneza patienceigiraneza merged commit 8cf186c into main Jun 3, 2025
    10 checks passed
    @qodo-code-review
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Error Handling

    The ApiException.from_response method creates specific exception instances but doesn't handle all possible HTTP status codes. Consider adding a default case or handling additional common status codes like 429 (Too Many Requests).

    @classmethod
    def from_response(
        cls, 
        *, 
        http_resp, 
        body: Optional[str], 
        data: Optional[Any],
    ) -> Self:
        if http_resp.status == 400:
            raise BadRequestException(http_resp=http_resp, body=body, data=data)
    
        if http_resp.status == 401:
            raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
    
        if http_resp.status == 403:
            raise ForbiddenException(http_resp=http_resp, body=body, data=data)
    
        if http_resp.status == 404:
            raise NotFoundException(http_resp=http_resp, body=body, data=data)
    
        # Added new conditions for 409 and 422
        if http_resp.status == 409:
            raise ConflictException(http_resp=http_resp, body=body, data=data)
    
        if http_resp.status == 422:
            raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data)
    
        if 500 <= http_resp.status <= 599:
            raise ServiceException(http_resp=http_resp, body=body, data=data)
        raise ApiException(http_resp=http_resp, body=body, data=data)
    Input Validation

    The DnsInfoCreateRequest model uses StrictStr for fields but doesn't include any validation for email format or domain name format, which could lead to invalid data being sent to the API.

    domain: StrictStr = Field(description="Domain name")
    client_id: StrictStr = Field(description="Client id")
    email: StrictStr = Field(description="Email")
    __properties: ClassVar[List[str]] = ["domain", "client_id", "email"]
    Response Handling

    The API response status code mapping was changed from 201 to 200, but there's no handling for potential backward compatibility issues if the server still returns 201 status codes.

    _response_types_map: Dict[str, Optional[str]] = {
        '200': "DnsInfoCreate200Response",
    }

    @qodo-code-review
    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Fix serialization of optional field

    The access field is incorrectly marked as excluded in the to_dict() method.
    According to the model definition, access is an optional field that should be
    included in the serialized output when present, not a read-only field that
    should be excluded.

    workplace_console_client/models/token_refresh.py [67-75]

     def to_dict(self) -> Dict[str, Any]:
         """Return the dictionary representation of the model using alias.
     
         This has the following differences from calling pydantic's
         `self.model_dump(by_alias=True)`:
     
         * `None` is only added to the output dict for nullable fields that
           were set at model initialization. Other fields with value `None`
           are ignored.
         * OpenAPI `readOnly` fields are excluded.
         """
         excluded_fields: Set[str] = set([
    -        "access",
         ])
     
         _dict = self.model_dump(
             by_alias=True,
             exclude=excluded_fields,
             exclude_none=True,
         )
         return _dict

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 6

    __

    Why: The suggestion correctly identifies that the access field is being excluded from serialization when it should be included as an optional field. This could lead to data loss during serialization.

    Low
    Fix missing return value

    The from_response method doesn't return a value when an exception is raised.
    Since the method is annotated to return Self, it should return an instance of
    the class when no specific exception is raised.

    workplace_console_client/exceptions.py [163]

     @classmethod
     def from_response(
         cls, 
         *, 
         http_resp, 
         body: Optional[str], 
         data: Optional[Any],
     ) -> Self:
         if http_resp.status == 400:
             raise BadRequestException(http_resp=http_resp, body=body, data=data)
     
         if http_resp.status == 401:
             raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
     
         if http_resp.status == 403:
             raise ForbiddenException(http_resp=http_resp, body=body, data=data)
     
         if http_resp.status == 404:
             raise NotFoundException(http_resp=http_resp, body=body, data=data)
     
         # Added new conditions for 409 and 422
         if http_resp.status == 409:
             raise ConflictException(http_resp=http_resp, body=body, data=data)
     
         if http_resp.status == 422:
             raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data)
     
         if 500 <= http_resp.status <= 599:
             raise ServiceException(http_resp=http_resp, body=body, data=data)
    -    raise ApiException(http_resp=http_resp, body=body, data=data)
    +    return cls(http_resp=http_resp, body=body, data=data)

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 5

    __

    Why: The method signature indicates it should return Self, but the final line raises an exception instead. However, this might be intentional design since ApiException is the base exception class.

    Low
    General
    Synchronize version numbers

    The version in init.py is "1.0.0" but in setup.py it's "1.0.1". These
    versions should be synchronized to avoid confusion and ensure consistent
    versioning across the package.

    workplace_console_client/init.py [18]

    -__version__ = "1.0.0"
    +__version__ = "1.0.1"

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 6

    __

    Why: Version inconsistency between __init__.py ("1.0.0") and setup.py ("1.0.1") should be fixed to ensure consistent package versioning across the codebase.

    Low
    • More

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    1 participant