Skip to content

Commit

Permalink
rename schemas on engine API
Browse files Browse the repository at this point in the history
  • Loading branch information
lostbean committed Nov 17, 2023
1 parent 27ec28f commit e6b882a
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 93 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 26 additions & 33 deletions api/openapi/engine/engine_service.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
openapi: 3.0.0

info:
title: Engine API
version: 1.0.0
version: 0.1.0

paths:
/engine/info:
get:
Expand All @@ -12,7 +14,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/GetEngineInfoResponse'
$ref: '#/components/schemas/EngineInfo'

/enclaves:
get:
Expand All @@ -23,7 +25,12 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/GetEnclavesResponse'
type: object
properties:
enclave_info:
type: object
additionalProperties:
$ref: '#/components/schemas/EnclaveInfo'

post:
summary: Create Enclave
Expand All @@ -32,14 +39,14 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/CreateEnclaveArgs'
$ref: '#/components/schemas/CreateEnclave'
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/CreateEnclaveResponse'
$ref: '#/components/schemas/EnclaveInfo'

delete:
summary: Delete Enclaves
Expand All @@ -56,7 +63,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/DeleteResponse'
$ref: '#/components/schemas/DeletionSummary'

/enclaves/historical:
get:
Expand All @@ -67,7 +74,9 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/GetExistingAndHistoricalEnclaveIdentifiersResponse'
type: array
items:
$ref: '#/components/schemas/EnclaveIdentifiers'

/enclaves/{enclave_identifier}:
get:
Expand Down Expand Up @@ -148,33 +157,23 @@ paths:
schema:
type: object


# =========================================================================================================================
# =========================================================================================================================
# > > > > > > > > > > > > > > > > > > > > > > > > Data Models < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < <
# =========================================================================================================================
# =========================================================================================================================

components:

schemas:
GetEngineInfoResponse:

EngineInfo:
type: object
properties:
engine_version:
type: string

GetEnclavesResponse:
type: object
properties:
enclave_info:
type: object
additionalProperties:
$ref: '#/components/schemas/EnclaveInfo'

GetExistingAndHistoricalEnclaveIdentifiersResponse:
type: object
properties:
allIdentifiers:
type: array
items:
$ref: '#/components/schemas/EnclaveIdentifiers'

CreateEnclaveArgs:
CreateEnclave:
type: object
properties:
enclave_name:
Expand Down Expand Up @@ -206,12 +205,6 @@ components:
- STOPPED
- NON_EXISTENT

CreateEnclaveResponse:
type: object
properties:
enclave_info:
$ref: '#/components/schemas/EnclaveInfo'

EnclaveInfo:
type: object
properties:
Expand Down Expand Up @@ -273,7 +266,7 @@ components:
uuid:
type: string

DeleteResponse:
DeletionSummary:
type: object
properties:
removed_enclave_name_and_uuids:
Expand Down
21 changes: 9 additions & 12 deletions engine/server/engine/server/engine_rest_api_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (engine EngineRuntime) DeleteEnclaves(ctx context.Context, request api.Dele
}
}
removedApiResponse := utils.MapList(removedEnclaveUuidsAndNames, toHttpApiEnclaveNameAndUuid)
return api.DeleteEnclaves200JSONResponse(api.DeleteResponse{RemovedEnclaveNameAndUuids: &removedApiResponse}), nil
return api.DeleteEnclaves200JSONResponse(api.DeletionSummary{RemovedEnclaveNameAndUuids: &removedApiResponse}), nil
}

// Get Enclaves
Expand All @@ -186,8 +186,10 @@ func (engine EngineRuntime) GetEnclaves(ctx context.Context, request api.GetEncl
return nil, stacktrace.Propagate(err, "An error occurred getting info for enclaves")
}
info_map_http := toHttpApiEnclaveInfos(infoForEnclaves)
response := api.GetEnclavesResponse{EnclaveInfo: &info_map_http}
return api.GetEnclaves200JSONResponse(response), nil
response := api.GetEnclaves200JSONResponse{
EnclaveInfo: &info_map_http,
}
return response, nil
}

// Create Enclave
Expand Down Expand Up @@ -220,11 +222,7 @@ func (engine EngineRuntime) PostEnclaves(ctx context.Context, request api.PostEn
return nil, stacktrace.Propagate(err, "An error occurred creating new enclave with name '%v'", request.Body.EnclaveName)
}

grpcEnclaveInfo := toHttpApiEnclaveInfo(*enclaveInfo)
response := api.CreateEnclaveResponse{
EnclaveInfo: &grpcEnclaveInfo,
}

response := toHttpApiEnclaveInfo(*enclaveInfo)
return api.PostEnclaves200JSONResponse(response), nil
}

Expand All @@ -236,8 +234,7 @@ func (engine EngineRuntime) GetEnclavesHistorical(ctx context.Context, request a
return nil, stacktrace.Propagate(err, "An error occurred while fetching enclave identifiers")
}
identifiers_map_api := utils.MapList(allIdentifiers, toHttpApiEnclaveIdentifiers)
response := api.GetExistingAndHistoricalEnclaveIdentifiersResponse{AllIdentifiers: &identifiers_map_api}
return api.GetEnclavesHistorical200JSONResponse(response), nil
return api.GetEnclavesHistorical200JSONResponse(identifiers_map_api), nil
}

// Destroy Enclave
Expand Down Expand Up @@ -368,7 +365,7 @@ func (engine EngineRuntime) PostEnclavesEnclaveIdentifierStop(ctx context.Contex
// Get Engine Info
// (GET /engine/info)
func (engine EngineRuntime) GetEngineInfo(ctx context.Context, request api.GetEngineInfoRequestObject) (api.GetEngineInfoResponseObject, error) {
result := api.GetEngineInfoResponse{EngineVersion: &engine.ImageVersionTag}
result := api.EngineInfo{EngineVersion: &engine.ImageVersionTag}
return api.GetEngineInfo200JSONResponse(result), nil
}

Expand Down Expand Up @@ -440,7 +437,7 @@ func (service *EngineRuntime) reportAnyMissingUuidsAndGetNotFoundUuidsListHttp(

notFoundServiceUuidsMap := getNotFoundServiceUuidsAndEmptyServiceLogsMap(requestedServiceUuids, existingServiceUuids)
var notFoundServiceUuids []string
for service, _ := range notFoundServiceUuidsMap {
for service := range notFoundServiceUuidsMap {
notFoundServiceUuids = append(notFoundServiceUuids, service)
}
return notFoundServiceUuids, nil
Expand Down

0 comments on commit e6b882a

Please sign in to comment.