[SILO-1026] feat: add estimates external API endpoints (#8664)
* add project summary endpoint * update response structure * add estimates external API endpoints with migrations * fix invalid project and workspace error
This commit is contained in:
parent
d7c80885fd
commit
9fa707b260
10 changed files with 504 additions and 11 deletions
|
|
@ -47,6 +47,7 @@ from .parameters import (
|
|||
CYCLE_VIEW_PARAMETER,
|
||||
FIELDS_PARAMETER,
|
||||
EXPAND_PARAMETER,
|
||||
ESTIMATE_ID_PARAMETER,
|
||||
)
|
||||
|
||||
# Responses
|
||||
|
|
@ -126,6 +127,10 @@ from .examples import (
|
|||
STATE_UPDATE_EXAMPLE,
|
||||
INTAKE_ISSUE_CREATE_EXAMPLE,
|
||||
INTAKE_ISSUE_UPDATE_EXAMPLE,
|
||||
ESTIMATE_CREATE_EXAMPLE,
|
||||
ESTIMATE_UPDATE_EXAMPLE,
|
||||
ESTIMATE_POINT_CREATE_EXAMPLE,
|
||||
ESTIMATE_POINT_UPDATE_EXAMPLE,
|
||||
# Response Examples
|
||||
CYCLE_EXAMPLE,
|
||||
TRANSFER_CYCLE_ISSUE_SUCCESS_EXAMPLE,
|
||||
|
|
@ -145,6 +150,8 @@ from .examples import (
|
|||
PROJECT_MEMBER_EXAMPLE,
|
||||
CYCLE_ISSUE_EXAMPLE,
|
||||
STICKY_EXAMPLE,
|
||||
ESTIMATE_EXAMPLE,
|
||||
ESTIMATE_POINT_EXAMPLE,
|
||||
)
|
||||
|
||||
# Helper decorators
|
||||
|
|
@ -166,6 +173,8 @@ from .decorators import (
|
|||
module_docs,
|
||||
module_issue_docs,
|
||||
state_docs,
|
||||
estimate_docs,
|
||||
estimate_point_docs,
|
||||
)
|
||||
|
||||
# Schema processing hooks
|
||||
|
|
@ -207,6 +216,7 @@ __all__ = [
|
|||
"CYCLE_VIEW_PARAMETER",
|
||||
"FIELDS_PARAMETER",
|
||||
"EXPAND_PARAMETER",
|
||||
"ESTIMATE_ID_PARAMETER",
|
||||
# Responses
|
||||
"UNAUTHORIZED_RESPONSE",
|
||||
"FORBIDDEN_RESPONSE",
|
||||
|
|
@ -280,6 +290,10 @@ __all__ = [
|
|||
"STATE_UPDATE_EXAMPLE",
|
||||
"INTAKE_ISSUE_CREATE_EXAMPLE",
|
||||
"INTAKE_ISSUE_UPDATE_EXAMPLE",
|
||||
"ESTIMATE_CREATE_EXAMPLE",
|
||||
"ESTIMATE_UPDATE_EXAMPLE",
|
||||
"ESTIMATE_POINT_CREATE_EXAMPLE",
|
||||
"ESTIMATE_POINT_UPDATE_EXAMPLE",
|
||||
# Response Examples
|
||||
"CYCLE_EXAMPLE",
|
||||
"TRANSFER_CYCLE_ISSUE_SUCCESS_EXAMPLE",
|
||||
|
|
@ -299,6 +313,8 @@ __all__ = [
|
|||
"PROJECT_MEMBER_EXAMPLE",
|
||||
"CYCLE_ISSUE_EXAMPLE",
|
||||
"STICKY_EXAMPLE",
|
||||
"ESTIMATE_EXAMPLE",
|
||||
"ESTIMATE_POINT_EXAMPLE",
|
||||
# Decorators
|
||||
"workspace_docs",
|
||||
"project_docs",
|
||||
|
|
@ -317,6 +333,8 @@ __all__ = [
|
|||
"module_docs",
|
||||
"module_issue_docs",
|
||||
"state_docs",
|
||||
"estimate_docs",
|
||||
"estimate_point_docs",
|
||||
# Hooks
|
||||
"preprocess_filter_api_v1_paths",
|
||||
"generate_operation_summary",
|
||||
|
|
|
|||
|
|
@ -297,3 +297,29 @@ def sticky_docs(**kwargs):
|
|||
}
|
||||
|
||||
return extend_schema(**_merge_schema_options(defaults, kwargs))
|
||||
|
||||
def estimate_docs(**kwargs):
|
||||
"""Decorator for estimate-related endpoints"""
|
||||
defaults = {
|
||||
"tags": ["Estimates"],
|
||||
"parameters": [WORKSPACE_SLUG_PARAMETER, PROJECT_ID_PARAMETER],
|
||||
"responses": {
|
||||
401: UNAUTHORIZED_RESPONSE,
|
||||
403: FORBIDDEN_RESPONSE,
|
||||
404: NOT_FOUND_RESPONSE,
|
||||
},
|
||||
}
|
||||
return extend_schema(**_merge_schema_options(defaults, kwargs))
|
||||
|
||||
def estimate_point_docs(**kwargs):
|
||||
"""Decorator for estimate point-related endpoints"""
|
||||
defaults = {
|
||||
"tags": ["Estimate Points"],
|
||||
"parameters": [WORKSPACE_SLUG_PARAMETER, PROJECT_ID_PARAMETER],
|
||||
"responses": {
|
||||
401: UNAUTHORIZED_RESPONSE,
|
||||
403: FORBIDDEN_RESPONSE,
|
||||
404: NOT_FOUND_RESPONSE,
|
||||
},
|
||||
}
|
||||
return extend_schema(**_merge_schema_options(defaults, kwargs))
|
||||
|
|
@ -686,6 +686,69 @@ STICKY_EXAMPLE = OpenApiExample(
|
|||
},
|
||||
)
|
||||
|
||||
# Estimate Examples
|
||||
ESTIMATE_EXAMPLE = OpenApiExample(
|
||||
name="Estimate",
|
||||
value={
|
||||
"id": "550e8400-e29b-41d4-a716-446655440000",
|
||||
"name": "Estimate 1",
|
||||
"description": "Estimate 1 description",
|
||||
},
|
||||
description="Example response for an estimate",
|
||||
)
|
||||
|
||||
ESTIMATE_POINT_EXAMPLE = OpenApiExample(
|
||||
name="EstimatePoint",
|
||||
value={
|
||||
"id": "550e8400-e29b-41d4-a716-446655440000",
|
||||
"estimate": "550e8400-e29b-41d4-a716-446655440001",
|
||||
"key": 1,
|
||||
"value": "1",
|
||||
},
|
||||
description="Example response for an estimate point",
|
||||
)
|
||||
ESTIMATE_CREATE_EXAMPLE = OpenApiExample(
|
||||
name="EstimateCreateSerializer",
|
||||
value={
|
||||
"name": "Estimate 1",
|
||||
"description": "Estimate 1 description",
|
||||
},
|
||||
description="Example request for creating an estimate",
|
||||
)
|
||||
ESTIMATE_UPDATE_EXAMPLE = OpenApiExample(
|
||||
name="EstimateUpdateSerializer",
|
||||
value={
|
||||
"name": "Estimate 1",
|
||||
"description": "Estimate 1 description",
|
||||
},
|
||||
description="Example request for updating an estimate",
|
||||
)
|
||||
|
||||
# Estimate Point Examples
|
||||
ESTIMATE_POINT_CREATE_EXAMPLE = OpenApiExample(
|
||||
name="EstimatePointCreateSerializer",
|
||||
value=[
|
||||
{
|
||||
"value": "1",
|
||||
"description": "Estimate Point 1 description",
|
||||
},
|
||||
{
|
||||
"value": "2",
|
||||
"description": "Estimate Point 2 description",
|
||||
},
|
||||
],
|
||||
description="Example request for creating an estimate point",
|
||||
)
|
||||
ESTIMATE_POINT_UPDATE_EXAMPLE = OpenApiExample(
|
||||
name="EstimatePointUpdateSerializer",
|
||||
value={
|
||||
"value": "1",
|
||||
"description": "Estimate Point 1 description",
|
||||
},
|
||||
description="Example request for updating an estimate point",
|
||||
)
|
||||
|
||||
|
||||
# Sample data for different entity types
|
||||
SAMPLE_ISSUE = {
|
||||
"id": "550e8400-e29b-41d4-a716-446655440000",
|
||||
|
|
@ -801,6 +864,24 @@ SAMPLE_STICKY = {
|
|||
"created_at": "2024-01-01T10:30:00Z",
|
||||
}
|
||||
|
||||
SAMPLE_ESTIMATE = {
|
||||
"id": "550e8400-e29b-41d4-a716-446655440000",
|
||||
"name": "Estimate 1",
|
||||
"description": "Estimate 1 description",
|
||||
"type": "categories",
|
||||
"last_used": False,
|
||||
"created_at": "2024-01-01T10:30:00Z",
|
||||
}
|
||||
|
||||
SAMPLE_ESTIMATE_POINT = {
|
||||
"id": "550e8400-e29b-41d4-a716-446655440000",
|
||||
"estimate": "550e8400-e29b-41d4-a716-446655440001",
|
||||
"key": 1,
|
||||
"value": "1",
|
||||
"description": "Estimate Point 1 description",
|
||||
"created_at": "2024-01-01T10:30:00Z",
|
||||
}
|
||||
|
||||
# Mapping of schema types to sample data
|
||||
SCHEMA_EXAMPLES = {
|
||||
"Issue": SAMPLE_ISSUE,
|
||||
|
|
@ -816,6 +897,8 @@ SCHEMA_EXAMPLES = {
|
|||
"Intake": SAMPLE_INTAKE,
|
||||
"CycleIssue": SAMPLE_CYCLE_ISSUE,
|
||||
"Sticky": SAMPLE_STICKY,
|
||||
"Estimate": SAMPLE_ESTIMATE,
|
||||
"EstimatePoint": SAMPLE_ESTIMATE_POINT,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -495,3 +495,11 @@ EXPAND_PARAMETER = OpenApiParameter(
|
|||
),
|
||||
],
|
||||
)
|
||||
|
||||
ESTIMATE_ID_PARAMETER = OpenApiParameter(
|
||||
name="estimate_id",
|
||||
description="Estimate ID",
|
||||
required=True,
|
||||
type=OpenApiTypes.UUID,
|
||||
location=OpenApiParameter.PATH,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue