diff options
author | John Estabrook <jestabro@vyos.io> | 2021-11-22 13:37:39 -0600 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2021-11-24 13:33:45 -0600 |
commit | 97022cea7fe4bb56919bcaa85568afac2420aba7 (patch) | |
tree | dc2f4e697bb4cdd6cf16ba4f391bf5a5419a84a4 /src | |
parent | 715b3c05b6f6bed436c7651d8a7897e8c120329b (diff) | |
download | vyos-1x-97022cea7fe4bb56919bcaa85568afac2420aba7.tar.gz vyos-1x-97022cea7fe4bb56919bcaa85568afac2420aba7.zip |
graphql: T3993: normalize naming conventions
(cherry picked from commit fb2dc58d91bd93ba3aaa63d46e49e6609c18d46f)
Diffstat (limited to 'src')
-rw-r--r-- | src/services/api/graphql/README.graphql | 20 | ||||
-rw-r--r-- | src/services/api/graphql/graphql/mutations.py | 10 | ||||
-rw-r--r-- | src/services/api/graphql/graphql/schema/config_file.graphql | 16 | ||||
-rw-r--r-- | src/services/api/graphql/graphql/schema/dhcp_server.graphql | 8 | ||||
-rw-r--r-- | src/services/api/graphql/graphql/schema/interface_ethernet.graphql | 8 | ||||
-rw-r--r-- | src/services/api/graphql/graphql/schema/schema.graphql | 8 | ||||
-rw-r--r-- | src/services/api/graphql/recipes/create_dhcp_server.py (renamed from src/services/api/graphql/recipes/dhcp_server.py) | 2 | ||||
-rw-r--r-- | src/services/api/graphql/recipes/create_interface_ethernet.py (renamed from src/services/api/graphql/recipes/interface_ethernet.py) | 2 | ||||
-rw-r--r-- | src/services/api/graphql/recipes/templates/create_dhcp_server.tmpl (renamed from src/services/api/graphql/recipes/templates/dhcp_server.tmpl) | 0 | ||||
-rw-r--r-- | src/services/api/graphql/recipes/templates/create_interface_ethernet.tmpl (renamed from src/services/api/graphql/recipes/templates/interface_ethernet.tmpl) | 0 |
10 files changed, 39 insertions, 35 deletions
diff --git a/src/services/api/graphql/README.graphql b/src/services/api/graphql/README.graphql index a387f3276..6e9e16c6b 100644 --- a/src/services/api/graphql/README.graphql +++ b/src/services/api/graphql/README.graphql @@ -10,7 +10,7 @@ to run with that address as default router by requesting these 'mutations' in the GraphQL playground: mutation { - createInterfaceEthernet (data: {interface: "eth1", + CreateInterfaceEthernet (data: {interface: "eth1", address: "192.168.0.1/24", description: "BOB"}) { success @@ -22,7 +22,7 @@ mutation { } mutation { - createDhcpServer(data: {sharedNetworkName: "BOB", + CreateDhcpServer(data: {sharedNetworkName: "BOB", subnet: "192.168.0.0/24", defaultRouter: "192.168.0.1", nameServer: "192.168.0.1", @@ -45,7 +45,7 @@ mutation { To save the configuration, use the following mutation: mutation { - saveConfigFile(data: {fileName: "/config/config.boot"}) { + SaveConfigFile(data: {fileName: "/config/config.boot"}) { success errors data { @@ -64,7 +64,7 @@ https://hostname/graphql), one can load an arbitrary config file from a path. mutation { - loadConfigFile(data: {fileName: "/home/vyos/config.boot"}) { + LoadConfigFile(data: {fileName: "/home/vyos/config.boot"}) { success errors data { @@ -89,22 +89,26 @@ What's here: services ├── api │ └── graphql +│ ├── bindings.py │ ├── graphql │ │ ├── directives.py │ │ ├── __init__.py │ │ ├── mutations.py │ │ └── schema +│ │ ├── config_file.graphql │ │ ├── dhcp_server.graphql │ │ ├── interface_ethernet.graphql │ │ └── schema.graphql +│ ├── README.graphql │ ├── recipes -│ │ ├── dhcp_server.py +│ │ ├── config_file.py +│ │ ├── create_dhcp_server.py +│ │ ├── create_interface_ethernet.py │ │ ├── __init__.py -│ │ ├── interface_ethernet.py │ │ ├── recipe.py │ │ └── templates -│ │ ├── dhcp_server.tmpl -│ │ └── interface_ethernet.tmpl +│ │ ├── create_dhcp_server.tmpl +│ │ └── create_interface_ethernet.tmpl │ └── state.py ├── vyos-configd ├── vyos-hostsd diff --git a/src/services/api/graphql/graphql/mutations.py b/src/services/api/graphql/graphql/mutations.py index 8c613b9ca..02d5be0ef 100644 --- a/src/services/api/graphql/graphql/mutations.py +++ b/src/services/api/graphql/graphql/mutations.py @@ -21,9 +21,9 @@ def make_configure_resolver(mutation_name): :raise Exception: encapsulating ConfigErrors, or internal errors """ - class_name = mutation_name.replace('create', '', 1).replace('delete', '', 1) + class_name = mutation_name func_base_name = convert_camel_case_to_snake(class_name) - resolver_name = f'resolve_create_{func_base_name}' + resolver_name = f'resolve_{func_base_name}' func_sig = '(obj: Any, info: GraphQLResolveInfo, data: Dict)' @mutation.field(mutation_name) @@ -59,12 +59,12 @@ def make_configure_resolver(mutation_name): def make_config_file_resolver(mutation_name): op = '' - if 'save' in mutation_name: + if 'Save' in mutation_name: op = 'save' - elif 'load' in mutation_name: + elif 'Load' in mutation_name: op = 'load' - class_name = mutation_name.replace('save', '', 1).replace('load', '', 1) + class_name = mutation_name.replace('Save', '', 1).replace('Load', '', 1) func_base_name = convert_camel_case_to_snake(class_name) resolver_name = f'resolve_{func_base_name}' func_sig = '(obj: Any, info: GraphQLResolveInfo, data: Dict)' diff --git a/src/services/api/graphql/graphql/schema/config_file.graphql b/src/services/api/graphql/graphql/schema/config_file.graphql index 3096cf743..31ab26b9e 100644 --- a/src/services/api/graphql/graphql/schema/config_file.graphql +++ b/src/services/api/graphql/graphql/schema/config_file.graphql @@ -1,27 +1,27 @@ -input saveConfigFileInput { +input SaveConfigFileInput { fileName: String } -type saveConfigFile { +type SaveConfigFile { fileName: String } -type saveConfigFileResult { - data: saveConfigFile +type SaveConfigFileResult { + data: SaveConfigFile success: Boolean! errors: [String] } -input loadConfigFileInput { +input LoadConfigFileInput { fileName: String! } -type loadConfigFile { +type LoadConfigFile { fileName: String! } -type loadConfigFileResult { - data: loadConfigFile +type LoadConfigFileResult { + data: LoadConfigFile success: Boolean! errors: [String] } diff --git a/src/services/api/graphql/graphql/schema/dhcp_server.graphql b/src/services/api/graphql/graphql/schema/dhcp_server.graphql index 9f741a0a5..25f091bfa 100644 --- a/src/services/api/graphql/graphql/schema/dhcp_server.graphql +++ b/src/services/api/graphql/graphql/schema/dhcp_server.graphql @@ -1,4 +1,4 @@ -input dhcpServerConfigInput { +input DhcpServerConfigInput { sharedNetworkName: String subnet: String defaultRouter: String @@ -13,7 +13,7 @@ input dhcpServerConfigInput { dnsForwardingListenAddress: String } -type dhcpServerConfig { +type DhcpServerConfig { sharedNetworkName: String subnet: String defaultRouter: String @@ -28,8 +28,8 @@ type dhcpServerConfig { dnsForwardingListenAddress: String } -type createDhcpServerResult { - data: dhcpServerConfig +type CreateDhcpServerResult { + data: DhcpServerConfig success: Boolean! errors: [String] } diff --git a/src/services/api/graphql/graphql/schema/interface_ethernet.graphql b/src/services/api/graphql/graphql/schema/interface_ethernet.graphql index fdcf97bad..32438b315 100644 --- a/src/services/api/graphql/graphql/schema/interface_ethernet.graphql +++ b/src/services/api/graphql/graphql/schema/interface_ethernet.graphql @@ -1,18 +1,18 @@ -input interfaceEthernetConfigInput { +input InterfaceEthernetConfigInput { interface: String address: String replace: Boolean = true description: String } -type interfaceEthernetConfig { +type InterfaceEthernetConfig { interface: String address: String description: String } -type createInterfaceEthernetResult { - data: interfaceEthernetConfig +type CreateInterfaceEthernetResult { + data: InterfaceEthernetConfig success: Boolean! errors: [String] } diff --git a/src/services/api/graphql/graphql/schema/schema.graphql b/src/services/api/graphql/graphql/schema/schema.graphql index 4730f24bc..e34a4eadb 100644 --- a/src/services/api/graphql/graphql/schema/schema.graphql +++ b/src/services/api/graphql/graphql/schema/schema.graphql @@ -11,8 +11,8 @@ directive @configure on FIELD_DEFINITION directive @configfile on FIELD_DEFINITION type Mutation { - createDhcpServer(data: dhcpServerConfigInput) : createDhcpServerResult @configure - createInterfaceEthernet(data: interfaceEthernetConfigInput) : createInterfaceEthernetResult @configure - saveConfigFile(data: saveConfigFileInput) : saveConfigFileResult @configfile - loadConfigFile(data: loadConfigFileInput) : loadConfigFileResult @configfile + CreateDhcpServer(data: DhcpServerConfigInput) : CreateDhcpServerResult @configure + CreateInterfaceEthernet(data: InterfaceEthernetConfigInput) : CreateInterfaceEthernetResult @configure + SaveConfigFile(data: SaveConfigFileInput) : SaveConfigFileResult @configfile + LoadConfigFile(data: LoadConfigFileInput) : LoadConfigFileResult @configfile } diff --git a/src/services/api/graphql/recipes/dhcp_server.py b/src/services/api/graphql/recipes/create_dhcp_server.py index 3edb3028e..ac6f15209 100644 --- a/src/services/api/graphql/recipes/dhcp_server.py +++ b/src/services/api/graphql/recipes/create_dhcp_server.py @@ -1,7 +1,7 @@ from . recipe import Recipe -class DhcpServer(Recipe): +class CreateDhcpServer(Recipe): def __init__(self, session, command_file): super().__init__(session, command_file) diff --git a/src/services/api/graphql/recipes/interface_ethernet.py b/src/services/api/graphql/recipes/create_interface_ethernet.py index f88f5924f..aafb4d55c 100644 --- a/src/services/api/graphql/recipes/interface_ethernet.py +++ b/src/services/api/graphql/recipes/create_interface_ethernet.py @@ -1,7 +1,7 @@ from . recipe import Recipe -class InterfaceEthernet(Recipe): +class CreateInterfaceEthernet(Recipe): def __init__(self, session, command_file): super().__init__(session, command_file) diff --git a/src/services/api/graphql/recipes/templates/dhcp_server.tmpl b/src/services/api/graphql/recipes/templates/create_dhcp_server.tmpl index 70de43183..70de43183 100644 --- a/src/services/api/graphql/recipes/templates/dhcp_server.tmpl +++ b/src/services/api/graphql/recipes/templates/create_dhcp_server.tmpl diff --git a/src/services/api/graphql/recipes/templates/interface_ethernet.tmpl b/src/services/api/graphql/recipes/templates/create_interface_ethernet.tmpl index d9d7ed691..d9d7ed691 100644 --- a/src/services/api/graphql/recipes/templates/interface_ethernet.tmpl +++ b/src/services/api/graphql/recipes/templates/create_interface_ethernet.tmpl |