Skip to content

Commit

Permalink
Update pydantic models
Browse files Browse the repository at this point in the history
  • Loading branch information
DMalone87 committed Sep 26, 2024
1 parent 8439b12 commit 61a12b5
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 16 deletions.
7 changes: 7 additions & 0 deletions oas/gen_pydantic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

python oas_to_pydantic.py 2.0/sources.yaml pydantic/sources.py
python oas_to_pydantic.py 2.0/complaints.yaml pydantic/complaints.py
python oas_to_pydantic.py 2.0/officers.yaml pydantic/officers.py
python oas_to_pydantic.py 2.0/agencies.yaml pydantic/agencies.py
python oas_to_pydantic.py 2.0/litigation.yaml pydantic/litigation.py
5 changes: 1 addition & 4 deletions oas/pydantic/agencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


class BaseAgency(BaseModel):
uid: Optional[str] = Field(None, description="Unique identifier for the agency")
name: Optional[str] = Field(None, description="Name of the agency")
hq_address: Optional[str] = Field(None, description="Address of the agency")
hq_city: Optional[str] = Field(None, description="City of the agency")
Expand All @@ -16,7 +15,6 @@ class BaseAgency(BaseModel):


class CreateAgency(BaseAgency, BaseModel):
uid: Optional[str] = Field(None, description="Unique identifier for the agency")
name: Optional[str] = Field(None, description="Name of the agency")
hq_address: Optional[str] = Field(None, description="Address of the agency")
hq_city: Optional[str] = Field(None, description="City of the agency")
Expand All @@ -29,7 +27,6 @@ class CreateAgency(BaseAgency, BaseModel):


class UpdateAgency(BaseAgency, BaseModel):
uid: Optional[str] = Field(None, description="Unique identifier for the agency")
name: Optional[str] = Field(None, description="Name of the agency")
hq_address: Optional[str] = Field(None, description="Address of the agency")
hq_city: Optional[str] = Field(None, description="City of the agency")
Expand All @@ -46,7 +43,6 @@ class AgencyList(PaginatedResponse, BaseModel):


class Agency(BaseAgency, BaseModel):
uid: Optional[str] = Field(None, description="Unique identifier for the agency")
name: Optional[str] = Field(None, description="Name of the agency")
hq_address: Optional[str] = Field(None, description="Address of the agency")
hq_city: Optional[str] = Field(None, description="City of the agency")
Expand All @@ -56,6 +52,7 @@ class Agency(BaseAgency, BaseModel):
phone: Optional[str] = Field(None, description="Phone number of the agency")
email: Optional[str] = Field(None, description="Email of the agency")
website_url: Optional[str] = Field(None, description="Website of the agency")
uid: Optional[str] = Field(None, description="Unique identifier for the agency")
officers_url: Optional[str] = Field(None, description="URL to get a list of officers for this agency")
units_url: Optional[str] = Field(None, description="URL to get a list of units for this agency")

Expand Down
25 changes: 19 additions & 6 deletions oas/pydantic/complaints.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

class BaseComplaint(BaseModel):
"""Base complaint object"""
record_id: Optional[str] = Field(None, description="The ID that was given to this complaint by the orginal source of the data.")
source_details: Optional[SourceDetails] = None
category: Optional[str] = Field(None, description="The category of the complaint.")
incident_date: Optional[str] = Field(None, description="The date and time the incident occurred.")
recieved_date: Optional[str] = Field(None, description="The date and time the complaint was received by the reporting partner.")
recieved_date: Optional[str] = Field(None, description="The date and time the complaint was received by the reporting source.")
closed_date: Optional[str] = Field(None, description="The date and time the complaint was closed.")
location: Optional[Dict[str, Any]] = None
reason_for_contact: Optional[str] = Field(None, description="The reason for the contact.")
Expand All @@ -17,17 +18,18 @@ class BaseComplaint(BaseModel):


class CreateComplaint(BaseComplaint, BaseModel):
record_id: Optional[str] = Field(None, description="The ID that was given to this complaint by the orginal source of the data.")
source_details: Optional[SourceDetails] = None
category: Optional[str] = Field(None, description="The category of the complaint.")
incident_date: Optional[str] = Field(None, description="The date and time the incident occurred.")
recieved_date: Optional[str] = Field(None, description="The date and time the complaint was received by the reporting partner.")
recieved_date: Optional[str] = Field(None, description="The date and time the complaint was received by the reporting source.")
closed_date: Optional[str] = Field(None, description="The date and time the complaint was closed.")
location: Optional[Dict[str, Any]] = None
reason_for_contact: Optional[str] = Field(None, description="The reason for the contact.")
outcome_of_contact: Optional[str] = Field(None, description="The outcome of the contact.")
civilian_witnesses: Optional[List[Civilian]] = Field(None, description="The civilian witnesses associated with the complaint.")
attachements: Optional[List[Attachemnts]] = Field(None, description="Documents and multimeida associated with the complaint.")
source_uid: Optional[str] = Field(None, description="The UID of the partner that reported the complaint.")
source_uid: Optional[str] = Field(None, description="The UID of the source that reported the complaint.")
civilian_review_board_uid: Optional[str] = Field(None, description="The UID of the civilian review board that reviewed the complaint.")
police_witnesses: Optional[List[str]] = Field(None, description="The UID of any police witnesses associated with the complaint.")
allegations: Optional[List[CreateAllegation]] = Field(None, description="The allegations associated with the complaint.")
Expand All @@ -36,10 +38,11 @@ class CreateComplaint(BaseComplaint, BaseModel):


class UpdateComplaint(BaseComplaint, BaseModel):
record_id: Optional[str] = Field(None, description="The ID that was given to this complaint by the orginal source of the data.")
source_details: Optional[SourceDetails] = None
category: Optional[str] = Field(None, description="The category of the complaint.")
incident_date: Optional[str] = Field(None, description="The date and time the incident occurred.")
recieved_date: Optional[str] = Field(None, description="The date and time the complaint was received by the reporting partner.")
recieved_date: Optional[str] = Field(None, description="The date and time the complaint was received by the reporting source.")
closed_date: Optional[str] = Field(None, description="The date and time the complaint was closed.")
location: Optional[Dict[str, Any]] = None
reason_for_contact: Optional[str] = Field(None, description="The reason for the contact.")
Expand All @@ -54,10 +57,11 @@ class UpdateComplaint(BaseComplaint, BaseModel):


class Complaint(BaseComplaint, BaseModel):
record_id: Optional[str] = Field(None, description="The ID that was given to this complaint by the orginal source of the data.")
source_details: Optional[SourceDetails] = None
category: str = Field(..., description="The category of the complaint.")
incident_date: str = Field(..., description="The date and time the incident occurred.")
recieved_date: str = Field(..., description="The date and time the complaint was received by the reporting partner.")
recieved_date: str = Field(..., description="The date and time the complaint was received by the reporting source.")
closed_date: Optional[str] = Field(None, description="The date and time the complaint was closed.")
location: Dict[str, Any] = ...
reason_for_contact: Optional[str] = Field(None, description="The reason for the contact.")
Expand All @@ -67,7 +71,7 @@ class Complaint(BaseComplaint, BaseModel):
uid: str = Field(..., description="Unique identifier for the complaint.")
created_at: str = Field(..., description="Date and time the complaint was created.")
updated_at: str = Field(..., description="Date and time the complaint was last updated.")
source: Optional[Partner] = Field(None, description="The partner that reported the complaint.")
source: Optional[Source] = Field(None, description="The source that reported the complaint.")
civilian_review_board: Optional[ReviewBoard] = Field(None, description="The civilian review board that reviewed the complaint.")
police_witnesses: List[Officer] = Field(..., description="The police witnesses associated with the complaint.")
allegations: List[Allegation] = Field(..., description="The allegations associated with the complaint.")
Expand All @@ -80,17 +84,23 @@ class ComplaintList(PaginatedResponse, BaseModel):


class BaseAllegation(BaseModel):
record_id: Optional[str] = Field(None, description="The ID that was given to this allegation by the orginal source of the data.")
complaintant: Optional[Civilian] = Field(None, description="Demographic information of the individual who filed the complaint.")
allegation: Optional[str] = Field(None, description="The allegation made by the complaintant.")
type: Optional[str] = Field(None, description="The type of allegation.")
sub_type: Optional[str] = Field(None, description="The sub type of the allegation.")
recomended_finding: Optional[str] = Field(None, description="The finding recomended by the review board.")
recomended_outcome: Optional[str] = Field(None, description="The outcome recomended by the review board.")
finding: Optional[str] = Field(None, description="The legal finding.")
outcome: Optional[str] = Field(None, description="The final outcome of the allegation.")


class CreateAllegation(BaseAllegation, BaseModel):
record_id: Optional[str] = Field(None, description="The ID that was given to this allegation by the orginal source of the data.")
complaintant: Optional[Civilian] = Field(None, description="Demographic information of the individual who filed the complaint.")
allegation: Optional[str] = Field(None, description="The allegation made by the complaintant.")
type: Optional[str] = Field(None, description="The type of allegation.")
sub_type: Optional[str] = Field(None, description="The sub type of the allegation.")
recomended_finding: Optional[str] = Field(None, description="The finding recomended by the review board.")
recomended_outcome: Optional[str] = Field(None, description="The outcome recomended by the review board.")
finding: Optional[str] = Field(None, description="The legal finding.")
Expand All @@ -99,8 +109,11 @@ class CreateAllegation(BaseAllegation, BaseModel):


class Allegation(BaseAllegation, BaseModel):
record_id: Optional[str] = Field(None, description="The ID that was given to this allegation by the orginal source of the data.")
complaintant: Optional[Civilian] = Field(None, description="Demographic information of the individual who filed the complaint.")
allegation: Optional[str] = Field(None, description="The allegation made by the complaintant.")
type: Optional[str] = Field(None, description="The type of allegation.")
sub_type: Optional[str] = Field(None, description="The sub type of the allegation.")
recomended_finding: Optional[str] = Field(None, description="The finding recomended by the review board.")
recomended_outcome: Optional[str] = Field(None, description="The outcome recomended by the review board.")
finding: Optional[str] = Field(None, description="The legal finding.")
Expand Down
16 changes: 10 additions & 6 deletions oas/pydantic/officers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class BaseEmployment(BaseModel):
officer_uid: Optional[str] = Field(None, description="The UID of the officer.")
agency_uid: Optional[str] = Field(None, description="The UID of the agency the officer is employed by.")
unit_uid: Optional[str] = Field(None, description="The UID of the unit the officer is assigned to.")
earliest_employment: Optional[str] = Field(None, description="The earliest date of employment")
latest_employment: Optional[str] = Field(None, description="The latest date of employment")
earliest_employment: Optional[str] = Field(None, description="The earliest known date of employment")
latest_employment: Optional[str] = Field(None, description="The latest known date of employment")
badge_number: Optional[str] = Field(None, description="The badge number of the officer")
highest_rank: Optional[str] = Field(None, description="The highest rank the officer has held during this employment.")
commander: Optional[bool] = Field(None, description="Indicates that the officer commanded the unit during this employment.")
Expand All @@ -17,8 +17,8 @@ class AddEmployment(BaseEmployment, BaseModel):
officer_uid: Optional[str] = Field(None, description="The UID of the officer.")
agency_uid: Optional[str] = Field(None, description="The UID of the agency the officer is employed by.")
unit_uid: Optional[str] = Field(None, description="The UID of the unit the officer is assigned to.")
earliest_employment: Optional[str] = Field(None, description="The earliest date of employment")
latest_employment: Optional[str] = Field(None, description="The latest date of employment")
earliest_employment: Optional[str] = Field(None, description="The earliest known date of employment")
latest_employment: Optional[str] = Field(None, description="The latest known date of employment")
badge_number: Optional[str] = Field(None, description="The badge number of the officer")
highest_rank: Optional[str] = Field(None, description="The highest rank the officer has held during this employment.")
commander: Optional[bool] = Field(None, description="Indicates that the officer commanded the unit during this employment.")
Expand All @@ -37,8 +37,8 @@ class Employment(BaseEmployment, BaseModel):
officer_uid: Optional[str] = Field(None, description="The UID of the officer.")
agency_uid: Optional[str] = Field(None, description="The UID of the agency the officer is employed by.")
unit_uid: Optional[str] = Field(None, description="The UID of the unit the officer is assigned to.")
earliest_employment: Optional[str] = Field(None, description="The earliest date of employment")
latest_employment: Optional[str] = Field(None, description="The latest date of employment")
earliest_employment: Optional[str] = Field(None, description="The earliest known date of employment")
latest_employment: Optional[str] = Field(None, description="The latest known date of employment")
badge_number: Optional[str] = Field(None, description="The badge number of the officer")
highest_rank: Optional[str] = Field(None, description="The highest rank the officer has held during this employment.")
commander: Optional[bool] = Field(None, description="Indicates that the officer commanded the unit during this employment.")
Expand All @@ -59,6 +59,7 @@ class BaseOfficer(BaseModel):
first_name: Optional[str] = Field(None, description="First name of the officer")
middle_name: Optional[str] = Field(None, description="Middle name of the officer")
last_name: Optional[str] = Field(None, description="Last name of the officer")
suffix: Optional[str] = Field(None, description="Suffix of the officer's name")
ethnicity: Optional[str] = Field(None, description="The ethnicity of the officer")
gender: Optional[str] = Field(None, description="The gender of the officer")
date_of_birth: Optional[str] = Field(None, description="The date of birth of the officer")
Expand All @@ -69,6 +70,7 @@ class CreateOfficer(BaseOfficer, BaseModel):
first_name: Optional[str] = Field(None, description="First name of the officer")
middle_name: Optional[str] = Field(None, description="Middle name of the officer")
last_name: Optional[str] = Field(None, description="Last name of the officer")
suffix: Optional[str] = Field(None, description="Suffix of the officer's name")
ethnicity: Optional[str] = Field(None, description="The ethnicity of the officer")
gender: Optional[str] = Field(None, description="The gender of the officer")
date_of_birth: Optional[str] = Field(None, description="The date of birth of the officer")
Expand All @@ -79,6 +81,7 @@ class UpdateOfficer(BaseOfficer, BaseModel):
first_name: Optional[str] = Field(None, description="First name of the officer")
middle_name: Optional[str] = Field(None, description="Middle name of the officer")
last_name: Optional[str] = Field(None, description="Last name of the officer")
suffix: Optional[str] = Field(None, description="Suffix of the officer's name")
ethnicity: Optional[str] = Field(None, description="The ethnicity of the officer")
gender: Optional[str] = Field(None, description="The gender of the officer")
date_of_birth: Optional[str] = Field(None, description="The date of birth of the officer")
Expand All @@ -89,6 +92,7 @@ class Officer(BaseOfficer, BaseModel):
first_name: Optional[str] = Field(None, description="First name of the officer")
middle_name: Optional[str] = Field(None, description="Middle name of the officer")
last_name: Optional[str] = Field(None, description="Last name of the officer")
suffix: Optional[str] = Field(None, description="Suffix of the officer's name")
ethnicity: Optional[str] = Field(None, description="The ethnicity of the officer")
gender: Optional[str] = Field(None, description="The gender of the officer")
date_of_birth: Optional[str] = Field(None, description="The date of birth of the officer")
Expand Down
Loading

0 comments on commit 61a12b5

Please sign in to comment.