Skip to content

Commit

Permalink
Merge b46f3e2 into 8100a67
Browse files Browse the repository at this point in the history
  • Loading branch information
lcaparroz committed Apr 15, 2021
2 parents 8100a67 + b46f3e2 commit abe57ef
Show file tree
Hide file tree
Showing 16 changed files with 665 additions and 0 deletions.
15 changes: 15 additions & 0 deletions api_docs/http_server
@@ -0,0 +1,15 @@
#!/usr/bin/env python3
# encoding: utf-8
"""Run `python3 -m http.server` with CORS support"""

from http.server import HTTPServer, SimpleHTTPRequestHandler

class CORSRequestHandler(SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Access-Control-Allow-Methods', 'GET')
self.send_header('Cache-Control', 'no-store, no-cache, must-revalidate')
return super(CORSRequestHandler, self).end_headers()

httpd = HTTPServer(('localhost', 8080), CORSRequestHandler)
httpd.serve_forever()
56 changes: 56 additions & 0 deletions api_docs/swagger-ui/index.html
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Swagger UI</title>
<link
rel="stylesheet"
type="text/css"
href="https://unpkg.com/swagger-ui-dist@3/swagger-ui.css"
/>
<style>
html {
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}

*,
*:before,
*:after {
box-sizing: inherit;
}

body {
margin: 0;
background: #fafafa;
}
</style>
</head>

<body>
<div id="swagger-ui"></div>
<script
src="https://unpkg.com/swagger-ui-dist@3/swagger-ui-bundle.js"
charset="UTF-8"
></script>
<script
src="https://unpkg.com/swagger-ui-dist@3/swagger-ui-standalone-preset.js"
charset="UTF-8"
></script>
<script>
window.onload = function () {
const ui = SwaggerUIBundle({
url: "/swagger/swagger.yaml",
dom_id: "#swagger-ui",
deepLinking: true,
presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset],
plugins: [SwaggerUIBundle.plugins.DownloadUrl],
layout: "StandaloneLayout",
});

window.ui = ui;
};
</script>
</body>
</html>
30 changes: 30 additions & 0 deletions api_docs/swagger/components/parameters.yaml
@@ -0,0 +1,30 @@
Date:
name: Date
in: header
schema:
type: string
pattern: "^[A-Z][a-z]{2}, [0-9]{2} [A-Z][a-z]{2} [0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2} [A-Z]{3}$"
required: true
description: Current time and date of request in HTTP Date Header format (RFC 7321)
example: "Tue, 06 Jul 2016 04:39:43 GMT"

ContentMd5:
name: Content-MD5
in: header
schema:
type: string
format: byte
required: true
description: Base-64 encoded MD5 hash of request body (without HTTP verb and Headers)
example: 1B2M2Y8AsgTpgAmY7PhCfg==

Authorization:
name: Authorization
in: header
schema:
type: string
required: true
description: >-
Header containing HMAC type, organization credentials and request signature
(more information available at the top of this page)
example: APIAuth-HMAC-SHA256 112233:oDUPWnSduVE+DmkqQC7m3CP66ycVhQImHxmdW2COmio=
61 changes: 61 additions & 0 deletions api_docs/swagger/components/requestBodies/fields.yaml
@@ -0,0 +1,61 @@
# Common fields of the 'partner_order' object

oem_token:
required: true
type: string
example: 987654
minLength: 1
maxLength: 255
description: >-
OEM token used to identify an OEM partner order.
purchased_at:
required: true
type: string
format: date-time
example: "2016-07-06T08:48:22.000Z"
description: >-
Date and time of an OEM partner order. Format: ISO8601.
email:
type: string
format: email
example: john.doe@example.com
description: >-
[Optional] E-mail adress of the OEM partner's customer, who will be notified
once the subscription is activated.
## Fields specific to pre-activation orders ('partner_order' object)

end_user_account_number:
required: true
type: string
example: A123123
description: Either the end user's UC site ID or the end user's SF account number.

# Common fields of objects in 'partner_order_items' array

sku:
type: string
required: true
example: 345-67890
description: SUSE SKU number of purchased item.

system_limit:
type: integer
format: int32
minimum: 1
required: true
example: 2
description: >-
Maximum number (quantity) of systems which can use the given SKU.
## Specific to pre-activation orders ('partner_order_items' array)

starts_at:
type: string
format: date-time
example: "2016-07-06T08:48:22.000Z"
description: >-
Date and time when the SKU lifetime starts; subscription start date.
Format: ISO8601.
@@ -0,0 +1,6 @@
type: object
properties:
sku:
$ref: '/swagger/components/requestBodies/fields.yaml#/sku'
system_limit:
$ref: '/swagger/components/requestBodies/fields.yaml#/system_limit'
@@ -0,0 +1,65 @@
required: true
content:
application/json:
schema:
type: object
properties:
partner_order:
required: true
type: object
description: Object which represents the order to be placed.
properties:
oem_token:
$ref: '/swagger/components/requestBodies/fields.yaml#/oem_token'
purchased_at:
$ref: '/swagger/components/requestBodies/fields.yaml#/purchased_at'
email:
$ref: '/swagger/components/requestBodies/fields.yaml#/email'
partner_order_items:
required: true
type: array
description: List of all order items.
items:
$ref: '/swagger/components/requestBodies/partner_order_item_payload.yaml'
description: |-
Payload to create an OEM partner order on SCC API.
The request's payload *must* contain a JSON object that *should* correspond to
a single order.
At the root of the main JSON object, there *must* be an unique key named
`"partner_order"`, whose value *should* be an JSON object representing an OEM
partner order, containing the following keys:
- `"oem_token"`: string, **required**
Value *must* be a string, with a maximum length of 255 characters.
It *should not* be empty, and must be unique per OEM partner at the moment
of placing a new order. It is generated and kept by the OEM partner.
- `"purchased_at"`: string, **required**
Value *must* be a string, ISO8601-formatted. It must be older than the
current date and time (cannot be a moment in the future). It represents
the date and time at which the customer placed the order with the OEM
partner.
- `"email"`: string, *optional*
Value *must* be a string, email-formatted. The key-value pair *may* be
ommited. It represents the customer's email address to be notified aboutt
activated subscriptions.
- `"partner_order_items"`: array of JSON objects, **required**
Value *must* be an array of JSON objects representing the order items.
Those objects *should* contain the following keys:
- `"sku"`: string, **required**
Value *must* be a string and *must* match a valid SUSE SKU.
- `"system_limit"`: integer, **required**
Value *must* be an integer greater than one. It represents the maximum
number of systems which can use the given SKU simultaneously.
@@ -0,0 +1,8 @@
type: object
properties:
sku:
$ref: '/swagger/components/requestBodies/fields.yaml#/sku'
system_limit:
$ref: '/swagger/components/requestBodies/fields.yaml#/system_limit'
starts_at:
$ref: '/swagger/components/requestBodies/fields.yaml#/starts_at'
@@ -0,0 +1,81 @@
required: true
content:
application/json:
schema:
type: object
properties:
partner_order:
type: object
required: true
description: Main object containing all required data to create an order.
properties:
oem_token:
$ref: '/swagger/components/requestBodies/fields.yaml#/oem_token'
end_user_account_number:
$ref: '/swagger/components/requestBodies/fields.yaml#/end_user_account_number'
purchased_at:
$ref: '/swagger/components/requestBodies/fields.yaml#/purchased_at'
email:
$ref: '/swagger/components/requestBodies/fields.yaml#/email'
partner_order_items:
required: true
type: array
description: List of all order items.
items:
$ref: '/swagger/components/requestBodies/pre_activation/partner_order_item_payload.yaml'
description: |-
Payload to create an OEM partner order and pre-activate it on SCC API.
The request's payload *must* contain a JSON object that *should* correspond to
a single order.
At the root of the main JSON object, there *must* be an unique key named
`"partner_order"`, whose value *should* be an JSON object representing an OEM
partner order, containing the following keys:
- `"oem_token"`: string, **required**
Value *must* be a string, with a maximum length of 255 characters.
It *should not* be empty, and must be unique per OEM partner at the moment
of placing a new order. It is generated and kept by the OEM partner.
- `"purchased_at"`: string, **required**
Value *must* be a string, ISO8601-formatted. It must be older than the
current date and time (cannot be a moment in the future). It represents
the date and time at which the customer placed the order with the OEM
partner.
- `"end_user_account_number"`: string, **required**
Value *must* be a string which identifies the end user (customer) within
the SCC domain. It *must* be either the end user's UC site ID or the end
user's Sales Force account number. It *should* be informed by the end user
to the OEM partner prior to placing an order to SUSE.
- `"email"`: string, *optional*
Value *must* be a string, email-formatted. The key-value pair *may* be
ommited. It represents the customer's email address to be notified aboutt
activated subscriptions.
- `"partner_order_items"`: array of JSON objects, **required**
Value *must* be an array of JSON objects representing the order items.
Those objects *should* contain the following keys:
- `"sku"`: string, **required**
Value *must* be a string and *must* match a valid SUSE SKU.
- `"system_limit"`: integer, **required**
Value *must* be an integer greater than one. It represents the maximum
number of systems which can use the given SKU simultaneously.
- `"starts_at"`: string, *optional*
Value *must* be a string, ISO8601-formatted. It *must* be newer than
the current date and time (cannot be a moment in the past). It is used
to define the start date of a SKU lifetime. If omited, the lifetime
starts once SCC successfully activates the order item.

0 comments on commit abe57ef

Please sign in to comment.