Skip to content

Update Generated Code

Method

REST method is adopted.

HTTP Method

PUT: Update generated code information

Naming Convention

To unify the naming of query parameters and nodes and improve readability, snake_case is used for URIs and JSON nodes in requests.

Request and Response

Headers

Meta information is set in HTTP headers, not in the response body.

Request Headers

  • Authorization
  • Content-Type
  • Accept
  • Accept-language

Response Headers

  • Content-Type

Update Generated Code Information

URI

PUT /v1/organizations/{organization_id}/projects/{project_id}/generated_codes/{code_id}

Path Parameters

Name Type Required Description
organization_id string Required Organization UUID
project_id string Required Project UUID
code_id string Required Generated code UUID

Request Body

The request body is JSON.

{
  "source_code": "const UpdatedComponent = () => { return <div>Updated</div>; }",
  "status": 2
}

Request Parameters

Name Type Required Description
source_code string Optional Updated source code
status number Optional Processing status (0-3)

Response

The response is JSON.

{
  "id": "generated-code-uuid",
  "projectId": "project-uuid",
  "sourceCode": "const UpdatedComponent = () => { return <div>Updated</div>; }",
  "status": 2,
  "createdAt": 1234567890000,
  "updatedAt": 1234567899999,
  "deletedAt": null,
  "createdBy": "user-id",
  "updatedBy": "updater-id",
  "deletedBy": null
}

Authentication

Authentication is performed using JSON Web Tokens (JWT) issued by Amazon Cognito.

Error Handling

The status codes for error handling are as follows.

Description Status Code Status Name
Invalid data 400 Bad Request
Missing credentials 401 Unauthorized
Insufficient permissions 403 Forbidden
Generated code, project, or organization not found 404 Not Found
Internal server error 500 Internal Server Error

Processing Flow

  1. Extract organization ID, project ID, and code ID from path parameters
  2. Extract update fields from request body
  3. Verify the user has access to the project
  4. Update the generated code in the database
  5. Return updated generated code information

Detailed Flowchart

flowchart TD
    Start([PUT Request]) --> Auth[Auth & Parameter Extraction]
    Auth --> Service[Service Layer]
    Service --> AccessCheck[Access Check]
    AccessCheck --> HasAccess{Write permission?}
    HasAccess -->|No| Err404[404 Not Found]
    HasAccess -->|Yes| ValidateFields{At least 1 field?}
    ValidateFields -->|No| Err400[400 Bad Request]
    ValidateFields -->|Yes| CheckExist[Check existing]
    CheckExist --> Exists{Exists?}
    Exists -->|No| Err404
    Exists -->|Yes| UpdateDB[DB Update<br/>Transaction]
    UpdateDB --> Success[200 OK]