-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
186 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
16 changes: 16 additions & 0 deletions
16
src/sonic-yang-models/tests/yang_model_tests/tests/restapi.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"RESTAPI_TABLE_WITH_INCORRECT_CERT": { | ||
"desc": "RESTAPI TABLE_WITH_INCORRECT_CERT failure.", | ||
"eStr": ["Value", "does not satisfy the constraint"] | ||
}, | ||
"RESTAPI_TABLE_WITH_INCORRECT_CLIENT": { | ||
"desc": "RESTAPI TABLE_WITH_INCORRECT_CLIENT failure.", | ||
"eStr": ["Value", "does not satisfy the constraint"] | ||
}, | ||
"RESTAPI_TABLE_WITH_VALID_CONFIG": { | ||
"desc": "RESTAPI TABLE WITH VALID CONFIG." | ||
}, | ||
"RESTAPI_TABLE_WITH_MULTIPLE_CERTS": { | ||
"desc": "RESTAPI TABLE WITH MULTIPLE CERTS." | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/sonic-yang-models/tests/yang_model_tests/tests_config/restapi.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"RESTAPI_TABLE_WITH_INCORRECT_CERT": { | ||
"sonic-restapi:sonic-restapi": { | ||
"sonic-restapi:RESTAPI": { | ||
"certs": { | ||
"ca_crt": "/etc/sonic/credentials/ame_root.pem", | ||
"server_crt": "a/b/c", | ||
"server_key": "/etc/sonic/credentials/restapiserver.key", | ||
"client_crt_cname": "client" | ||
} | ||
} | ||
} | ||
}, | ||
"RESTAPI_TABLE_WITH_INCORRECT_CLIENT": { | ||
"sonic-restapi:sonic-restapi": { | ||
"sonic-restapi:RESTAPI": { | ||
"certs": { | ||
"ca_crt": "/etc/sonic/credentials/ame_root.pem", | ||
"server_crt": "/etc/sonic/credentials/restapiserver.crt", | ||
"server_key": "/etc/sonic/credentials/restapiserver.key", | ||
"client_crt_cname": "/client" | ||
} | ||
} | ||
} | ||
}, | ||
"RESTAPI_TABLE_WITH_VALID_CONFIG": { | ||
"sonic-restapi:sonic-restapi": { | ||
"sonic-restapi:RESTAPI": { | ||
"certs": { | ||
"ca_crt": "/etc/sonic/credentials/ame_root.pem", | ||
"server_crt": "/etc/sonic/credentials/restapiserver.crt", | ||
"server_key": "/etc/sonic/credentials/restapiserver.key", | ||
"client_crt_cname": "client.sonic.net" | ||
} | ||
} | ||
} | ||
}, | ||
"RESTAPI_TABLE_WITH_MULTIPLE_CERTS": { | ||
"sonic-restapi:sonic-restapi": { | ||
"sonic-restapi:RESTAPI": { | ||
"certs": { | ||
"ca_crt": "/etc/sonic/credentials/ame_root.pem", | ||
"server_crt": "/etc/sonic/credentials/restapiserver.crt", | ||
"server_key": "/etc/sonic/credentials/restapiserver.key", | ||
"client_crt_cname": "client.sonic.net,clientds.prod.net" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
module sonic-restapi { | ||
|
||
yang-version 1.1; | ||
|
||
namespace "http://github.com/sonic-net/sonic-restapi"; | ||
prefix restapi; | ||
|
||
import ietf-inet-types { | ||
prefix inet; | ||
} | ||
|
||
organization | ||
"SONiC"; | ||
|
||
contact | ||
"SONiC"; | ||
|
||
description "RESTAPI YANG Module for SONiC OS"; | ||
|
||
revision 2022-10-05 { | ||
description "First Revision"; | ||
} | ||
|
||
container sonic-restapi { | ||
|
||
container RESTAPI { | ||
|
||
description "RESTAPI TABLE part of config_db.json"; | ||
|
||
container certs { | ||
|
||
leaf ca_crt { | ||
type string { | ||
pattern '(/[a-zA-Z0-9_-]+)*/([a-zA-Z0-9_-]+).([a-z]+)'; | ||
} | ||
description "Local path for ca_crt."; | ||
} | ||
|
||
leaf server_crt { | ||
type string { | ||
pattern '(/[a-zA-Z0-9_-]+)*/([a-zA-Z0-9_-]+).crt'; | ||
} | ||
description "Local path for server_crt."; | ||
} | ||
|
||
leaf client_crt_cname { | ||
type string { | ||
pattern '([a-zA-Z0-9_\-\.]+,)*([a-zA-Z0-9_\-\.]+)'; | ||
} | ||
description "Client cert name."; | ||
} | ||
|
||
leaf server_key { | ||
type string { | ||
pattern '(/[a-zA-Z0-9_-]+)*/([a-zA-Z0-9_-]+).key'; | ||
} | ||
description "Local path for server_key."; | ||
} | ||
|
||
} | ||
|
||
container config { | ||
|
||
leaf client_auth { | ||
type boolean; | ||
default true; | ||
description "Enable client authentication"; | ||
} | ||
|
||
leaf log_level { | ||
type string { | ||
pattern "trace|info"; | ||
} | ||
description "container log level for restapi"; | ||
} | ||
|
||
leaf allow_insecure { | ||
type boolean; | ||
default false; | ||
description "Allow insecure connection"; | ||
} | ||
} | ||
} | ||
} | ||
} |