-
Notifications
You must be signed in to change notification settings - Fork 12
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
Cloning, Model Validation #39
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.
@@ -77,10 +59,28 @@ def _header_property(self): | |||
|
|||
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
def _make_request( | ||
self, path: str, *, method: str = 'get', **kwargs | ||
) -> requests.Response: | ||
"""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.
@@ -291,6 +318,7 @@ def create_job(self, account_id: int, payload: Dict) -> Dict: | |||
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.