Skip to content

Conversation

dpguthrie
Copy link
Owner

No description provided.

@dpguthrie dpguthrie changed the title Feat/model validation Cloning, Model Validation Sep 27, 2022
git_provider_webhook: Optional[bool] = None


class Job(BaseModel):
Copy link
Owner Author

Choose a reason for hiding this comment

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

@matt-winkler Here's what I was thinking as far as doing validation for a particular resource. This is pydantic and it provides this validation out of the box when you provide the schema for the resource.


return 'api_key'

def _clone_resource(self, resource: str, **kwargs):
Copy link
Owner Author

Choose a reason for hiding this comment

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

@matt-winkler A private method that we can use for other resources we'd like to clone

"""Make request to API."""

# Model is not an argument that the request method accepts, needs to be removed
model = kwargs.pop('model', None)
Copy link
Owner Author

Choose a reason for hiding this comment

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

@matt-winkler This is where we would pull out the model, if it's been passed. And line 83 below will assign the validated model, with the appropriate defaults, back to the json key.

f'accounts/{account_id}/jobs/',
method='post',
json=payload,
model=models.Job,
Copy link
Owner Author

Choose a reason for hiding this comment

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

@matt-winkler This is where the appropriate model would be passed.

@dpguthrie dpguthrie marked this pull request as draft September 27, 2022 22:15
@dpguthrie dpguthrie mentioned this pull request Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants