-
Notifications
You must be signed in to change notification settings - Fork 13
Cloning, Model Validation #39
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
base: main
Are you sure you want to change the base?
Conversation
git_provider_webhook: Optional[bool] = None | ||
|
||
|
||
class Job(BaseModel): |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
No description provided.