Last active
March 7, 2021 00:39
-
-
Save cedricbonhomme/a4dca56fa1357f7134901d8e3490d698 to your computer and use it in GitHub Desktop.
Example creation of object on MOSP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# -*- coding: utf-8 - | |
import requests | |
import uuid | |
# The JSON object | |
json_object = { | |
"authors": ["Consortium GARR [www.garr.it]"], | |
"label": "Cybersecurity Framework v. 2.0", | |
"language": "IT", | |
"refs": ["https://www.cybersecurityframework.it"], | |
"uuid": str(uuid.uuid4()), | |
"values": [ | |
{ | |
"category": "Asset Management (ID.AM)", | |
"code": "1_ID.AM-1", | |
"label": "Sono censiti i sistemi e gli apparati fisici in uso nell'organizzazione", | |
"uuid": str(uuid.uuid4()), | |
}, | |
{ | |
"category": "Asset Management (ID.AM)", | |
"code": "1_ID.AM-2", | |
"label": "Sono censite le piattaforme e le applicazioni software in uso nell'organizzazione", | |
"uuid": str(uuid.uuid4()), | |
}, | |
{ | |
"category": "Asset Management (ID.AM)", | |
"code": "1_ID.AM-3", | |
"label": "I flussi di dati e comunicazioni inerenti l'organizzazione sono identificati", | |
"uuid": str(uuid.uuid4()), | |
}, | |
], | |
"version": 2, | |
"version_ext": "0", | |
} | |
# Information relative to the object | |
data = { | |
"name": "Framework Nazionale per la Cybersecurity e la Data Protection v. 2.0 [IT] [draft, just started]", | |
"description": 'A MONARC object for the "Framework Nazionale per la Cybersecurity e la Data Protection" v. 2.0 specs [www.cybersecurityframework.it] ', | |
"org_id": 15, | |
"schema_id": 12, | |
"json_object": json_object, | |
} | |
result = requests.post( | |
url='https://objects.monarc.lu/api/v1/json_object', | |
headers={ | |
"Authorization": "Token <YOUR-TOKEN>", | |
"Content-Type": "application/json", | |
"Accept": "application/json" | |
}, | |
json=data, | |
) | |
if result.status_code != 201: | |
print(result.reason) | |
else: | |
print(result.content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment