From: Kiran Kamineni Date: Mon, 5 Mar 2018 20:57:22 +0000 (-0800) Subject: Updating api documentation X-Git-Tag: 2.0.0-ONAP~71 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aaf%2Fsms.git;a=commitdiff_plain;h=5a4dfbf75e292a03d73c5a7690d78547b45ffc88 Updating api documentation Updating API documentation to add login, status and unseal end points Issue-ID: AAF-121 Change-Id: I073d970aa779353a34236e61692ca67f380084b6 Signed-off-by: Kiran Kamineni --- diff --git a/sms-service/doc/api_swagger.html b/sms-service/doc/api_swagger.html new file mode 100644 index 0000000..94a72aa --- /dev/null +++ b/sms-service/doc/api_swagger.html @@ -0,0 +1,724 @@ + + + + Secret Management Service + + + +

Secret Management Service

+
This is a service that provides secret management facilities
+
More information:
+ +
Version: 1.0.0
+
BasePath:/v1/sms/
+
Apache 2.0
+
http://www.apache.org/licenses/LICENSE-2.0.html
+

Access

+
    +
  1. APIKey KeyParamName:token KeyInQuery:false KeyInHeader:true
  2. +
+ +

Methods

+ [ Jump to Models ] + +

Table of Contents

+
+

Domain

+ +

Login

+ +

Secret

+ +

System

+ + +

Domain

+
+
+ Up +
delete /domain/{domainName}
+
Deletes a domain by name (domainDomainNameDelete)
+
Deletes a domain with provided name
+ +

Path parameters

+
+
domainName (required)
+ +
Path Parameter — Name of the domain
+
+ + + + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    +
  • application/json
  • +
+ +

Responses

+

204

+ Successful Deletion + +

404

+ Invalid Path or Path not found + +
+
+
+
+ Up +
post /domain
+
Add a new domain (domainPost)
+
+ + +

Consumes

+ This API call consumes the following media types via the Content-Type request header: +
    +
  • application/json
  • +
+ +

Request body

+
+
body Domain (required)
+ +
Body Parameter
+ +
+ + + + +

Return type

+
+ Domain + +
+ + + +

Example data

+
Content-Type: application/json
+
{
+  "name" : "aeiou",
+  "uuid" : "aeiou"
+}
+ +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    +
  • application/json
  • +
+ +

Responses

+

201

+ Successful Creation + Domain +

400

+ Invalid input + +

500

+ Internal Server Error + +
+
+

Login

+
+
+ Up +
post /login
+
Login with username and password (loginPost)
+
Operations related to logging in via username and Password
+ + +

Consumes

+ This API call consumes the following media types via the Content-Type request header: +
    +
  • application/json
  • +
+ +

Request body

+
+
body Credential (required)
+ +
Body Parameter
+ +
+ + + + +

Return type

+ + + + +

Example data

+
Content-Type: application/json
+
{
+  "ttl" : 0,
+  "token" : "aeiou"
+}
+ +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    +
  • application/json
  • +
+ +

Responses

+

200

+ Successful Login returns a token + inline_response_200 +

404

+ Invalid Username or Password + +
+
+

Secret

+
+
+ Up +
get /domain/{domainName}/secret
+
List secret Names in this domain (domainDomainNameSecretGet)
+
Gets all secret names in this domain
+ +

Path parameters

+
+
domainName (required)
+ +
Path Parameter — Name of the domain in which to look at
+
+ + + + + + +

Return type

+
+ + array[String] +
+ + + +

Example data

+
Content-Type: application/json
+
[ "secret1", "secret2", "secret3" ]
+ +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    +
  • application/json
  • +
+ +

Responses

+

200

+ Successful operation + +

404

+ Invalid Path or Path not found + +
+
+
+
+ Up +
post /domain/{domainName}/secret
+
Add a new secret (domainDomainNameSecretPost)
+
+ +

Path parameters

+
+
domainName (required)
+ +
Path Parameter — Name of the domain
+
+ +

Consumes

+ This API call consumes the following media types via the Content-Type request header: +
    +
  • application/json
  • +
+ +

Request body

+
+
body Secret (required)
+ +
Body Parameter
+ +
+ + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    +
  • application/json
  • +
+ +

Responses

+

201

+ Successful Creation + +

404

+ Invalid Path or Path not found + +
+
+
+
+ Up +
delete /domain/{domainName}/secret/{secretName}
+
Deletes a Secret (domainDomainNameSecretSecretNameDelete)
+
+ +

Path parameters

+
+
secretName (required)
+ +
Path Parameter — Name of Secret to Delete
domainName (required)
+ +
Path Parameter — Path to the SecretDomain which contains the Secret
+
+ + + + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    +
  • application/json
  • +
+ +

Responses

+

204

+ Successful Deletion + +

404

+ Invalid Path or Path not found + +
+
+
+
+ Up +
get /domain/{domainName}/secret/{secretName}
+
Find Secret by Name (domainDomainNameSecretSecretNameGet)
+
Returns a single secret
+ +

Path parameters

+
+
domainName (required)
+ +
Path Parameter — Name of the domain in which to look at
secretName (required)
+ +
Path Parameter — Name of the secret which is needed
+
+ + + + + + +

Return type

+
+ Secret + +
+ + + +

Example data

+
Content-Type: application/json
+
{
+  "values" : {
+    "name" : "john",
+    "Age" : 40,
+    "admin" : true
+  },
+  "name" : "aeiou"
+}
+ +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    +
  • application/json
  • +
+ +

Responses

+

200

+ successful operation + Secret +

404

+ Invalid Path or Path not found + +
+
+

System

+
+
+ Up +
get /status
+
Get backend status (statusGet)
+
Gets current backend status. This API is used only by quorum clients
+ + + + + + + +

Return type

+ + + + +

Example data

+
Content-Type: application/json
+
{
+  "sealstatus" : "aeiou"
+}
+ +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    +
  • application/json
  • +
+ +

Responses

+

200

+ Successful operation + inline_response_200_1 +

404

+ Invalid Path or Path not found + +
+
+
+
+ Up +
post /unseal
+
Unseal backend (unsealPost)
+
Sends unseal shard to unseal if backend is sealed
+ + +

Consumes

+ This API call consumes the following media types via the Content-Type request header: +
    +
  • application/json
  • +
+ +

Request body

+
+
body body (required)
+ +
Body Parameter
+ +
+ + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    +
  • application/json
  • +
+ +

Responses

+

201

+ Submitted unseal key + +

404

+ Invalid Path or Path not found + +
+
+ +

Models

+ [ Jump to Methods ] + +

Table of Contents

+
    +
  1. Credential -
  2. +
  3. Domain -
  4. +
  5. Secret -
  6. +
  7. body -
  8. +
  9. inline_response_200 -
  10. +
  11. inline_response_200_1 -
  12. +
+ +
+

Credential - Up

+
+
+
username (optional)
+
password (optional)
+
+
+
+

Domain - Up

+
+
+
uuid (optional)
String Optional value provided by user. If user does not provide, server will auto generate
+
name (optional)
String Name of the secret domain under which all secrets will be stored
+
+
+
+

Secret - Up

+
+
+
name (optional)
String Name of the secret
+
values (optional)
map[String, Object] Map of key value pairs that constitute the secret
+
+
+
+

body - Up

+ +
+
unsealshard (optional)
String Unseal shard that will be used along with other shards to unseal backend
+
+
+
+

inline_response_200 - Up

+ +
+
token (optional)
+
ttl (optional)
Integer ttl of returned token in seconds
+
+
+
+

inline_response_200_1 - Up

+ +
+
sealstatus (optional)
String seal status of backend
+
+
+ + diff --git a/sms-service/doc/api_swagger.yaml b/sms-service/doc/api_swagger.yaml index 5e0b792..08e3c18 100644 --- a/sms-service/doc/api_swagger.yaml +++ b/sms-service/doc/api_swagger.yaml @@ -8,9 +8,11 @@ info: license: name: Apache 2.0 url: 'http://www.apache.org/licenses/LICENSE-2.0.html' -host: 'aaf.onap.org:8000' +host: 'aaf.onap.org:10443' basePath: /v1/sms/ tags: + - name: system + description: Operations related to quorum client which are not useful to clients - name: login description: Operations related to username password based authentication - name: domain @@ -24,9 +26,8 @@ paths: post: tags: - login - summary: "Login with username and password" - description: 'Operations related to logging in via username and Password' - operationId: loginUser + summary: Login with username and password + description: Operations related to logging in via username and Password consumes: - application/json produces: @@ -39,18 +40,67 @@ paths: $ref: '#/definitions/Credential' responses: '200': - description: "Successful Login" + description: Successful Login returns a token schema: - type: "string" + type: object + properties: + token: + type: string + ttl: + type: integer + description: ttl of returned token in seconds '404': - description: "Invalid Username or Password" + description: Invalid Username or Password + /status: + get: + tags: + - system + description: Gets current backend status. This API is used only by quorum clients + summary: Get backend status + produces: + - application/json + responses: + '200': + description: Successful operation + schema: + type: object + properties: + sealstatus: + type: string + description: seal status of backend + '404': + description: Invalid Path or Path not found + /unseal: + post: + tags: + - system + description: Sends unseal shard to unseal if backend is sealed + summary: Unseal backend + consumes: + - application/json + produces: + - application/json + parameters: + - in: body + name: body + required: true + schema: + type: object + properties: + unsealshard: + type: string + description: Unseal shard that will be used along with other shards to unseal backend + responses: + '201': + description: Submitted unseal key + '404': + description: Invalid Path or Path not found /domain: post: tags: - domain summary: Add a new domain description: '' - operationId: addDomain consumes: - application/json produces: @@ -62,38 +112,20 @@ paths: schema: $ref: '#/definitions/Domain' responses: - '200': + '201': description: Successful Creation schema: $ref: '#/definitions/Domain' - '405': + '400': description: Invalid input + '500': + description: Internal Server Error '/domain/{domainName}': - get: - tags: - - domain - description: Gets domain information by name - operationId: getDomainByName - produces: - - application/json - parameters: - - name: domainName - in: path - description: Name of the domain - required: true - type: string - responses: - '200': - description: successful operation - schema: - $ref: '#/definitions/Domain' - '404': - description: Invalid Path or Path not found delete: tags: - domain description: Deletes a domain with provided name - operationId: deleteDomainByName + summary: Deletes a domain by name produces: - application/json parameters: @@ -113,7 +145,6 @@ paths: - secret summary: Add a new secret description: '' - operationId: addSecretInDomain consumes: - application/json produces: @@ -130,17 +161,15 @@ paths: schema: $ref: '#/definitions/Secret' responses: - '200': + '201': description: Successful Creation - schema: - $ref: '#/definitions/Secret' '404': description: Invalid Path or Path not found get: tags: - secret - description: Gets all secrets in this domain - operationId: getAllSecretsInDomain + description: Gets all secret names in this domain + summary: List secret Names in this domain produces: - application/json parameters: @@ -151,11 +180,12 @@ paths: type: string responses: '200': - description: successful operation + description: Successful operation schema: - type: "array" + type: array items: - $ref: '#/definitions/Secret' + type: string + example: ['secret1', 'secret2', 'secret3'] '404': description: Invalid Path or Path not found '/domain/{domainName}/secret/{secretName}': @@ -164,7 +194,6 @@ paths: - secret summary: Find Secret by Name description: Returns a single secret - operationId: getSecretByName produces: - application/json parameters: @@ -190,7 +219,6 @@ paths: - secret summary: Deletes a Secret description: '' - operationId: deleteSecret produces: - application/json parameters: @@ -209,14 +237,19 @@ paths: description: Successful Deletion '404': description: Invalid Path or Path not found +securityDefinitions: + token: + type: "apiKey" + name: "token" + in: "header" definitions: Credential: type: object properties: username: - type: "string" + type: string password: - type: "string" + type: string Domain: type: object properties: @@ -229,21 +262,20 @@ definitions: type: string description: Name of the secret domain under which all secrets will be stored Secret: - type: "object" + type: object properties: name: - type: "string" + type: string description: Name of the secret - value: - type: "array" - description: Array of key value pairs that constitute the secret - items: - type: "object" - properties: - key: - type: "string" - value: - type: "string" + values: + description: Map of key value pairs that constitute the secret + type: object + additionalProperties: + type: object + example: + "name": "john" + "Age": 40 + "admin": true externalDocs: description: Find out more about Swagger url: 'http://swagger.io' diff --git a/sms-service/src/sms/handler/handler.go b/sms-service/src/sms/handler/handler.go index dd124e9..fde6718 100644 --- a/sms-service/src/sms/handler/handler.go +++ b/sms-service/src/sms/handler/handler.go @@ -52,6 +52,8 @@ func (h handler) createSecretDomainHandler(w http.ResponseWriter, r *http.Reques http.Error(w, err.Error(), http.StatusInternalServerError) return } + + w.WriteHeader(http.StatusCreated) } // deleteSecretDomainHandler deletes a secret domain with the name provided @@ -64,6 +66,8 @@ func (h handler) deleteSecretDomainHandler(w http.ResponseWriter, r *http.Reques http.Error(w, err.Error(), http.StatusInternalServerError) return } + + w.WriteHeader(http.StatusNoContent) } // createSecretHandler handles creation of secrets on a given domain name